汇编语言利用子程序的方法编程,把DATAS段里面的字符串倒叙输出到屏幕
题目:
利用子程序的方法编程,把DATAS段里面的字符串倒叙输出到屏幕
DATAS SEGMENT
db ‘welcome’
DATAS ENDS
方案一:
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov ax,STACKS
mov ss,ax
mov sp,20
mov cx,7
mov bx,6
call dao
MOV AH,4CH
INT 21H
dao:
mov dl,[bx]
mov ah,02
int 21h
dec bx
loop dao
ret
CODES ENDS
END START
方案二:
DATAS SEGMENT
str1 db 'welcome'
DATAS ENDS
STACKS SEGMENT
db 40 dup(0)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov ax,stacks
mov ss,ax
mov sp,40
mov bx,offset str1
add bx,6
mov cx,7
call convert
MOV AH,4CH
INT 21H
convert:
s: mov dx,[bx]
mov ah,02
int 21h
dec bx
loop s
ret
CODES ENDS
END START