I am a beginner in assembly programming and I experience some issues with this problem. So the addresses of the commands below are defined by the contents of CS:IP
registers . If CS
is equal to 0750h and IP
is 047Bh find all the addresses of the commands. It's given that all the commands have a size of 3 bytes.
I have found that address is equal to segment * 10h + offset. That means 0750h * 10h + 047Bh = 797Bh. After that in order to find the address of each command I just add 3 to 797Bh? Am I right?
start:
mov ax, data
mov ds, ax
mov al,3Fh
mov ah,30h
cmp al,ah
jl p1
add ah,al
sub ah,30h
p1:
add al,ah
sub al,30h
mov ax, 4c00h
int 21h
ends
It's given that all the commands have a size of 3 bytes
This is certainly false. Look below to find out.
CS:IP = 0750h:047Bh
corresponds to linear address 0000797Bh.
0000797B mov ax, data 3 bytes : opc + word immediate
0000797E mov ds, ax 2 bytes : opc + modr/m
00007980 mov al, 3Fh 2 bytes : opc + byte immediate
00007982 mov ah, 30h 2 bytes : opc + byte immediate
00007984 cmp al, ah 2 bytes : opc + modr/m
00007986 jl p1 2 bytes : opc + byte displacement
00007988 add ah, al 2 bytes : opc + modr/m
0000798A sub ah, 30h 3 bytes : opc + modr/m + byte immediate
p1:
0000798D add al, ah 2 bytes : opc + modr/m
0000798F sub al, 30h 2 bytes : opc + byte immediate
00007991 mov ax, 4c00h 3 bytes : opc + word immediate
00007994 int 21h 2 bytes : opc + byte immediate