; File: strout.asm ; Written By: Deepak Kumar ; Date: March 25, 2024 ; Purpuse: ; To show how to write your own version of LC-3's PUTS ; Given the address of a string in R0, output the string. ; The string has to be null terminated. ; ; The main program ; ; First, the string to be output .ORIG x3000 HELLO .STRINGZ "\nHello, world!\n" ; ; Next, the main program ; START LEA R0, HELLO JSR STROUT DONE HALT ; ; The PUTSTR subroutine ; STROUT ; Given the starting address of a string in R1 ; Output the string to console ; STROUT ST R1, SaveR1 ADD R1, R0, #0 ; Copy R1 into R0 (since R0 is used for char output) LOOP LDR R0, R1, #0 BRz STROUTDONE OUT ADD R1, R1, #1 BR LOOP STROUTDONE LD R1, SaveR1 RET SaveR1 .BLKW 1 .END