Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 90 users online: 4 members, 50 guests and 36 bots. Members: Kaslai, lboe, mr.depontes@gmail.com. Bots: VoilaBot (1), Spinn3r (2), Magpie Crawler (4), VoilaBot (10), Googlebot (18), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
toraora
Newbie

Joined: 07 Jan 2011 Posts: 15 Location: USA
|
Posted: 08 Jan 2011 11:10:52 pm Post subject: Using Calculator Variables |
|
|
Hi all,
I'm wondering how to access the calculator variables (A, B, C, L1, L2, Str1, etc.) in ASM. I tried going through the 28 days tutorial but it doesn't quite make sense to me.
Thanks |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55729 Location: Earth, Sol, Milky Way
|
Posted: 08 Jan 2011 11:16:12 pm Post subject: Re: Using Calculator Variables |
|
|
| toraora wrote: | Hi all,
I'm wondering how to access the calculator variables (A, B, C, L1, L2, Str1, etc.) in ASM. I tried going through the 28 days tutorial but it doesn't quite make sense to me.
Thanks | Edit: When in doubt, read this document:
http://education.ti.com/downloads/guidebooks/sdk/83p/83psysroutines.pdf
Older post: Allow me to present this probably quite poor code from Doors CS 4:
Code: ;+---------------------------------------------+
;| Set BASIC Variables Routines |
;+---------------------------------------------+
;| Thanks to Tutorial 25 of ASMGuru for this! |
;+---------------------------------------------+
SETVAR_X:
call SETVAR_INIT
ld hl,'X'
ld (OP1+1),hl
jp _STOOTHER
SETVAR_Y:
call SETVAR_INIT
ld hl,'Y'
ld (OP1+1),hl
jp _STOOTHER
SETVAR_A:
call SETVAR_INIT
ld hl,'A'
ld (OP1+1),hl
jp _STOOTHER
SETVAR_N:
call SETVAR_INIT
ld hl,'N'
ld (OP1+1),hl
jp _STOOTHER
SETVAR_N_hl:
call _SetXXXXOp2
call _Op2ToOp1
call _PUSHREALO1
call _ZEROOP1
ld hl,'N'
ld (OP1+1),hl
jp _STOOTHER
SETVAR_INIT:
ld (op1),a
call _Setxxop1
call _PUSHREALO1
call _ZEROOP1
ret
;+---------------------------------------------+
;| Get BASIC Variables Routines |
;+---------------------------------------------+
;| Thanks to Tutorial 25 of ASMGuru for this! |
;+---------------------------------------------+
GET_A:
call _zerooop1
ld hl,op1+1
ld (hl),'A' ;or any other var
jp GETVAR
GET_X:
call _zerooop1
ld hl,op1+1
ld (hl),'X' ;or any other var
jp GETVAR
GET_Y:
call _zerooop1
ld hl,op1+1
ld (hl),'Y' ;or any other var
jp GETVAR
GET_N:
call _zerooop1
ld hl,op1+1
ld (hl),'N' ;or any other var
GETVAR:
call _rclvarsym ;op1 / op2 -> value
call _convop1
ld a,e ;previously ld a,hl
ret Note that this is TI-83 ASM. For TI-83+ ASM, all the call _routines need to be bcall(_routine)s. _________________
 |
|
| Back to top |
|
|
Deep Thought

Expert

Joined: 11 Mar 2010 Posts: 739 Location: The Universe
|
Posted: 08 Jan 2011 11:32:50 pm Post subject: |
|
|
Quick tutorial for RAM vars (they're easier):
Just like anything else in memory, you access calculator variables with a pointer, which means you'd need to know where it is first. The TI-OS includes two b_calls that find variables for you: FindSym and ChkFindSym. The first one is faster but can only find variables that aren't programs, appvars, or groups. If you want to find a variable that's one of those, you'll have to use ChkFindSym.
Either way, you first have to load the name of the program into the nine-byte area called OP1 (so the routine knows what to look for). The easiest way is to store the name as data in the program:
Code:
ProgName:
.db ProgObj, "NAME", 0
Then when you actually call the routine, load the label into HL, call Mov9ToOp1 (with rst 20h), and call the appropriate finding routine:
Code:
LD HL, ProgName
RST 20h
b_call(ChkFindSym)
If it finds the variable, the carry is reset:
Code:
JR c, ProgNotFound
If it's in RAM, B will be 0:
Code:
LD A, B
OR A
JR nz, ProgInArc
DE now points to the two size bytes of the variable, which come before the data. If you want to make DE point to the start of the actual data, add two:
Code:
INC DE
INC DE
This will also work with any other variable type.
Hope that clears some stuff up. _________________
  |
|
| Back to top |
|
|
toraora
Newbie

Joined: 07 Jan 2011 Posts: 15 Location: USA
|
Posted: 08 Jan 2011 11:40:27 pm Post subject: |
|
|
So, if I wanted to find a list LIST, I would have the following code:
Code:
ListName:
.db ListObj, "LIST", 0
LD HL, ListName
RST 20h
b_call(_FindSym)
and if I wanted to read from list LIST, then i would start from DE + 2 in RAM.
Correct? |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55729 Location: Earth, Sol, Milky Way
|
Posted: 09 Jan 2011 12:19:28 am Post subject: |
|
|
List are found with ChkFindSym, not FindSym. Also, you don't inline .dbs, unless you weren't. Convention is to put data like that at the end of your program. Otherwise, correct. _________________
 |
|
| Back to top |
|
|
Deep Thought

Expert

Joined: 11 Mar 2010 Posts: 739 Location: The Universe
|
Posted: 09 Jan 2011 12:39:51 am Post subject: |
|
|
What Kerm said. Always put your data at the end of the program (after the RET). Otherwise it'll get run as a sequence of commands, since they're the same thing. _________________
  |
|
| Back to top |
|
|
toraora
Newbie

Joined: 07 Jan 2011 Posts: 15 Location: USA
|
Posted: 09 Jan 2011 12:48:34 am Post subject: |
|
|
So I am trying to code a calculator lock that utilizes list LIST, which contains the key values. Here is the code I have (doesn't work):
Code:
.NOLIST
#include "ti83plus.inc"
.LIST
.ORG 9d93h
.DB t2ByteTok, tAsmCmp
FindList:
LD HL, ListName
RST 20h
b_call(_ChkFindSym)
LD H, D
LD L, E
LD (ListLoc), HL
LD B, (HL)
LD L, B
LD (ListLeng), HL
LD C, 0
Start:
INC C
LD A, C
LD HL, (ListLeng)
CP L
JR Z, End
PUSH BC
GetKeyCode:
b_call(_GetCSC)
CP 0
JR Z, GetKeyCode
POP BC
PUSH AF
LD HL, (ListLoc)+2
LD B, C
Loop:
INC HL
DJNZ Loop
LD B, (HL)
POP AF
CP B
JR Z, Start
LD C, 0
JR Start
End:
RET
.end
.end
ListName:
.DB ListObj, "LIST", 0
ListLoc:
.DW 0
ListLeng:
.DB 0
This indirection is making me dizzy... |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 09 Jan 2011 12:51:00 am Post subject: |
|
|
| Deep Thought wrote: | | Otherwise it'll get run as a sequence of commands, since they're the same thing. |
Uh, no. It will only get run if the programmer forgets to jump around the data. IMO, randomly scattering data around your program isn't good, but it won't crash your calc if you are careful.  _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
Deep Thought

Expert

Joined: 11 Mar 2010 Posts: 739 Location: The Universe
|
Posted: 09 Jan 2011 12:51:53 am Post subject: |
|
|
Numbers in lists are stored as 9-byte floating points (tutorial here). _________________
  |
|
| Back to top |
|
|
toraora
Newbie

Joined: 07 Jan 2011 Posts: 15 Location: USA
|
Posted: 09 Jan 2011 12:55:17 am Post subject: |
|
|
Oh yeah. I forgot >.<
Still, when I run the debugger, ListLoc points at apparently nowhere in particular.
EDIT: after hours of debugging, i finished the program. |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55729 Location: Earth, Sol, Milky Way
|
Posted: 10 Jan 2011 01:35:52 am Post subject: |
|
|
| toraora wrote: | Oh yeah. I forgot >.<
Still, when I run the debugger, ListLoc points at apparently nowhere in particular.
EDIT: after hours of debugging, i finished the program. | That's great to hear, congrats! Perhaps you'll consider uploading it to the Cemetech archives, once you decide it's complete? _________________
 |
|
| Back to top |
|
|
|
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
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.037166 seconds.
|