简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM