Re-jigging your code with addresses (and some comments) makes it a little easier to figure out potential problems:
0000 LDWA 0xFFFF, i ; set A to -1, why?
0003 DECO 0xFFFF, i ; decimal output -1
0006 LDBA 0xFC15, d ; get input character
0009 STWA 0x001D, d ; store to variable
000c STBA 0xFC16, d ; output character
000f LDWA 0x001D, d ; get character back
0012 SUBA 0x001F, d ; presumably subtract 0x20
0015 ORA 0x0021, d ; not sure what this intends
0018 STBA 0xFC16, d
001b STOP ; 1-byte operation
001c .BLOCK 2 ; two arbitrary bytes.
001e .WORD 20 ; takes two bytes 0x0014
0020 .WORD 0x0020 ; 0x0020
.END
Based on that, you appear to have used the wrong addresses for direct storage and retrieval, possibly because you think STOP
is a two-byte operation but I can't be sure.
Going forward, you should be able to get rid of superfluous code and ensure you only uppercase lowercase letters by only acting on the range (inclusive) a..z
. Something like this would be a good start:
asc_a: .equate 0x0061 ; Lower case A.
asc_z: .equate 0x007a ; Lower case Z.
sub_val: .equate 0x0020 ; Difference from upper to lower.
in_char: .equate 0xfc15 ; Address to get char from user.
out_char: .equate 0xfc16 ; Address to put char to user.
main: deco 0xffff,i ; Decimal output -1.
ldba in_char,d ; Get input character.
cpwa asc_a,i ; If outside a..z, do not translate.
brlt no_xlat
cpwa asc_z,i
brgt no_xlat
suba sub_val,i ; Convert to upper (61..7a -> 41..5a).
no_xlat: stba out_char,d ; Output character.
stop
You'll see there that we don't actually need data storage since we can just use immediate operands for constants and the accumulator for the character itself.
If you do need data storage, I would tend to place it at a fixed location so that code changes do not affect it, something like:
0000 start: br main
0003 some_data: .block 0x20
0023 more_data: .word 0xdead
0026 more_data: .word 0xbeef
0029 main: <<Code goes here>>
That way, no changes to the code affect your variables, something that will be quite handy if you have to hand-code your stuff rather than relying on a decent assembler that can work out the symbols automatically.