Hey guys,
I'm having a problem with programming on my TI-84+ calculator.
In one of my programs, I'd like to display the current time. Although I though this wouldn't be a very big problem, I fount out that most the guides for assembly programming are written for the TI-83+, which does not keep track of time.
Although I did not check the entire ti83plus.inc file for any b_call I could use, I think it's highly unlikely there is one in there, since it is, as the name suggests, written for the TI-83 aswell.
I'm kinda hoping anyone of you could help me out.Smile
Greetings, Arriopolis.
Luckily, that's a very easy problem. The TI-84+/SE exposes the time via a series of ports; you do in a,($portnum) to get data from a port, and out ($portnum),a to push data into a port. You read the value of the clock via Port $45 and above. If you read the values of ports $45, $46, $47, and $48, those four byte together form a 32-bit value (in order, $48, $47, $46, $45, because the z80 is little-endian. This 32-bit number represents the number of seconds that have passed since 12:00am, January 1st, 1997.

Luckily, there are also some bcalls that will go through the trouble of turning that 32-bit integer into something more useable for display. _GetDate returns:
Code:
    OP1=Day of Month
    FPST=Day of Month
    FPS1=Month
    FPS2=Year
and _GetTime returns:
Code:
    OP1=Seconds
    FPST=Seconds
    FPS1=Minutes
    FPS2=Hours
Could you explain what FPS really means/does?
arriopolis wrote:
Could you explain what FPS really means/does?
Absolutely. While I do so, though, I very strongly recommend you grab these two documents from TI:

:: TI-83+ System Routines Reference
:: TI-83+ SDK Reference

The latter one in particular explains the Floating Point Stack very well. It's basically just like the word stack (the one you use when you push/pop hl, de, bc, af, ix, and iy). You can use PopRealO* to pop from the floating point stack into OP* memory (OP1 through OP6). For example:


Code:
bcall(_GetTime)
bcall(_PopOP2)
bcall(_PopOP3)
bcall(_PopOP4)


Will leave seconds in OP1, move seconds to OP2, move minutes to OP3, and move hours to OP4.
KermMartian wrote:


Code:
bcall(_GetTime)
bcall(_PopOP2)
bcall(_PopOP3)
bcall(_PopOP4)

Will leave seconds in OP1, move seconds to OP2, move minutes to OP3, and move hours to OP4.

So this will leave the total number of seconds after the 1st of january 1997 in OP1, and then the number of secs as part of a minute in OP2?
No. When you read manually from the ports using in a,($blah), then you are given the seconds since 1/1/1997. When you use _GetTime, it gives you the literal current hour, minute, and second that you would find on a regular clock, but it won't give you the seconds from 1/1/1997 anywhere.
KermMartian wrote:
Will leave seconds in OP1

Which seconds then?
arriopolis wrote:
KermMartian wrote:
Will leave seconds in OP1

Which seconds then?
The same seconds that are in OP2. Click on the GetTime link that I added to my post above; it shows the details about that particular BCall.
Two things:
Why don't you just do:

Code:
b_call(_getTime)
b_call(_PopOP1)
b_call(_PopOP2)
b_call(_PopOP3)

So now you have no results duplicated.
In the ti83plus.inc file, I only found _PopOP1, _PopOP3 and _PopOP5, and so did I in the link you sent me. Does this mean you can only use OP3 and OP5 to store the values, or are there other routines, built-in in the dcs_sdk compiler... somehow?

Oh, wait...
I see, you can use _PushRealO*, 'cause you're sure that it's a real number. Thanks for your help!
Sorry, that was confusion on my part. You're probably better off repeatedly pop'ing into OP1, then displaying that, anyway. Also, a point of etiquette if you don't mind - please edit your posts instead of double-posting if it's been less than twelve to twenty-four hours since your last post.
So I could:

Code:

bcall    $514F
ld  h,0
ld l,op1
bcall    disphl

To display the date? Question
No, that makes no sense whatsoever. Op1 is a 2-byte number, namely an address, that points to an 11-byte RAM area. L is a one-byte register. Even if you did ld hl,op1 \ bcall(_disphl), that would display the decimal representation of the address of Op1, not the 11-byte contents formatted as a floating-point number. There is a bcall called _dispop1a that will display up to A digits of Op1, so that might be useful to you here.
  
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