main.asm-1

    multi-model program
main4.asm
%include "asm_io.inc"
segment .data
sum dd 0
segment .bss
input resd 1
segment .text
global _asm_main
extern get_int,print_sum
_ams_main:
enter 0,0 ;
pusha
mov edx,1 ;edx i .
while_loop:
push edx
push dword input ;
call get_int
add esp,8 ;i &input
mov eax,[input]
cmp eax,0
je end_while
add [sum].eax
inc edx
jmp short while_loop
end_while:
push dword [sum]
call print_sum
pop ecx
popa
leave
ret
sub4.asm
%include "ams_io.inc"
segment .data
prompt db ")Enter an integer number (0 to quit): ",0
segment .text
global get_int,print_sum
get_int:
enter 0,0
mov eax,[ebp+12]
call print_int
mov eax,prompt
call print_string
call read_int
mov ebx,[ebp+8]
mov [ebx],eax
leave
ret
segment .data
result db "The sum is ",0
segment .text
print_sum:
enter 0,0
mov eax,[ebp+8]
call print_int
call print_nl
leave
ret