Click here to load reader
Upload
meljun-cortes
View
219
Download
13
Embed Size (px)
Citation preview
* Property of STIPage 1 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Classification of Instructions
Classification of Instructions:
1. Data Transfer Instructions2. Arithmetic Instructions3. Logic Instructions4. Shift Instructions5. Rotate Instructions6. Flag Control Instructions7. Jump Instructions8. String Instructions
* Property of STIPage 2 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
MOV Instruction
Ø The MOV instruction facilitates the movement of data either between registers or between a register and main memory. They do not affect the flags.
Format: MOV D, SAction: D [S]
MOV [BP+SI+1000H], DSseg regMM
MOV SS, [1AFFH]MMseg reg
MOV AX, CSseg regregister
MOV DS, BXregisterseg reg
MOV word ptr [BX], 1834HimmediateMM
MOV CX, 80FEHimmediateregister
MOV [BX], DXregisterMM
MOV CX, [BP+SI]MMregister
MOV CX, BXregisterregister
ExampleSourceDestination
* Property of STIPage 3 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Example – MOV Instruction
Ø Determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
MOV AX, BXMOV DI, 0005HMOV [BP + SI], AX
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 4 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
The XCHG Instruction
Ø The XCHG (Exchange) instruction swaps the contents of the source and destination operands.
Format: XCHG D, SAction: [D] [S]
XCHG AH, BLregisterregister
XCHG [BX], CXregisterMM
ExampleSourceDestination
* Property of STIPage 5 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Example – XCHG Instruction
Ø Determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
XCHG DI, SIXCHG BX, [CX]XCHG [BX + 0020H], AX
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 6 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Exercise 1
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
MOV AX, 0034HXCHG CX, [AX]MOV [CX + SI], BX
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 7 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Quiz 1
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
XCHG AX, BXMOV [CX], AXXCHG BX, [CX + SI + 000FH]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 8 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
The PUSH Instruction
Ø The PUSH instruction decrements SP by 2 and then moves a word data from the source operand to the top of the stack pointed to by SP.
Format: PUSH SAction: SP SP - 2
[SP+ 1] [SH][SP] [SL]
PUSH BETAMM
PUSH DSseg reg
PUSH AXregister
ExampleSource
* Property of STIPage 9 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Example – PUSH Instruction
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
PUSH AXPUSH [BX]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 10 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Exercise 2
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
PUSH DXPUSH [BX + DI]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 11 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
The POP Instruction
Ø POP transfers a word data pointed to by SP to the destination operand. Afterwards, the value of SP is incremented by 2.
Format: POP DAction: DL [SP]
DH [SP + 1]SP SP + 2
POP BETAMM
POP DSseg reg
POP AXregister
ExampleDestination
* Property of STIPage 12 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Example – POP Instruction
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
POP AXPOP [BX]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 13 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Exercise 3
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
POP CXPOP [BX + DI + 000AH]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 14 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Quiz 2
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
POP CXPOP [BP+ SI + 0010H]PUSH SIPUSH [DI]
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 15 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
The LEA Instruction
Ø The LEA (Load Effective Address) instruction is for transferring the effective address (not data) of the source operand to the destination operand. Format: LEA D, SAction: D EA of S
Example: Assume the following:DS = 5000HLIST = 1800H
44H
33H
22H
11H
51800H
517FFH
51801H
51802H
* Property of STIPage 16 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Example – LEA Instruction
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
LIST = 0020H ALPHA = 0030H GAMMA = 0040H
MOV AX, LISTLEA BX, ALPHALEA DI, GAMMA
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 17 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Exercise 4
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
LEA AX, LISTMOV ALPHA, BXMOV GAMMA, DILEA SI, ALPHA
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =
* Property of STIPage 18 of 18
Data Transfer Instructions
Computer Organization and Assembly Language
Data Transfer Instruction Exercise
Ø Unless otherwise stated, determine the contents of all the affected general purpose registers and memory addresses after executing the following program. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents:
POP BXMOV AX, [CX]MOV BP, AXMOV SI, [0074H]MOV CX, [BP + SI]PUSH CX
4000HES =001EHSI =001BHDX =
2000HSS =0017HDI =0012HCX =
2000HDS =0035HSP =0019HBX =
3000HCS =0002HBP =0015HAX =