Mniej więcej tak może być napisany program:
global _main
extern _printf
extern _scanf
section .data
format: db "%d", 0
format2: db "%s", 0
end_p: db "End Program", 0
high_meal: db "High Meal", 0xa, 0
medium_meal: db "Medium Meal", 0xa, 0
low_meal: db "Low Meal", 0xa, 0
section .text
_main:
loop1:
push xxx
push format
call _scanf
pop eax
pop eax
cmp dword [eax], 0
jl exit_of_program
cmp dword [eax], 750
jae high_c
cmp dword [eax], 750
jnl skip1
cmp dword [eax], 350
jae medium_c
cmp dword [eax], 350
jnl skip1
cmp dword [eax], 0
jae low_c
skip1:
jmp loop1
;push dword [eax]
;push format
;call _printf
;add esp, 8
ret
exit_of_program:
push end_p
push format2
call _printf
add esp, 8
ret
high_c:
push high_meal
push format2
call _printf
add esp, 8
jmp loop1
ret
medium_c:
push medium_meal
push format2
call _printf
add esp, 8
jmp loop1
ret
low_c:
push low_meal
push format2
call _printf
add esp, 8
jmp loop1
ret
section .bss
xxx: resb 1
Assembler Nasm, compiler gcc, linker chyba ld.
Kompilacja:
nasm -fwin32 scanf___1.asm && gcc scanf___1.obj && a