;; ;; Author: Bill Slough ;; ;; MAT 3670 ;; ;; Example assembly language program with a simple loop ;; ;; Displays a line of N asterisks, where N is a given value in memory. ;; .ORIG x3000 ; specify the "origin"; i.e., where to load in memory LD R1,N ; NOT R1,R1 ; ADD R1,R1,#1 ; R1 = -N AND R2,R2,#0 ; R2 = 0; LOOP ADD R3,R2,R1 ; while (R2 < N) BRzp ELOOP ; LD R0,STAR ; R0 = '*' OUT ; write('*') ADD R2,R2,#1 ; R2 = R2 + 1 BRnzp LOOP ; end while ELOOP LEA R0,NEWLN ; PUTS ; write('\n') STOP HALT ; N .FILL 6 ; how many characters to display? STAR .FILL x2A ; the character to display NEWLN .STRINGZ "\n" .END