I am working on a shell program (in asm), when I ran it on wabbitemu, it crashed. Can anyone help me debug it? I am using asm8x to compile it.


Code:
#include "ti83plus.inc"

.org $9D95
.db $BB,$6D

BCALL_(_clrLCDFull)
BCALL_(_getKey)

    cp kUp
    jp z,Up
    cp kDown
    jp z,Down

Up:
BCALL_(_FindAlphaUp)
   
Down:
BCALL_(_FindAlphaDn)

Thanks
You don't return anywhere, and you also don't initialize HL before those two bcalls, so what you actually need is:


Code:
#include "ti83plus.inc"

.org $9D93
.db $BB,$6D

BCALL_(_clrLCDFull)
BCALL_(_getKey)

    cp kUp
    jr z,Up
    cp kDown
    jr z,Down
    [jp, jr, or ret so it doesn't go into Up]
Up:
    [set up HL]
    BCALL_(_FindAlphaUp)
    [jp, jr, or ret so it doesn't go into Down]
Down:
    [set up HL]
    BCALL_(_FindAlphaDn)
    [jp, jr, or ret so it doesn't go into random memory]

Code:
#include "ti83plus.inc"

.org $9D95
.db $BB,$6D
...
    cp kUp
    jp z,Up
...
Up:
    BCALL_(_FindAlphaUp)

That'll break things nicely as well. Your origin should be $9D93, which wouldn't be a problem, but you're using jp (absolute jump), so the addresses are off by two. End result: you jump to a byte of data- recipe for disaster.
The Tari wrote:

Code:
#include "ti83plus.inc"

.org $9D95
.db $BB,$6D
...
    cp kUp
    jp z,Up
...
Up:
    BCALL_(_FindAlphaUp)

That'll break things nicely as well. Your origin should be $9D93, which wouldn't be a problem, but you're using jp (absolute jump), so the addresses are off by two. End result: you jump to a byte of data- recipe for disaster.


We have discussed that before, so far for all code I have done in assembly (using wabbitemu rom version:1.12) $9D95 has worked. I'm not sure if it is because of the rom version, or what. People have said that part, and from now on if I say $9D95, I will be testing both. You are the first I think to have said anything about jp vs jr.
Take my word on this...it may appear to work correctly, but when you start referencing labels or absolute addresses, it won't work correctly until you make it $9D93.

The reason why is because when the OS runs your program, it doesn't copy the $BB $6D bytes to userMem ($9D95), so you have to account for that by offsetting your .org address by 2. Every OS/ROM ever has loaded assembly programs that same way.
  
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