JACKY_ZZ[猫猫爱吃鱼]

春风拂面两颊红,秋叶洒地一片金。 夏荷摇曳一身轻,冬雪覆盖大地银。
posts - 30, comments - 123, trackbacks - 0, articles - 0

[ASM] 利用堆栈传递参数

Posted on 2014-12-18 17:10 jacky_zz 阅读(513) 评论(0)  编辑 收藏 引用 所属分类: ASM
; You may customize this and other start-up templates; 
; The location of 
this template is c:\emu8086\inc\0_com_template.txt

    org 100h
    jmp start

data:
    dw 
32 dup(0)
        
stack:
    dw 
256 dup(0)

start:
; add your code here    
    mov ax, cs
    mov ds, ax
    mov bx, data
    
    mov ss, ax
    mov sp, stack
+31
    
    push 
0x0001
    push 
0x0002
    push 
0x0003
    call test_proc
    
    hlt
    
test_proc:
    push bp
    mov bp, sp
    
    mov ax, [bp
+8]
    push ax
    call write_char
    
    mov ax, [bp
+6]
    push ax
    call write_char
    
    mov ax, [bp
+4]
    push ax
    call write_char
    
    pop bp
    ret 
6
    
write_char:
    push bp
    mov bp, sp
    
    mov ax, [bp
+4]
    mov dl, al
    add dl, 
0x30
    cmp dl, 
0x3a
    jl printit
    add dl, 
0x07
    
printit:
    mov ah, 
0x02
    
int 0x21
    pop bp
    ret 
2

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理