CSC231 Homework 6 2012

From dftwiki3
Revision as of 12:48, 10 October 2012 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- =Problem #1= Make a copy of this program in your directory and run it. Verify that it prints 10 numbers, starting at 0, and stopping at 9 (included). <br /> <sour...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 13:48, 10 October 2012 (EDT)


Problem #1

Make a copy of this program in your directory and run it. Verify that it prints 10 numbers, starting at 0, and stopping at 9 (included).

;;; loopExample.asm
;;;a simple demo program to show how to implement a counting loop
;;;Uses the driver.c program as a C "wrapper" 
	
		%include "asm_io.inc"

             ;; -------------------------
             ;; data segment
             ;; -------------------------
             section .data
count        dd	0

             ;; -------------------------
             ;; code area
             ;; -------------------------
             section .text
             global  asm_main
asm_main:       
	     
	     mov	ecx, 10			; get ready to loop 10 times
for:	     mov	eax, dword[count]	; load counter
	     call	print_int		; print it
             call    	print_nl		; new line

	     inc	dword[count] 		; increment counter
	     loop	for			; keep looping until done

             ;; return to C program

             ret