Re: LZ: variables
[Prev][Next][Index][Thread]
Will Stokes (3D Diamond productions) wrote:
>
> wstokes@vertex.ucls.uchicago.edu
> http://www.uic.edu/~hhstokes/index.html
> Will Stokes
> to all of the people out there who responded to my earlier
> question, thankyou, I got one of the solutions to work. Now I have a
> rather simple questions having to do with keystrokes: here's my code:
>
> Top:
> CALL_(Get) ;in the basic stem of program
> ; 'Get' is called
>
> Get: ;a subrotine i made
> call GET_KEY ;get the last keystoke
> cp $37 ; was exit presses
> ret z ; if so exit to zshell menu
> cp $02 ; was left arrow pressed
> CALL_(Left) ; ok run 'Left'
> cp $03 ; was right pressed
> CALL_(Right) ; ok run 'Right'
> JUMP_(Top) ; go back to 'Top'
> Left:
> dec a ;a=a-1
> cp 0 ;compare a to zero
> jr z, L2 ; if zerso jumpto 'L2'
> ret ; if not it will return to 'Get'
> L2:
> ld a, 9 ; a=9
> ret
> Right:
> inc a
> cp 10
> jr z, R2
> ret
> R2:
> ld a, 1
> ret
> -----------------------------------------------------------
> the exit to zshell part works but the left and right commands don't for
> some reason, is there somthing visible here that I'm doing wrong????
As many people have said, you must CALL_Z instead of CALL_. Another thing is that it's not so
clever to JUMP_(Top). After a while the stack will get overflowed (= the calc will probably
crash). You must RET back to the top.
<pre>
--
----------------------------------------------------------------------------
| Real name: Jimmy Mårdell | "The concept of God it makes no sense |
| Email....: <mja@algonet.se> | An out-of-life experience |
| IRC-name.: Yarin | Free at last to do what I please |
| WWW......: - | In heaven there are no TVs" - Cat rapes Dog |
|----------------------------------------------------------------------------|
| "I'm the operator with my pocket calculator" - Kraftwerk |
----------------------------------------------------------------------------
</pre>
References: