












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Register addressing mode,^Immediate addressing mode,^ Direct addressing mode,^register indirect addressing mode,^ Based addressing mode,^Indexed addressing mode,^ Based indexed addressing mode,^String addressing mode, and^ `Port addressing mode.a^ Instruction gets its source data from a register. a^ Data can be either 8 or 16 bits in length a^ Data resulting from the operation is stored in another register.^ Examples:^ MOV AX, BX
; copy the 16-bit content of BX to AXMOV AL, BL ; copy the 8-bit content of BL to ALMOV SI, DI ; copy DI into SIMOV DS, AX^ ; copy AX into DS Note: The following register to register transfers are not permitted:MOV BL, BX
; Not permitted (mixed sizes)MOV CS, AX^ ; Not permitted (CS cannot be the destination) (?)MOV ES, DS^ ; Not allowed (segment register to segment register forbidden)
Source
^ Hexadecimal numbers are usually denoted by appending an H (or h) andpreceded by 0 if they start with a letter e.g. 0Fh, 0A8h, 0F34Bh^^ Binary numbers are usually denoted by appending a B (or b).^ `^ Text characters (their ASCII code) are enclosed by apostrophe(‘).MOV AL, 0Ah
; load 0Ah into AL
; copies AL to 11234h; Assume DS=1000h
; load the contents at address 10020h and 10021h; into AL and AH, respectively MOV [1234h], AL
; copy AL to address 11234h MOV ES:[1234h], AL
; copy AL to address 21234h MOV FRED, AL
; copy AL to address14567h (offset is calculated by the; assembler)
(with BX=0222h, DS=1000h, SS=2000h, BP=0111h)MOV CX, [BX]^
; copy a word from address 10222h and 10223h to CX MOV [BP], DL
; copy a byte from register DL to address 20111h Note : BP defaults to SS
(with DS=1000h, SS=2000h, BP=0222h, BX=0111h)MOV AX, [BP-2]^
; copy the content of 20220h and 20221h to AX MOV [BX+777h], AX
; copy AL to 10888h and AH to 10889h
; This syntax is used above MOV [DI]+FRED, BLMOV FRED[DI], BL
Q: what if the resultant offset >65535? a^ By default, the segment address is derived from DS, except the BPregister, which is derived from SS. a^ A signed displacement may also be included to calculate the offset.^ Example
(assumes SS=1000h, SI=3333h, BP=2222h)MOV AX, [SI+BP]^ ; load the content of 15555h and 15556h to; AL and AH respectivelyMOV AX, [SI+BP+1111h]; load the contents of 16666H and; 16667h to AL and AH respectivelyNote: This addressing mode includes the base-plus-index and base-relative-plus-index addressing modes defined in Brey’s.
; put the content of I/O port 40H into ALOUT 80h, AL^ ; send the contents of AL to I/O port 80h a^ The I/O ports may be addressed using the register DX (full range of65536 ports are accessible)^ Examples:^ IN AL, DX
; Load AL with the byte from port address given by DXOUT DX, AX^ ; Send the word in AX to port address given by DXQ: Is the instruction “MOV AL, DX;” valid?
e.g. MOV AX, 1234h a^ in a register (register addressing).
e.g. MOV DS, AX;
a^ in memory at a specified offset. The offset may be specified by one of thefollowing (displacement is a constant or label expression):^ ^ [displacement]^ ^ [BP]
[BP+displacement] ^ [BX]^
[BX+displacement] ^ [SI]^
[SI+displacement] ^ [DI]^
[DI+displacement] ^ [BX+SI]^
[BX+SI+displacement] ^ [BX+DI]^
[BX+DI+displacement] ^ [BP+SI]^
[BP+SI+displacement] ^ [BP+DI]^
[BP+DI+displacement]
(by default, except when BP is used)
a^ in memory locations given implicitly by string instructions. a^ at input/output ports specified by a register or a constant.
See Brey’s Table 3-12for more examples
; Jump to the current code segment location addressed by; the content of CX. a^ Stack addressing mode uses the PUSH and POP instruction to transferdata between the stack memory and registers or direct data.Example:POPF
; Remove a word from stack and place it into the flagPUSH DS^ ; Copy DS to the stackPUSH 1234h^ ; Copy a 1234h to the stack
Algorithm
PrincipalAdvantage
PrincipalDisadvantage
Register^
No memoryreference
Limited addressspace
Immediate^
Operand = A
No memoryreference
Limited operandmagnitude
Direct^
Simple^
Less flexible
Registerindirect
Large addressspace
Extra memoryreference
Base-IndexRelative
Flexibility^
Complexity
Stack^
EA = top ofstack
No memoryreference
LimitedapplicabilityEA: effective addressR: RegisterA: a constant
Example MOV AX,BXMOV CH, 3AhMOV [123h], AXMOV [BX], CLMOV [BX+SI+30h], DXPOP^ DX