⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main4.asm

📁 关于linux环境下的nasm代码的生成和使用
💻 ASM
字号:
;; file: main4.asm; Multi-module subprogram example program;; To create executable:; Using djgpp:; nasm -f coff sub4.asm; nasm -f coff main4.asm; gcc -o sub4 sub4.o main4.o driver.c asm_io.o;; Using Borland C/C++; nasm -f obj sub4.asm; nasm -f obj main4.asm; bcc32 sub4.obj main4.asm driver.c asm_io.obj%include "asm_io.inc"segment .datasum     dd   0segment .bssinput   resd 1 ;; psuedo-code algorithm; i = 1;; sum = 0;; while( get_int(i, &input), input != 0 ) {;   sum += input;;   i++;; }; print_sum(num);segment .text        global  asm_main        extern  get_int, print_sumasm_main:        enter   0,0               ; setup routine        pusha        mov     edx, 1            ; edx is 'i' in pseudo-codewhile_loop:        push    edx               ; save i on stack        push    dword input       ; push address on input on stack        call    get_int        add     esp, 8            ; remove i and &input from stack        mov     eax, [input]        cmp     eax, 0        je      end_while        add     [sum], eax        ; sum += input        inc     edx        jmp     short while_loopend_while:        push    dword [sum]       ; push value of sum onto stack        call    print_sum        pop     ecx               ; remove [sum] from stack        popa        leave                             ret

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -