(1)
assume cs:code,ds:data,ss:stack
data segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,data
mov ds,ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
1.数据不变
2.ss 076b ds 076a cs 076c
3.x-2 x-1
(2)assume cs:code,ds:data,ss:stack
4.(N+15)/16*16
(3)
1.不变
2.cs = 076a ss = 076e ds = 076d
3.x+3 x+4
(4)
不指明程序入口,第(3)个程序仍然可以正确执行。
(5)
编写code段中的代码,将a段和b段中的数据依次相加,将结果保存到c段中。
assume cs:code
a segment
db 1,2,3,4,5,6,7,8
a ends
b segment
db 1,2,3,4,5,6,7,8
b ends
c segment
db 0,0,0,0,0,0,0,0
c ends
code segment
start:
mov ax,a
mov ds,ax
mov si,0
mov di,20h
mov cx,8
s: mov al,ds:[si]
add al,ds:[si + 10h]
mov ds:[di],al
inc si
inc di
loop s
mov ax,4c00h
int 21h
code ends
end start
(6)
编写code段中的代码,用push指令将a段中的前8个字型数据,逆序存储到b段中。
assume cs:code
a segment
dw 1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffh
a ends
b segment
dw 0,0,0,0,0,0,0,0
b ends
code segment
start:
mov ax,b
mov ss,ax
mov sp,10h
mov ax,a
mov ds,ax
mov di,0
mov cx,8
s: push ds:[di]
add di,2
loop s
mov ax,4c00h
int 21h
code ends
end start
push指令
sp = sp -2