first.asm

first.asm
;file:first.asm
;
;nasm -f coff first.asm
;gcc -o first.o driver.c asm_io.o
%include "asm_io.inc"
;
segment.data
prompt1 db "Enter a number: ",0
prompt2 db "Enter another number: ",0
outmsg1 db "You entered ",0
outmsg2 db " and ",0
outmsg3 db ", the sum of these is ",0
segment.bss
input1 resd 1
input2 resd 1
segment.text
global _asm_main
_asm_main:
enter 0,0
pusha
mov eax, prompt1
call print_string
call read_int
mov [input1], eax
mov eax, prompt2
call print_string
call read_int
mov [input2], eax
mov eax, [input1]
add eax, [input2]
mov ebx, eax
dump_regs 1
dump_mem 2, outmsg1, 1
mov eax, outmsg1
call print_string
mov eax, [input1]
call print_int
mov eax, outmsg2
call print_string
mov eax, [input2]
call print_int
mov eax, outmsg3
call print_string
mov eax, ebx
call print_int
call print_nl
popa
mov eax, 0
leave
ret
assembly base skeleton
skel.asm
%include"asm_io.inc"
segment.data
;
;초기화된 데이터는 여기 데이타 세그먼트에 들어간다.
;
segment.bss
;
;초기화 되지 않은 데이터는 여기 bss 세그먼트에 들어간다.
;
segment.text
global _asm_main
_asm_main:
enter 0,0 ;셋업 루틴
pusha
;
;코드는 텍스트 세그먼트에 들어간다. 이 주석 앞 뒤의 코드를 수정하지 마세요
;
popa
mov eax,0 ;C로 리턴된다.
leave
ret