Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Ben24


Newbie


Joined: 28 Dec 2010
Posts: 16

Posted: 28 Dec 2010 11:49:44 pm    Post subject:

Hello,

I'm fairly new to ASM and have a few, quick, questions about the key port on the TI-83+. It is not through lack of information that these questions have arisen but rather a surplus. Everything that I have read seems to be in complete contradiction with what another guide or forum post suggests. :P

Question 1) What does sending $FF to the key port actually do?


  • "ASM In 28 Days" makes a brief reference to this in “Program 22-3” with a comment saying that it resets the key port.
  • "Phil's TI-83 Assembly Logs" says that it activates the port and that this is necessary before using _GetKey (I am assuming that this information is accurate and that it is something that only needs to be done on the Ti-83).
  • I also read a forum post a while back that said something along the lines of "Resets the key port... sort of".


Question 2) How much delay time is necessary between enabling a key group and reading from the key port? Where are delays necessary? Are there any times where there is no need for a delay? (eg. When you are just checking the same key group again and again in a loop?)


  • "Program 22-1" in "ASM In 28 Days" demonstrates the need for a delay for 2 NOPs (Although without NOPs the program runs fine in every emulator that I have tried it in. I am guessing this is because slow key port response time has little practical application).
  • "Program 22-2" in "ASM In 28 Days" does not use NOPs. This is what prompted the last question "Are there any times where there is no need for a delay?".


I would appreciate any help/tips/advice/links/etc. that could help me to understand this.

Thank you Smile
- Ben
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 29 Dec 2010 01:55:32 am    Post subject:

Ben24 wrote:

Question 1) What does sending $FF to the key port actually do?

Question 2) How much delay time is necessary between enabling a key group and reading from the key port? Where are delays necessary? Are there any times where there is no need for a delay? (eg. When you are just checking the same key group again and again in a loop?)

Writing the $FF basically makes that port forget its prior state. Normally, you would mask out all but one keygroup (group 0-6) and then read its respective keys. Without the prior $FF write, that data becomes a bit more arbitrary. I believe the last time I left out the $FF, keys from other groups started to have effect too.

The delay times are a bit of a mystery. This may have been a programming practice carried over from older chipsets where it was mandatory allow setup & hold time for those registers. These days, it seems you can say "nope" to NOPs with no ill effects. I've used VTI, WabbitEmu, and the real thing this way. On the plus side, a few idle NOPs (or even HALTs) in a key-checking loop will save some battery life.


Last edited by Guest on 29 Dec 2010 01:56:33 am; edited 1 time in total
Back to top
Ben24


Newbie


Joined: 28 Dec 2010
Posts: 16

Posted: 29 Dec 2010 05:24:25 am    Post subject:

Ah, fantastic. Thanks for all the information and the quick response.

The problem that you describe of keys from other groups having affect as well, sounds very similar to the one I referenced from "ASM in 28 Days". Source: http://pastebin.com/U4M5QHey
Apparently two NOPs between the OUT/INs solves the problem of the keys [x] and [->] also having effect. I wonder if $FF would fix the problem also?

I'm reluctant to do any testing with my actual calculator, just in case I bork it the day before an exam or something. Razz
I'll have to see if I can find a cheap second-hand one on eBay for testing.

Thanks again.
- Ben
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 29 Dec 2010 03:33:16 pm    Post subject:

Yeah, it's not a bad idea to wait or just emulate with VTI, PindurTI, or WabbitEmu. I'm not sure if it's possible to absolutely brick a TI-83+ from a code bug, but it's fairly easy to crash it to the point that pulling the battery has no immediate effect. There's a reset sequence to fix that, but it's kind of an unnecessary hassle for most.
Back to top
Xeda112358


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 20 Jan 2011 09:00:18 pm    Post subject:

Oh, since it is here, what exactly does a halt do? I've never really used it to any effect that I have noted, but I am pretty sure it has something to do with interrupts, right? ... or wrong?
Back to top
Ben24


Newbie


Joined: 28 Dec 2010
Posts: 16

Posted: 20 Jan 2011 09:35:07 pm    Post subject:

ThunderBolt wrote:

Oh, since it is here, what exactly does a halt do? I've never really used it to any effect that I have noted, but I am pretty sure it has something to do with interrupts, right? ... or wrong?


Yeh, from what I've read, it suspends CPU operation until an interrupt or reset occurs.
Back to top
Xeda112358


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 20 Jan 2011 11:05:16 pm    Post subject:

But what exactly does that mean?
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 21 Jan 2011 12:27:39 am    Post subject:

Yep. A HALT is similar to the IDLE or SLEEP commands seen in other processors. When operating normally, the processor will briefly break away from whatever it's running to execute a quick interrupt routine. This happens at regular intervals (~200 times per second), but it's over so quick most programs won't even notice.

Adding a HALT command will suspend most CPU activity until the next interrupt is over. It's a good way to save energy or slow things down when speed isn't necessarily a good thing.
Back to top
Xeda112358


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 21 Jan 2011 12:59:59 am    Post subject:

So if my code uses a halt during loops where it waiting for user input, it saves power? That would be mightly useful. And the FFh thing explains some things about my key routines Very Happy Thanks a bunch!
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement