关于汇编的传递参数的练习
;Code by FBI;2010-12-25
assume cs:code
data segment
i_int1 dw 12eh,12666,1,8,3,38,0a0dh
dw 12eh,345,41,84,34,38,0a0dh
dw 12eh,12346,1,86,36,38,0a0dh
dw 12eh,666,145,8,33eh,38,0a0dh
i_int2 dw 1234,567,10249,877,0ffffh
temp db 100 dup(0)
data ends
stack segment
dw 60 dup(0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,100
push es
mov ax,0
push ax
mov ax,data
mov ds,ax
mov ax,offset i_int1
push ax
mov ax,offset temp
push ax
call d_to_num
add sp,4
call cls
push ds
pop es
mov di,offset temp
call display
mov dx,offset temp
mov ah,09h
int 21h
retf
;cls
cls PROC
push cx
push ds
mov cx,320
mov ax,0b800h
mov ds,ax
mov bx,1600
mov ax,09f20h
s: mov ,ax
inc bx
inc bx
loop s
pop ds
pop cx
ret
cls ENDP
;display
display proc
push ds
push ax
push si
mov ax,0b800h
mov ds,ax
mov bx,1600
mov si,0
xor ax,ax
_s: mov al,es:
cmp ax,0dh
jz _t
_ttt: mov ds:,al
inc si
inc si
inc di
cmp ax,0
jz _end
jmp _s
_end: pop si
pop ax
pop ds
ret
_t: inc di
mov al,es:
cmp ax,0ah
jz _tt
dec di
mov al,0dh
jmp _ttt
_tt: inc di
add bx,160
mov si,0
jmp _s
display endp
;dtonum ds:di,ds:si
d_to_num proc
mov bp,sp
push bp
push di
push si
push cx
;取地址
mov di,
mov si,
;开始转换
d_s: mov ax,ds:
cmp ax,0ffffh
jz d_end
cmp ax,0a0dh
jz d_enter
d_a: ;mov bx,ax
mov cx,05
mov bx,10
d_ss: xor dx,dx
div bx
add dl,30h
push dx
loop d_ss
mov cx,05h
d_sss: pop dx
mov ds:,dl
inc di
loop d_sss
mov byte ptr ds:,20h
inc di
inc si
inc si
jmp d_s
d_end: mov byte ptr ds:,0h
inc di
mov byte ptr ds:,24h
pop cx
pop si
pop bx
pop bp
ret
d_enter:mov byte ptr ds:,0dh
inc di
mov byte ptr ds:,0ah
inc di
inc si
inc si
jmp d_s
d_to_num endp
code ends
end start
页:
[1]