跟汇编携手到老!

在学习与实践中进步。
随笔 - 0, 文章 - 4, 评论 - 0, 引用 - 0
数据加载中……

我的第2个win32汇编程序

.386
.model flat, stdcall
option casemap : none
includelib msvcrt.lib

printf   PROTO C :dword, :vararg
scanf   PROTO C :dword, :vararg

.data
outputStart  byte   'input ten num', 0ah, 0
outputCount  byte   'input the %d num', 0ah, 0
input   byte   '%d', 0
outputResult byte   'the max num is %d', 0ah, 0
iArray   dword   5 dup (?) 

.code
start   proc
    mov    ebx,   offset iArray
    mov    ecx,   5
    xor    esi,   esi
startInput:                 
    invoke   printf,   offset outputCount, esi
    invoke   scanf,   offset input, ebx
    add    ebx,   4
    inc    esi
    cmp    esi,   5
    jnz    startInput
    
    mov    esi,   1
    mov    eax,   dword ptr iArray
    mov    ebx,   offset iArray
getMax:
    cmp    eax,   dword ptr [ebx + esi * 4]  
    jl    updateMax
    inc    esi
    cmp    esi,   5
    jz    output
    jmp    getMax
updateMax:  
    mov    eax,   dword ptr [ebx + esi * 4]
    inc    esi
    cmp    esi,   5
    jnz    getMax
output:
    invoke   printf,   offset outputResult, eax
    ret
start   endp
end    start  

posted on 2006-12-10 12:09 仰望宁静的星空! 阅读(122) 评论(0)  编辑 收藏 引用 所属分类: ASM

只有注册用户登录后才能发表评论。