Tutorial 4
Tutorial 4
06.02.2024
07.02.2024
08.02.2024
12.02.2024
Contents
• Addressing Modes
• Machine Code Formation
• Machine Code Formation with for Segment
Override Prefix
a. MOV CX,DX
b. MOV BX,1234
c. MOV AX,[SI]
d. MOV [offset address], 2345
e. MOV CX, [BX+SI]
f. MOV CX,[BX+SI+1234]
Determine the 16-bit effective addresses (EA) and 20-bit physical address (PA) for the
following addressing modes:
Assume offset or displacement is 0500H and for direct addressing consider the location offset
to be 0100H.
Note: All instructions need not have the W and D bits. In such cases, the size of the operand is implicit, and
the direction is irrelevant.
a. MOV AX,BX
b. MOV BX,1234H
c. MOV AX,[SI]
d. MOV ES,AX
11
MOV AX, BX
So, the data movement is between two registers. As per the instruction encoding format,
d = 1, r/m → reg
w = 1 for 16-bit data
MOD = 11 for register movements
Destination: AX, reg = 000
Source: BX, r/m = 011
Hence, the complete machine code should be: 1000 1011 1100 0011 (8B C3 H)
Go to Tables 12
MOV BX,1234H
The instruction has an immediate field. As per the instruction encoding format,
Hence, the complete machine code should be: 1011 1011 00110100 00010010 (BB 34 12 H)
Go to Tables 13
MOV AX,[SI]
The instruction has an immediate field. As per the instruction encoding format,
d = 1, r/m → reg
w = 1 for 16-bit data
MOD = 00 for no displacement
Destination: AX, reg = 000
Source: [SI], r/m = 100
Hence, the complete machine code should be: 1000 1011 0000 0100 (8B 04 H)
Go to Tables 14
MOV ES,AX
The instruction has an data transfer between accumulator to segment register. As per the
instruction encoding format,
Hence, the complete machine code should be: 1000 1110 1100 0000 (8E C0 H)
Go to Tables 15
a. MOV DS:43D[BP],CX
b. MOV CS:[BX],DH
16
MOV DS:43D[BP],CX
d = 0, reg → r/m
w = 1 for 16-bit data operation.
Source: CX, reg = 001
Destination: DS: 43[BP]
Except the segment override, the destination is DS:[BP], which is the memory location with 8-bit
displacement, hence mod = 01 with r/m = 110
8-bit Displacement = 43D = 2B H
Thus, the complete machine code becomes: 0011 1110 1000 1001 0100 1110 0010 1011(3E 89 4E 2B H)
Go to Tables 17
MOV CS:[BX],DH
d = 0, reg → r/m
w = 0 for 8-bit data operation.
Source: DH, reg = 110
Destination: CS: [BX]
Except the segment override, the destination is CS:[BX], which is the memory location with 0-
bit displacement, hence mod = 00 with r/m = 111
Thus the complete machine code becomes: 0010 1110 1000 1000 0011 0111 (2E 88 37 H)
Go to Tables 18
19