指令 | AX | BX | CX | 解析 |
---|---|---|---|---|
mov,ax,62627 | F4A3H | 62627十六进制表示 | ||
mov ah,31H | 31A3H | 覆盖高8位 | ||
mov al,23H | 3123H | 覆盖低8位 | ||
add ax,ax | 6246H | |||
mov, bx,826CH | 6246H | 826CH | ||
mov cx,ax | 6246H | 826CH | 6246H | |
mov ax,bx | 826CH | 826CH | 6246H | |
add ax,bx | 04D8H | 826CH | 6246H | ax bx值相等,相当于ax乘以2即ax左移一位最高位溢出 826C= 1000 0010 0110 1100,左移一位即0000 0100 1101 1000=04DBH |
mov al,bh | 0482H | 826CH | 6246H | bx高8位覆盖ax低8位 |
mov ah,bl | 6C82H | 826CH | 6246H | |
add ah,ah | D882H | 826CH | 6246H | ah高8位乘以2,即高8位左移一位 |
add al,6 | D888H | 826CH | 6246H | |
add al,al | D810H | 826CH | 6246H | 低8位左移一位,最高位不会覆盖高8位 |
mov ax,cx | 6246H | 826CH | 6246H |
mov ax,2
add ax,ax
add ax,ax
add ax,ax
指令 | AX | BX | DS | 解析 |
---|---|---|---|---|
mov ax,1 | 1H | 0H | ||
mov ds,ax | 1H | 0H | 1H | |
mov ax,[0000] | 2662H | 0H | 1H | 找内存单元10000H(16),ax是16位的,即2662H(内存中左边是低位) |
mov bx,[0001] | 2662H | E626H | 1H | |
mov ax,bx | E626H | E626H | 1H | |
mov ax,[0000] | 2662H | E626H | 1H | |
mov bx,[0002] | 2662H | D6E6H | 1H | |
add ax,bx | FD48H | D6E6H | 1H | |
add ax,[0004] | 2C14H | D6E6H | 1H | |
mov ax,0 | 0H | D6E6H | 1H | |
mov al,[0002] | 00E6H | D6E6H | 1H | |
mov bx,0 | 00E6H | 0H | 1H | |
mov bl,[000c] | 00E6H | 0026H | 1H | |
add al,bl | 000CH | 0026H | 1H |
指令 | AX | BX | DS | CS | IP | 解析 |
---|---|---|---|---|---|---|
mov ax,6622H | 6622H | 0 | 1000H | 1000H | 3H | |
jmp 0ff0H,0100 | 6622H | 0 | 1000H | 0FF0H | 0100H | 下一条指令为0FF0*16+0100=FF00H+0100H=20000H |
mov ax,2000H | 2000H | 0 | 1000H | 1000H | 0003H | |
mox ds,ax | 2000H | 0 | 2000H | 1000H | 0005H | |
mox ax,[0008] | C389H | 0 | 2000H | 1000H | 0005H | 把20008H的数据给ax,先复制给al然后ah |
mox ax,[0002] | EA66H | 0 | 2000H | 1000H | 0008H | |
mox bx,ax | EA66H | EA66H | 2000H | 1000H | 0008H |
mov ax,2000H
mov ss,ax
mov sp,0010H
mov ax,1000H
mov ss,ax
mov sp,0
(1) 向内存0:200H~0:23F依次传送数据0到 63(3FH)
```
assume cs:code
code segment
mov ax,0
mov ds,ax
mov bx,200H
mov cx,40H
s: mov [bx],ax
inc ax
inc bx
loop s
mov ax,4c00H
int 21h
code ends
end
···
然后调试一下 遇到loop时候按p可以跳过循环,最后结果如下:
(2) 向内存0:200H~0:23FH依次传送数据0到 63(3FH)只能使用9条指令,包括 mov ax,4c00h和int 21h
根据5.8一节开头讲述0:200H~0:23FH等同于20:0000H ~ 20:003FH。因此可得:
```
assume cs:code
code segment
mov ax,20H
mov ds,ax
mov bx,0H
mov cx,40H
s: mov [bx],bl
inc bx
loop s
mov ax,4c00H
int 21h
code ends
end
```
结果:
(3)第一个空显然是cs,因为代码段。第二个空是估计代码长度,不知道。先随便填一个空,然后debug。
看到代码长度为17H,十进制就是23.因此最后代码是:
assume cs:code
code segment
mov ax,cs
mov ds,ax
mov ax,0020H
mov es,ax
mov bx,0
mov cx,17H
s: mov al,[bx]
mov es:[bx],al
inc bx
loop s
mov ax,4c00H
int 21h
code ends
end
(1)
assume cs:codesg
codesg segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0976h
start:
mov ax,0
mov ds,ax
mov bx,0
mov cx,8
s:
mov ax,[bx]
mov cs:[bx],ax
add bx,2
loop s
mov ax,4c00h
int 21h
codesg ends
end start
assume cs:codesg
codesg segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0976h
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
start:
mov ax,cs
mov ss,ax
mov sp,36H
mov ax,0
mov ds,ax
mov bx,0
mov cx,8
s: push [bx]
pop cs:[bx]
add bx,2
loop s
mov ax,4c00h
int 21h
codesg ends
end start
(1) ① data段数据不变
② 程序运行前 cs=0773,ss=076F,ds=0760
运行后 cs=0773,ss=0771(回到原位),ds=0770(回到原位)
③ data x-2 stack x-1 (原因见书上92页)
(2)① 不变 ② cs=0773,ss=0771,ds=0770③data x-2 stack x-1