注册 登录
编程论坛 汇编论坛

莱鸟求助!数据逆序问题!

论坛 发布于 2006-05-23 14:59, 1009 次点击

下面是将定义的数据逆序,不但出现警告,而且还没有实现逆序,哥哥帮帮我

assume cs:code

code segment

dw 123h, 234h, 345h, 456h, 567h, 678h, 789h, 89h
dw 0, 0, 0, 0, 0, 0, 0, 0

start: mov ax, cs
mov ss, ax
mov sp, 32

mov bx, 0
mov cx, 8
s1: push, cs:[bx]
add bx, 2
loop s1

mov bx, 0
mov cx, 8
s2: pop cs:[bx]
add bx, 2
loop s2

mov ax, 4c00h
int 21h

code ends

end start



4 回复
#2
公子吕2006-05-23 15:15

.model small
.data
befor dw 123h, 234h, 345h, 456h, 567h, 678h, 789h, 89h
after dw 0, 0, 0, 0, 0, 0, 0, 0
.code
_start:
mov ax,@data
mov ds,ax ;初始化段地址
mov si,offset after-2 ;before最后一个字的地址
mov di,offset after ;after第一个字的地址
mov cx,8 ;loop循环次数
again: ;开始循环
mov ax,ptr word [si] ;
mov ptr word [di],ax ;befor最后面的数送after最前面
sub si,2 ;befor地址减一个字,即从最后依次向前一个字
add di,2 ;after依次向后一个字
loop again
mov ah,4ch ;exit
in 21h
end _start
end

[此贴子已经被作者于2006-5-23 16:03:36编辑过]

#3
论坛2006-05-23 15:21
,看不懂啊,我刚学
#4
公子吕2006-05-23 16:04

注释了。

#5
abd665432006-05-27 21:44
呵呵,可以利用堆栈来弄逆序嘛。
1