0

I'm having problem with printing a message in pdp-11. The code is:

tks = 177560
tkb = 177562
tps = 177564
tpb = 177566

mask1:   .word 177600   
WELM:    .ascii<Welcome to Shir and Maya checkers game!>            

SOG:     mov #0,r2
     movb WELM(r2),r1; put the letters in r1 by order
     bic mask1,r1; clear high byte                                   
     tstb @#tps; while the printer is busy          
     bpl .-4;                                     
     mov r1,@#tpb; send to the printer                               
     inc r2; add 1 to r2                                             
     cmp #46,r2; untill end  of the string                           
     bge .-32;  repeat

The output is suppose to be the message: Welcome to Shir and Maya checkers game!

Instead we get the message: Welcome tol@r and Maya checkers game!

Which means that for some unknown reason the " Shir" got replaced with "l@r"

What should I do?

shirs
  • 1
  • 2
    Have you tried tracing it with a debugger? – David Wohlferd Jun 28 '18 at 00:15
  • 1
    Do you always get that same result? Are you sure your printer busy check is correct? Why are you using `.-4` and `.-32` and not labels? – lurker Jun 28 '18 at 01:16
  • I'm using .-4 and .-32 because this sub routine is part of a very long code and the amount of labels is limited. – shirs Jun 28 '18 at 10:29
  • I've checked the printer busy check. it's alright. the problem is that for some reason after printing 'o' I'm suppose to have the ascii code for space in r1(40 in octal which is 32 in decimal) but instead I've 154 which is the ascii code for 'l' in octal. Same thing happens until I reach the 'r' and than it's continue to print correctly – shirs Jun 28 '18 at 10:36
  • I think more importantly you're printing 3 characters in place of 5, which could mean you're attempting to send a character before the printer is ready, which is why I asked about that. You didn't answer my question about whether the unexpected results are consistent. Are they? do you always see "l@r" in place of " Shir"? Your `.-32` doesn't seem right to me. Isn' t the `inc r1` instruction only a single word (2 bytes)? And `movb WELM(r2),r1` doesn't seem that far away from your `bge .-32` instruction. Maybe you could show the assembly listing that has the opcodes. – lurker Jun 28 '18 at 11:12
  • Yes I always get the same results. – shirs Jun 28 '18 at 11:12
  • And you are right about the .-32. it's suppose to be .-30. I've already changed it in the code but forgot to change it here. It stiil didn't fix the problem. – shirs Jun 28 '18 at 11:15
  • I've found the problem. I had problem with the torg. Once I've raised it to 1500 instead of 1000, it start to print things correctly. My guess is that something ran over the tag and that was the problem – shirs Jun 28 '18 at 11:57
  • It's always a little disturbing to make a change and have something work but not understand why. It could be a problem waiting to happen again under different circumstances. I don't see a `torg` in your post. Might be worth further investigation. – lurker Jun 30 '18 at 12:01

0 Answers0