Hey, I'm new here and I need a bit of help with the LC-3 Assembly language. Basically I need to write a program which takes a string and only displays the uppercase characters in it. So for example, I give it the string "This is a Sample String", it prints out "TSS". I've been trying to get it working for 2 days now and I can't seem to figure it out. I came up with this:

.ORIG x3000

;Lowercase: 97-122
;Uppercase: 65-90

LD R3, UPPER            ; load uppercase bitmask
LEA R1, STRING            ; pointer into string

LOAD LDR R0, R1, #0        ; get char
    BRz END            ; x00 means end of string
    AND R2, R0, R3        ; test for uppercase w/ mask
    BRz NEXT        ; not uppercase, get next
    OUT            ; output character
    NEXT ADD R1, R1, #1    ; pointer++
BRnzp LOAD            ; go get next char

UPPER .FILL b0000000000100000    ; bit 6 determines upper/lower case
STRING .STRINGZ "This is a Sample String"


But it instead prints out lowercase characters.... The only hint my professor gave was that the upper/lower bit mask (b0000000000100000) would help us. I really want to get this working, I just can't seem to figure out what I did wrong. Thanks for any help! :)

> BRz NEXT ; not uppercase, get next
So try 'not zero' branch then

lower case characters have bit 6 set (not clear)

Thanks so much, that worked perfectly! I've been hitting my head against a wall for 2 days trying to get this thing to work to find out it was a tiny (well, not so "tiny") mistake I made. :$ Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.