//用push指令将A段中的前8个字节数据,逆序存储到B段中,注意数据不是DW,而是DB
assume cs:code
a segment
db 1,2,3,4,5,6,7,8,0ah,0bh,0ch,0dh,0eh,0fh,0ffh
a ends
b segment
db 0,0,0,0,0,0,0,0
b ends
code segment
start:mov ax,a
mov ds,ax
mov ax,b
mov ss,ax
mov sp,8
mov bx,0
mov cx,8
s:mov dl,ds:[bx]
push dl
inc bx
loop s
mov ax,4c00h
int 21h
code ends
end start
//这是我自己写的代码,可是有错误,需要怎么改哦?
------解决方案--------------------------------------------------------
push和pop的数据类型应该是字。
程序如下:
assume cs:code,DS:A,SS:B
a segment
db 1,2,3,4,5,6,7,8,0ah,0bh,0ch,0dh,0eh,0fh,0ffh
CN EQU $
a ends
b segment
dw 0,0,0,0,0,0,0,0 ;16个字节,8个字节不够用
b ends
code segment
start:mov ax,a
mov ds,ax
mov ax,b
mov ss,ax
mov sp,16 堆栈深度为16字节
mov bx,0
mov cx,8
s:mov dx,WORD PTR ds:[bx]
XCHG DH,DL
push dx
inc bx
INC BX
loop s
mov ax,4c00h
int 21h
code ends
end start