Академический Документы
Профессиональный Документы
Культура Документы
Introduction
language.
Everything is 0s and 1s.
Instructions.
Data.
Control signals.
Hard
00110000001111000000000000010010
00
11
000 000
(Data register direct
addressing mode, D0)
Assembly Language
to understand, program.
Assembly Language
The Assembler
Assembly Language:
Machine Language:
00110000001111000
01100100011110000
00000000110100
MOVE.W
#$12,D0
MOVE.W #$34,D1
MULU
D1,D0
Assembler
Assembly
File #1
Assembly
File #2
Assembly
File #3
Assembly
File #4
ASSEMBLER
Listing File
Object
File #1
Object
File #2
Object
File #3
LINKER
Final Object
File
Object
File #4
Listing File
Data Representation
Methods
Data Sizes
Bit:
Most basic representation.
Contains either 0 or 1.
Can
Nibble: 4 bits.
Can represent 16 values (24).
Not recognized in M68k.
Need to write special program
Byte: 8 bits.
Indicated by .B notation.
Can hold value up to 256 (28).
to handle.
Data Sizes
Word: 16 bits.
Length
Long: 32 bits.
Length
Data Sizes
Bit (1)
D3
D0
Nibble (4)
D7
D0
Byte (8)
D15
D0
Word (16)
D31
D0
Long (32)
Binary
Binary: start with %
Example:
Move
#%10010101,D0
10010101B = 95H
D0 =
Octal
Octal: start with @
Example:
Move
#@45,D0
45O = 25H
D0 =
Hexadecimal
Hexadecimal: start with $
Example:
Move
D0 =
#$FE,D0
Decimal
Decimal: no need to put any symbols.
Example:
Move
#10,D0
10D = 0AH
D0 =
ASCII Characters
Characters: Enclose character in single
quotes ( ).
Example:
Move
MOVE.B
A = 41H
D0 =
Easy68k
Easy68k
Designed by Prof. C. Kelly, Monroe
County Community College.
Freeware.
Installer: http://www.easy68k.com/index.html
Easy68k Quick-Ref:
http://www.easy68k.com/QuickStart/LoadPageFrames.htm
http://www.easy68k.com/files/EASy68KQuickRef.pdf
Easy68k Interface
PROGRAM DESCRIPTION
VARIABLES/PARAMETERS
Simulation Window
Memory address
where instruction
is stored.
Program Instructions
END $1000
ORG
$1000
Program Instructions
END START
Use Labels
Any memory location may be given labels.
Easier to refer to specific locations:
Useful
LABEL1
END
ORG
$1000
MOVE.B
MOVE.B
CLR.B
#$2000,A0
#$10, D1
D0
ADD.B
SUB.B
(A0)+, D0
#1, D1
BNE
LABEL1
START
Flowchart
Flowchart
Graphical method to plan flow of our
programs.
Shows programs step-by-step operation.
Easy to understand and analyze.
Can be used to write organized programs.
Flowchart
Basic shapes:
Terminator.
Process.
Decision.
A=A+B
D0 = 3?
TRUE
Input/Output.
Connectors.
FALSE
Input D0
START
FINISH
Short
Example:
A=A+B
Reset Ports
Clear D0
Examples:
Port is active?
D0 = 3?
TRUE
TRUE
FALSE
FALSE
Input D0
Show calculation
results
Example: Connector
START
Input D0
D0 = D0 x D1
Input D1
FINISH
1
Input L
Area = L xB
Input B
FINISH
1
Translation to Assembly
START
ORG
$1000
Input D0
MOVE.W
#$12,D0
Input D1
MOVE.W
#$34,D1
MULU
D1,D0
D0 = D0 x D1
FINISH
END
Complete Program
START
ORG
$1000
MOVE.W
MOVE.W
#$12,D0
#$34,D1
MULU
D1,D0
END
START
Input numbers
into memory
locations.
Go to next
memory location
Load starting
address into A0
D0 = D0 - 1
D0 = 10
FALSE
D0 = 0?
TRUE
Clear D1
FINISH
START
Input numbers
into memory
locations.
Load starting
address into A0
ORG
$1000
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVEA.L
#$11,$1100
#$22,$1102
#$33,$1104
#$44,$1106
#$55,$1108
#$66,$110A
#$77,$110C
#$88,$110E
#$99,$1110
#$11,$1112
#$1100,A0
D0 = 10
MOVE.B #10,D0
Clear D1
CLR.B
D1 = D1 + (A0)
D1
ADD.W (A0),D1
FALSE
Go to next
memory location
D0 = D0 - 1
D0 = 0?
FINISH
ADDA.L #$2,A0
SUB.B #$1,D0
LOOPBNE LOOP, CMP.B #$0,D0
END
Complete Program
START
ORG
$1000
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
MOVE.W
#$11,$1100
#$22,$1102
#$33,$1104
#$44,$1106
#$55,$1108
#$66,$110A
#$77,$110C
#$88,$110E
#$99,$1110
#$11,$1112
MOVEA.L #$1100,A0
MOVE.B #10,D0
CLR.B
D1
LOOP
ADD.W
ADDA.L
SUB.B
CMP.B
BNE
(A0),D1
#$2,A0
#$1,D0
#$0,D0
LOOP
END
START
Conclusion
Conclusion
Assembly language:
Mnemonics
instead of binary.
Needs assembler to convert to machine code.
Organize
program flow.
Easier to manage and debug.