You would do something like this:

Code:
Loop:
 ld hl,Number
 [.......code.........]
 ld (hl),a ;assuming character that you want to store is in a
 inc hl ;increase hl by 1
 jp Loop
IRC wrote:
<TechNOM76> HOWEVER, if I pull the battery during running, and turn it back on, it goes to the homescreen.
<TechNOM76> Instead of the program (Using Start-Up app).
<AHelper2> But for times that it isn't running (if it is in the background)
<AHelper2> right, there is a way to catch it once you pull the battery


If anybody knows how to do this, it would be useful for my program here. I was told that BrandonW knew, but apparently he hasn't been around for a while. Sad
All you need to do is recalculate the RAM checksum, and there's a flag you need to continually set, if I can recall correctly. I'll have to look for the specifics for your tomorrow.
KermMartian wrote:
All you need to do is recalculate the RAM checksum, and there's a flag you need to continually set, if I can recall correctly. I'll have to look for the specifics for your tomorrow.

That can be done with _GetKey, correct? I want it to do more than simply not clear the RAM after a battery pull; I want it to not bypass the security after a battery pull.

Basically, turning it on normally will work fine, but when I pull a battery, re-insert it, and turn it on, the security mechanism (running the program) is bypassed, and it goes to the homescreen. If I just bypassed it but then turn it off and back on, the security mechanism returns.
_GetKey is really not a good thing to use; it has tons of bad side effects, like allowing the calculator to be shut off in the middle of your program. I don't think that _GetKey will do it for you automatically; you almost definitely need to manually recalculate the checksum and set the flag in question. I'd recommend at least GetCSC for your key-code-getting, if not direct input.
KermMartian wrote:
_GetKey is really not a good thing to use; it has tons of bad side effects, like allowing the calculator to be shut off in the middle of your program. I don't think that _GetKey will do it for you automatically; you almost definitely need to manually recalculate the checksum and set the flag in question. I'd recommend at least GetCSC for your key-code-getting, if not direct input.


  1. What's bad about shutdown during program execution?
  2. What are we discussing at this moment? I'm saying _GetKey prevents a RAM clear, but will allow security to be bypassed. Are they different flags or something?
  3. If so, what flag(s) should I be setting and where?
Shutdown in a program isn't good, because the copy of the program at $9D95 isn't removed. It would be better if you could shut it down manually, by turning off the LCD and enabling interrupts.
Exactly. It leaves the memory in a terribly broken state, especially if you're running from a shell. You should handle shutdown yourself, as Souvik said, so that when the calculator turns back on, it's still in your program (and as far as your security goes, still waiting for a password). The thing it doesn't solve is a battery-pull.
Okay, so I would like to convert my program (still at http://pastebin.com/gCeHucx2), to use _GetCSC and still avoid RAM clears. Any ideas on how to execute this plan?
I would still like to incorporate the Error: label, which has been messing me up.
technomonkey76 wrote:
Okay, so I would like to convert my program (still at http://pastebin.com/gCeHucx2), to use _GetCSC and still avoid RAM clears. Any ideas on how to execute this plan?
We can easily make your program turn on and off and still be in your program. We can (slightly less) easily make your program prevent RAM from being cleared if a battery pull occurs. If I recall correctly, though, combining the two to make your program continue running when the calculator powers on after a battery pull is a very hard problem.
KermMartian wrote:
technomonkey76 wrote:
Okay, so I would like to convert my program (still at http://pastebin.com/gCeHucx2), to use _GetCSC and still avoid RAM clears. Any ideas on how to execute this plan?
We can easily make your program turn on and off and still be in your program. We can (slightly less) easily make your program prevent RAM from being cleared if a battery pull occurs. If I recall correctly, though, combining the two to make your program continue running when the calculator powers on after a battery pull is a very hard problem.

To be 100% honest, I don't care if it resumes from where it stopped when the battery was pulled. I just need it to power off if the code is incorrect and prevent the RAM clear. It doesn't need to continue execution from where it was interrupted.
Okay... so: new question:
I want to make it so that line 19 in http://pastebin.com/DQtU2fiS works. I know I need to convert hl into a usable number for call. I heard I could use a "jumptable" for this, but I have absolutely no idea what this is. Sad Can anybody help me so I can use call here?
You could use SMC:

Code:

;HL is the address you want to call
[....code.....]
 ld a,l
 ld (CALL_HL+1),a
 ld a,h
 ld (CALL_HL+2),a ;The address is put into little-endian
CALL_HL:
 call $0000

Code:
 ld de,$+3+1+1
 push de
 jp (hl)
;that $+N line points here
An even easier way, that doesn't require SMC or another register:


Code:
; snip

    ld hl,destination
    call call_hl

; snip

call_hl:
    jp (hl)
Yup, benryves' solution is probably the best alternative. Technomonkey, you should be using a table for your labels anyway, though, not storing them in hl like that, for the sake of sanity.
KermMartian wrote:
Yup, benryves' solution is probably the best alternative. Technomonkey, you should be using a table for your labels anyway, though, not storing them in hl like that, for the sake of sanity.

Can somebody please explain the table, then?
Here is info on jump tables: http://en.wikipedia.org/wiki/Jump_table
might help.
KermMartian wrote:
_GetKey is really not a good thing to use; it has tons of bad side effects, like allowing the calculator to be shut off in the middle of your program. I don't think that _GetKey will do it for you automatically; you almost definitely need to manually recalculate the checksum and set the flag in question. I'd recommend at least GetCSC for your key-code-getting, if not direct input.


Isn't there a _GetKeyRetOff for that? Or are there problems with it too?
So... I've managed to get it SOMEWHAT working, but it won't let me through, no matter what. Help?
http://pastebin.com/Y4pEzGgp
Also, note: Old links are dead.
  
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 3 of 5
» 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