• Advertisement
Sign in to follow this  

LC-3 Assembly problem

This topic is 2019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am trying to create a game in assembly just for fun.

[color=#FF0000]EDIT: Please read my second post, it simplifies my question a lot.

In the game you have an inventory and some items. Must the game is actually finished already, and each subroutine works. However, I am having problems printing to the screen.

I have printed to the screen before but it was a pain.

I’m trying to create a function (subroutine) to display the binary content of R0 to the console. So I want it to print 1 or 0 for each bit; which will mean something in the game. I start in R0[15]…R0[0] end there.


PRINT
ST R7, PRS7
ST R3, PRS3
;AND R3, R3, #0
LD R3, MASK

LOOP
AND R0, R0, R3
BRp CHECK
CHECK ADD R0, R0, #1
TRAP x21
BRnzp DOWN
ELSE AND R0, R0, #0
TRAP x21
DOWN
LD R3, PRS3
LD R7, PRS7
PRS7 .BLKW 1
PRS3 .BLKW 1
MASK .FILL x8000 ; Mask x8000


There has to be an easy way to do this. Please help. Edited by Cuajin

Share this post


Link to post
Share on other sites
Advertisement
I haven't done assembly since the Z80 and 486, so I can't be of much help. But kudos to your craziness. I recall the run of machine crashes I had just making a Paint-like app in assembly.

Share this post


Link to post
Share on other sites
biggrin.png
I think I found a big problem. I can print now, but not 0s.

.ORIG x3000

LD R2, data5 ; Load the ASCII code
AND R0, R2, #0
TRAP x21

data5 .FILL x0030 ; ASCII code x30



I can use the same code and print a 1, or any number, but 0 (zero) just does not print.

For sure R0 = 0

R2 = ASCII code x0030

My output looks like this: 111111

It should look like: 1011011

It is actually 2 bits shorter which means that the 0s are being ignored.

Please help Edited by Cuajin

Share this post


Link to post
Share on other sites
Is it that you're using AND instead of add? It's hard for me to read because I haven't worked with it before, but I think that (or something like that) is resulting in a character 0 instead of a character 48, and character 0 is non-printable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement