Code:
call _AnsName
call _ChkFindSym
ret c
and $1f
cp StrngObj
ret nz
ex de, hl
ld c, (hl)
inc h
inc hl
ld de,OP1
ld a, 8
cp c
jr nc, $ + 4
ld c, 10 ; limit name length to 8
push hl
push de
push bc
call _ZeroOp1
pop bc
pop de
pop hl
ldir
ld hl,Password
ld de,OP2
ld b,5
call CompareStrings
jr z,YesPass
jr NoFail
CompareStrings:
ld a,(de)
cp (hl)
ret nz ;nz means they are not equal
inc hl
inc de
djnz CompareStrings
or a ;set the z flag, which means they are equal
ret
Password:
.db "1234567890",0
I'm trying to take a string stored in ans and compare it to a predetermined password. However, I'm getting an error and I don't know what is causing it. Most of the codes are copied from the forum so the codes may feel weird.
And does a password with all numbers cause it not to be a string?
1) use "inc hl" instead of "inc h"
2) where do you store the password? In OP1 or OP2?
3) what is BC when you "ldir"? You only set C
4) why do you compare only the first 5 numbers of the password?
5) "or a" doesn't return Z in general; use "xor a" instead
PT_ wrote:
1) use "inc hl" instead of "inc h"
2) where do you store the password? In OP1 or OP2?
3) what is BC when you "ldir"? You only set C.
2.
Original password is stored in this.
Password:.db "1234567890",0
Input password is a string stored in answer and str1. I stored it in both just to make life easier for me to test the program.
3.
I have no idea tbh.
Copied it from here. https://www.cemetech.net/forum/viewtopic.php?t=10287#sax
4.
I was desperate to find the issue so I cut it down to the first 5 numbers first.
5.
I just copied KermMartian's code ><
This code might be more useful:
Code:
call _AnsName
call _ChkFindSym
ret c
and $1f
cp StrngObj
ret nz
ex de, hl
ld c, (hl)
inc hl
ld b, 0
inc hl
ld de,OP1
ld a, 10
cp c
jr nc, $ + 4
ld c, 10 ; limit name length to 10
push hl
push de
push bc
call _ZeroOp1
pop bc
pop de
pop hl
ldir
ld hl,Password
ld de,OP1
ld b,5
call CompareStrings
jr z,YesPass
jr NoFail
CompareStrings:
ld a,(de)
cp (hl)
ret nz ;nz means they are not equal
inc hl
inc de
djnz CompareStrings
xor a ;set the z flag, which means they are equal
ret
Password:
.db "1234567890",0
PT_ wrote:
This code might be more useful:
Code:
call _AnsName
call _ChkFindSym
ret c
and $1f
cp StrngObj
ret nz
ex de, hl
ld c, (hl)
inc hl
ld b, 0
inc hl
ld de,OP1
ld a, 10
cp c
jr nc, $ + 4
ld c, 10 ; limit name length to 10
push hl
push de
push bc
call _ZeroOp1
pop bc
pop de
pop hl
ldir
ld hl,Password
ld de,OP1
ld b,5
call CompareStrings
jr z,YesPass
jr NoFail
CompareStrings:
ld a,(de)
cp (hl)
ret nz ;nz means they are not equal
inc hl
inc de
djnz CompareStrings
xor a ;set the z flag, which means they are equal
ret
Password:
.db "1234567890",0
Omg. Worked like a charm. Spend like 6 hours on this and havent solved it by myself.
Keep in mind that a string in Ans is tokenized. If you're hard-coding the password, it's easier to store the password in tokenized form, instead of trying to convert the tokens to a string. For a password that's all numbers and uppercase letters, the tokens are the same as ASCII, but other stuff won't be the same. For example, all lowercase letters are two-byte tokens.
Code: .nolist
#include "ti84pce.inc"
.org userMem-2
.db tExtTok,tAsm84CeCmp
.assume ADL=1
ld hl,tZ
call _Mov9ToOP1
call _ChkFindSym
jr c,Error
call nz,_Arc_Unarc
jp skip
Error:
call _homeup
call _ClrScrnFull
ld hl,ErrorText
call _PutS
call _GetKey
Skip:
call _HomeUp
call _ClrScrnFull
ret
ErrorText:
.db "Error",0
I want to unarchive Variable Z, however I can't seem to find the variable. What should I change?
Few more questions.
1. Which emulator should I use for coding for both TI84PCE and TI84PSE. Currently I'm testing on my own calculator ><
2. How do I clear RAM. And if possible clear RAM except for the program that is currently running.
3. Am I able to archive the ASM program that is currently running? If yes, where can I read more on it?
4. Where can I read/learn more about TempProgObj. E.g. Executing BASIC programs from archive/groups.
P.S. I've properly learned python. Some experience with C and C++ and dabbled with TIBASIC for the past 2 months. That's all the programming experience I've so please bear with me.
PCE: CEmu -- search Cemetech
CSE: Jstified -- Cemetech homepage >> Tools
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
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