CSC231 Crash Course Solution 3
--D. Thiebaut 15:09, 4 March 2011 (EST)
;;; prog3.asm
;;; D. Thiebaut
;;; solution for Exercise #3
;;;
;;; Assemble, link and run as follows:
;;; nasm -f elf asm_io.asm (do this only once)
;;; nasm -f elf prog3.asm
;;; gcc -o prog3 driver.c prog3.o asm_io.o
;;; ./prog3
;;;
%include "asm_io.inc"
%assign SYS_EXIT 1
;; -------------------------
;; data segment
;; -------------------------
section .data
a dd 3
b dd 5
c dd 8
d dd 10
e dd 20
result dd 0
;; -------------------------
;; code area
;; -------------------------
section .text
global asm_main
asm_main:
mov eax,[a]
add eax,[b]
add eax,[c]
add eax,[d]
add eax,[e]
mov [result],eax
mov eax,[result] ; pass result to print_int
call print_int ; and print value
call print_nl ; call the function that prints
; a new blank line
;; return to C program
ret