All pastes #579843 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-20 21:12 UTC
rendered paste body
%include "asm_io.inc"

segment .data

		prompt1 db		"Enter a number: ", 0 ; null terminator
		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 				; start up routine
		pusha

		mov	eax,prompt1
		call print_string		; see .inc file

		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

		;; the final end

		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				; return to c, letting it die
		leave
		ret