简体   繁体   中英

My input code for LC-3 isn't working as intended

I've been working on this bit of code to take a string of input and to have it displayed after I hit the enter key, but it doesn't work for some reason and I can't figure out where I'm going wrong at all. I would love some help to figure this one out.

      LD  R1, RT
      LEA R2, ARRAY
INPUT GETC           ;read the input character 
      OUT            ;echoes the character
      ADD R3, R0, R1
      BRz ENDINPUT
      STR R0, R2, #0
      ADD R2, R2, #1
      BR  INPUT
ENDINPUT
      STR R3, R2, #0
      LEA R0, ARRAY         ;outputs the string of characters
      PUTS

Late response, but in case it's still haunting you, hope these help!

  • Check that the value in location RT is correct. If you are checking for a 'LF' when you hit 'Enter', R2 should have the value of negative 'LF'. In 2s-complement this is 0xFFFFFFF0 .

  • Make sure your ARRAY is large enough to hold your inputs. Check your .BLKW line – I'm assuming you didn't post these lines in your post.

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