Printing strings in LC-3 assembly language (super noob)

16.2k views Asked by At

Super noob here. I'm doing a "hello world" type program in LC-3 assembly language and I simply don't know how to print more than one string to the console. I need 4 strings on separate lines that are my class, name, project and goodbye. Right now all I can seem to print in the class.

       .ORIG x3000
LOOP   LEA R0, CLASS
       LD R1, NAME
       LD R2, PROJECT
       LD R3, GOODBYE
       PUTS
       HALT
CLASS .STRINGZ "CS101\n"
NAME  .STRINGZ "JOHN\n"
...
      .END

How would I get the other 3 to print? Thanks!

1

There are 1 answers

0
Jester On BEST ANSWER

The Z in .STRINGZ means zero terminated. That is you have declared separate strings. If you want to print them all, you need to invoke PUTS multiple times. Alternatively, make it a single string with embedded newlines. Then you can print the whole thing in one go.