学习win32汇编2

Posted on 2006-12-22 13:11  doraemon1983  阅读(122)  评论(0)    收藏  举报
 1.386
 2.model flat, stdcall
 3option casemap : none
 4includelib msvcrt.lib
 5
 6printf   PROTO C :dword, :vararg
 7scanf   PROTO C :dword, :vararg
 8
 9.data
10outputStart  byte   'input ten num', 0ah, 0
11outputCount  byte   'input the %d num', 0ah, 0
12input   byte   '%d'0
13outputResult byte   'the max num is %d', 0ah, 0
14iArray   dword   5 dup (?) 
15
16.code
17start   proc
18    mov    ebx,   offset iArray
19    mov    ecx,   5
20    xor    esi,   esi
21startInput:                 
22    invoke   printf,   offset outputCount, esi
23    invoke   scanf,   offset input, ebx
24    add    ebx,   4
25    inc    esi
26    cmp    esi,   5
27    jnz    startInput
28    
29    mov    esi,   1
30    mov    eax,   dword ptr iArray
31    mov    ebx,   offset iArray
32getMax:
33    cmp    eax,   dword ptr [ebx + esi * 4]  
34    jl    updateMax
35    inc    esi
36    cmp    esi,   5
37    jz    output
38    jmp    getMax
39updateMax:  
40    mov    eax,   dword ptr [ebx + esi * 4]
41    inc    esi
42    cmp    esi,   5
43    jnz    getMax
44output:
45    invoke   printf,   offset outputResult, eax
46    ret
47start   endp
48end    start
49

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3