This code works for a very small amount of time after a keypress then spits what i assume is memory, why?

Code:

main:
 wait:
  call GetCSC
  or a, a
  jr z, wait
 cp a, 4
 jr z, up
 cp a, 3
 jr z, right
 cp a, 2
 jr z, left
 cp a, 1
 jr z, down
 cp a, 15
 jp nz, main
 ret
up:
 call ClrLCDFull
 call HomeUp
 ld hl, DispUp
 call PutS
right:
 call ClrLCDFull
 call HomeUp
 ld hl, DispRight
 call PutS
left:
 call ClrLCDFull
 call HomeUp
 ld hl, DispLeft
 call PutS
down:
 call ClrLCDFull
 call HomeUp
 ld hl, DispDown
 call PutS
DispUp:
 db "A" ,0
DispRight:
 db ">" ,0
DispLeft:
 db "<" ,0
DispDown:
 db "V" ,0

assembled with ez80 studio
the CE guy wrote:

Code:
up:
 call ClrLCDFull
 call HomeUp
 ld hl, DispUp
 call PutS
right:
 call ClrLCDFull
 call HomeUp
 ld hl, DispRight
 call PutS
left:
 call ClrLCDFull
 call HomeUp
 ld hl, DispLeft
 call PutS
down:
 call ClrLCDFull
 call HomeUp
 ld hl, DispDown
 call PutS
DispUp:
 db "A" ,0
DispRight:
 db ">" ,0
DispLeft:
 db "<" ,0
DispDown:
 db "V" ,0


Here is where I think the problem is. In each of the four branches, the OS returns from the call to PutS and executes the next branch. Then, the down branch starts executing data as code. I would put a ret block if you want to exit after that, or jr main if you want to continue the loop.
thx ill try that
Edit: it works perfectly
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement