Chapter 3.1.3
Chapter 3.1.3
• - memory to register
• - register to memory
• - register to register
• - memory to memory
Data transfer Group
MOVE INSTRUCTION
DATA TRANSFER | ADDRESSING MODE | IMMEDIATE DATA
D1 = AABBCCDD
Obtain the new content of register D1 after following instruction is
executed.
ANSWER:
D0 = AABBCCDD D1 = 11223344
Obtain the new content of register D1 after following instruction is
executed.
ANSWER:
A0 = AABBCCDD A1 = 11223344
Obtain the new content of register D1 after following instruction is
executed.
ANSWER:
D6 = AB206541
A2 = 00006541
MOVEA INSTRUCTION
DATA TRANSFER |ADDRESSING MODE |IMMEDIATE DATA
2) MOVEA.W #$8C00,A0
ANSWER:
A0 = FFFF8C00
MOVEA INSTRUCTION
DATA TRANSFER |ADDRESSING MODE |REGISTER DIRECT
3) MOVEA.W D6,A2
ANSWER:
D6 = AB20A541
A2 = FFFFA541
MOVEA INSTRUCTION
DATA TRANSFER |ADDRESSING MODE |REGISTER DIRECT
4) MOVEA.L D6,A2
ANSWER:
D6 = $AB206541
A2 = $AB206541
EXG INSTRUCTION
DATA TRANSFER |ADDRESSING MODE |REGISTER DIRECT
• EXG = Exchange
• EXG interchanges the contents of two registers.
• operand size for EXG is longword
1) EXG D1,D5
1) SWAP D1 2) SWAP D1
Before : D1 = 11223344 Before : D1 = $01234567
After : D1 = 33441122 After : D1 = $45670123
CLR INSTRUCTION
DATA TRANSFER |ADDRESSING MODE |REGISTER DIRECT
• CLR = Clear
• Loads the target with 0
1) CLR.B D1 2) CLR.W D1
Before : D1 = 11223344 Before : D1 = 11223344
After : D1 = 11223300 After : D1 = 11220000
ARITHMETIC GROUP
After After
D0 = 00002222 D0 = 00002222
D1 = 00202722 D1 = 00200522
ADD INSTRUCTION
ARITMETHIC GROUP|ADDRESSING MODE|IMMEDIATE DATA
Before : D1 = BBCCDDAA
After After
D1 = BBCCDDDA D1 =BBCCE2FF
3) ADD.B #$99,D1
After
D1 =BBCCDD43
ADD INSTRUCTION
ARITMETHIC GROUP|ADDRESSING MODE|ABSOLUTE
Before : D1 = $00200500
$3000 32
$3001 43
$3002 98
After After
D1 = 00203743 D1 =
ADDI INSTRUCTION
ARITMETHIC GROUP|ADDRESSING MODE|IMMEDIATE DATA
1) SUB.B D1,D0
After : D1 = _________ , D0 = __________
2) SUB.W D1,D0
3) SUB.B #$80,D0
After : D0 = __________
4) SUB.W #8000,D0
After : D0 = __________
PRACTICES
MULU INSTRUCTION
ARITMETHIC GROUP|MULTIPLICATION
• 68k microprocessor allows multiplication of 16 bits
destination with 16 bits source.
• Data is accessed via register (D0 to D7), memory, absolute data and
I/O port.
6541
X 0002
CA82
MULU INSTRUCTION
ARITMETHIC GROUP|DATA REGISTER DIRECT
1) DIVU #2,D3
After : D3 =000132A0
Result
i)654116 =2592110 ii) iii) Result :
Balance
Balance :
16 bit lower(result) 16 bit upper 110 = 116
( remainder/ balance)
DIVU INSTRUCTION
ARITMETHIC GROUP|IMMEDIATE DATA
2) DIVU #$1234,D0
i) Convert into decimal no
ii) Perform division between two
Before : D0= $00005678 number
iii) Convert back into hexadecimal
no
After : D0 = $0DA80004
Result
Balance
BEFORE
PRACTICES
BEFORE
PRACTICES
BEFORE
NEG operation
$41 = 01000001
NEG.B D3 Invert 1011111 0
+ 1
Before : D3 = $AB206541 $BF = 10111111
After : D3 = $AB2065BF
Example 2:
NEG.W D3
Before : D3 = $AB206541
After : D3 = $AB209ABF
Example 3:
NEG.W D3
Before : D3 = $AB202528
After : D3 = ___________
LOGICAL GROUP
Example 1:
• NOT.B D1 [D1(B) NOT D1 ]
(content in D1 is NOT, and the product is stored back to D1)
0101 0101
Example 1
Write the coding by using assembly language to
solve the equation below:
4510 +6C16
ORG $1000
MOVE.B #45, D0
MOVE.B #$6C, D1
ADD.B D1,D0
END
Example 2
ORG $1000
MOVE.B #@25, D0
MOVE.B #15, D1
MOVE.B #$A, D2
ADD.B D1, D0
SUB.B D2, D0
END
Example 3
Write the coding by using assembly language
to solve the equation below:
(7008 * 101010112 /ABAC16)
Solution
ORG $1000
MOVE.W #@700, D0
MOVE.W #%10101011, D1
MOVE.W #$ABAC, D2
MULU D1, D0
DIVU D2, D0
END
Example 4
Write the coding by using assembly
language to solve the equation below:
(DE16 AND 778) + 2010
Solution
ORG $1000
MOVE.B #$DE, D0
MOVE.B #@77, D1
MOVE.B #20, D2
AND.B D1,D0
ADD.B D2,D0
END
Simplify the equation below
Thank You…