CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 129 users online: 9 members, 92 guests and 28 bots.
Members: 0rac343, alanclem, flyingfisch, Piguy-3.14, Ploppz, Roshiras.
Bots: VoilaBot (1), Spinn3r (1), Magpie Crawler (4), VoilaBot (1), Yahoo! Slurp (1), Googlebot (18), MSN/Bing (2).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
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 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 Assembly
Author Message
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 10 Jan 2012 10:46:07 am    Post subject:

Yes, what the 28 day tutorial says is very much wrong. The lower 8-bits are random, so you will need to overwrite 257 bytes (not 256). A simple way to achieve this is:

Code:

     ld hl,9900h
     ld d,h
     ld e,l
     ld (hl),98h
     inc de
     ld bc,256
     ldir
     ret

This means your interrupt must be placed at 9898h. I hope that works...
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 10 Jan 2012 11:17:43 am    Post subject:

Or something like this:

Code:
  ld bc,$0100 ;256
  ld a,$99
  ld h,a     ;hl=$99XX
  ld l,c     ;hl=$9900
  ld d,h     ;de=$99XX
  ld e,b     ;de=$9901
  ld i,a
  inc a      ;a=$9A
  ld (hl),a  ;byte to copy (load your interrupt to $9A9A)
  ldir       ;bc=256, repeat 256 times
Thank you again ThunderBolt for the correction :D

In your example, i think it'd be quicker just to "ld de,$9901".


Last edited by Guest on 11 Jan 2012 06:25:38 am; edited 1 time in total
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 10 Jan 2012 12:15:20 pm    Post subject:

Thank you!
Thats very sad that the whole byte is random, but i guess ill have to live with that Smile.

I've made a few adjustments, it still doen't work(the program executes, but nothing is displayer when enter is pressed), but ill try to figure it out(probably key input problem Very Happy):

Code:

.org    $9D93
.db    t2ByteTok, tAsmCmp
    LD HL, interrupt
    LD DE, $9A9A
    LD BC, interrupt_end + 4 - interrupt
    LDIR
 
    LD HL,$9900   
    LD DE,$9901   
    LD BC,256      
    LD (HL), $9A      
    LDIR

    DI
    LD A, $99
    LD I, A
    IM 2
    EI
    RET

interrupt:
    EX AF, AF'
    EXX

    LD A, $FF
    OUT (1), A

    LD A, $FD
    OUT (1), A
    NOP
    NOP
    IN A, (1)
    BIT 7, A
    JP NZ, $003A

    LD HL, $9AB4
    bcall(_PutS)
    JP $003A
interrupt_end:

msg: .DB "HEY", 0
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 10 Jan 2012 06:36:03 pm    Post subject:

Ah, try ld hl,$9AB6 (if I counted right) or just do ld hl,msg Smile
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 11 Jan 2012 02:43:40 am    Post subject:

Nope, the adress is right. I'm trying to figure out whats wrong, but i just cant find it.

BTW, i cant use msg because the program is orginally writen at $9D95, and when i move it the adress would be wrong. Thts why i calculated a new adress with:
msg - $9D95 + 4 +9A9A. I dont know why but i gave me a wrong adress anyway, so i used a direct one, $9AB4, which is correct
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 11 Jan 2012 04:34:37 am    Post subject:

You could also try "$9A9A + (msg - interrupt)".
Also, bit 7,z checks this bit:
X1111111, not 1111111X.

Try this out (this works for the + key)

Code:
#include "ti83plus.inc"
.org    $9D93
.db    t2ByteTok, tAsmCmp

    LD HL, interrupt
    LD DE, $9A9A
    LD BC, interrupt_end - interrupt
    LDIR
 
    LD HL,$9900
    LD DE,$9901
    LD BC,256
    LD (HL), $9A               
    LDIR

    DI
    LD A, $99
    LD I, A
    IM 2
    EI
    RET

interrupt:
    EX AF, AF'
    EXX

    LD A, $FF
    OUT (1), A

    LD A, $FD
    OUT (1), A
    NOP
    NOP
    IN A, (1)
    bit 1,a
    JP NZ, $003A
    LD HL, $9A9A+msg-interrupt
    bcall(_PutS)
    JP $003A
msg: .DB "HEY", 0
interrupt_end:


Last edited by Guest on 11 Jan 2012 04:38:36 am; edited 1 time in total
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 11 Jan 2012 05:43:00 am    Post subject:

Yeah i just noticed it. Acually its bit 0.
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 11 Jan 2012 06:23:55 am    Post subject:

Yeah, but if you use enter you will jump into the interrupt immediately after running the program (because you won't be able to release the key fast enough), so i changed it to bit 1, the [+] key. The code above works for me Smile
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 11 Jan 2012 06:58:22 am    Post subject:

Thank you so much for help!

It displays hey like 2-3 times when the key is pressed but it works Very Happy
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 11 Jan 2012 07:15:14 am    Post subject:

The reason for that is because the code is so fast (and the interrupt is run over a hundred times a second). You could have another variable in safeRAM which you store 1 to if + is pressed (and if that variable = 1, don't display hey) and set to 0 if it is not pressed. That way it'll only display once. Try holding down + and see what happens Wink

Last edited by Guest on 11 Jan 2012 07:17:48 am; edited 1 time in total
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 11 Jan 2012 08:55:49 am    Post subject:

Yeah, but then i'd have a problem with when to reset it, so that it can wait for the key to pressed again. Maybe there is a way to reset the port so that when you do IN (1), A you get FF? (There must be, because TI did it). Ill try to look through the code, but i can allready see that there is a lot of jumps, so its gonna take some while.
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 11 Jan 2012 01:43:42 pm    Post subject:

What I mean is something like this:

Code:
buttonPressed = saferam1+500
interrupt:
    EX AF, AF'
    EXX
   
    LD A, $FF
    OUT (1), A

    LD A, $FD
    OUT (1), A
    NOP
    NOP
    IN A, (1)
    bit 1,a
    LD A,0
    JR NZ,returnToOS         ;If + key is not pressed, we want buttonPressed to equal zero
    LD A,(buttonPressed)
    OR A
    JP NZ,$003A              ;If buttonPressed != 0, quit
    LD HL, $9A9A+msg-interrupt
    bcall(_PutS)
    LD A,1                   ;If + is pressed, load 1 into buttonPressed
returnToOS:
    ld (buttonPressed),a
    JP $003A
msg: .DB "HEY", 0
interrupt_end:

I haven't tested it out, but you could try something like that.
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 12 Jan 2012 02:04:49 am    Post subject:

Yeah, and the problem with this is that the message display will only be executed once, becuase you dont reset the flag. What i would do is to make a counter that count the executions of the interupt. For example:

1. I know that interrupts trigger every 1/140 of a sec. Therefore i can make a 1 byte counter at $9872.
2. If the counter equals to 0 and the + button is pressed- display
3. If the counter is less than 140, increment, don't display.
4. If the counter is 140 set it to 0.

I think this should work, but the best way to do this is to find a way to know if the key is held down or not. I saw once a port(i checked it, it is port 4, bit 3) where you could find a flag like this, but only for [ON] key.
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 12 Jan 2012 04:48:42 am    Post subject:

Please read through the code again carefully, in particular:

Code:
...
    IN A, (1)
    bit 1,a                  ;check value of a, set/reset the z flag
    LD A,0                   ;we use ld so we dont modify the z flag
    JR NZ,returnToOS         ;If + key is not pressed, we want buttonPressed to equal zero
    LD A,(buttonPressed)
    OR A
    JP NZ,$003A              ;If buttonPressed != 0, quit
    LD HL, $9A9A+msg-interrupt
    bcall(_PutS)
    LD A,1                   ;If + is pressed, load 1 into buttonPressed
returnToOS:
    ld (buttonPressed),a     ;if + key was pressed, a will equal 1 (because of the ld a,1 just above)
    ...                      ; if + key was NOT pressed, a will equal 0 (because we ld a,0 then jump to returnToOS if + is not pressed)
                             ; thus, buttonPressed will equal 1 until + is not pressed, in which case it will be reset to 0
I just tested it out and it works fine for me Smile

Last edited by Guest on 12 Jan 2012 04:49:44 am; edited 1 time in total
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 12 Jan 2012 12:49:27 pm    Post subject:

I apologize, i in fact didn't look through it carefully. For fun i wrote a similiar one before reading your code, and it works as well Smile Thanks
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 13 Jan 2012 06:15:37 am    Post subject:

Don't worry about it, and it's even better that you wrote your own code, congrats!
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 16 Jan 2012 04:12:27 am    Post subject:

Okay i've got a few more problems. Firstable i want to say that im not using TI-83, but TI-84.

When i loaded the interrupt program onto my calc, it didnt display anything.
And when i translated the code into OP- codes and typed it in hex form with AsmPrgm token the calc crashed.

So my first question is: Are there any diffrences between 83 and 84? By diffrences i mean diffrences in memory alocation, diffrent mechanisms and so on.

2. Why does the calculator crash when im typing the OP-codes directly? Im sure i didnt do any mistake with the numbers.
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 16 Jan 2012 09:59:36 am    Post subject:

Between the TI-83 there are some differences in the layout of the calc's memory (different saferam locations, programs are run from a different location in memory, etc.), but programs for the 83+ should in theory work fine on the 84+. What is the code you've compiled/are trying to load?
Back to top
jammasterz


Advanced Newbie


Joined: 28 Nov 2011
Posts: 72

Posted: 16 Jan 2012 10:39:37 am    Post subject:

The corrected version of this, which worked fine on the emulator.

Code:
#include "ti83plus.inc"
.org    $9D93
.db    t2ByteTok, tAsmCmp

    LD HL, interrupt
    LD DE, $9A9A
    LD BC, interrupt_end - interrupt
    LDIR
 
    LD HL,$9900
    LD DE,$9901
    LD BC,256
    LD (HL), $9A               
    LDIR

    DI
    LD A, $99
    LD I, A
    IM 2
    EI
    RET

interrupt:
    EX AF, AF'
    EXX

    LD A, $FF
    OUT (1), A

    LD A, $FD
    OUT (1), A
    NOP
    NOP
    IN A, (1)
    bit 1,a
    JP NZ, $003A
    LD HL, $9A9A+msg-interrupt
    bcall(_PutS)
    JP $003A
msg: .DB "HEY", 0
interrupt_end:
Back to top
asdf


Advanced Newbie


Joined: 17 Aug 2008
Posts: 73

Posted: 16 Jan 2012 03:08:54 pm    Post subject:

Hmm, i don't actually have a calc anymore to test it on, but i don't see what could cause any problems. Try adding a di at the start of your interrupt routine and an ei before jumping to $003A (though i assume _PutS disables interrupts...). You could also try loading your interrupt somewhere else, maybe saferam1, i dunno. Maybe ThunderBolt or someone else knows what's going on?
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
    » Goto page Previous  1, 2, 3, 4  Next
» View previous topic :: View next topic  
Page 3 of 4 » All times are GMT - 5 Hours

 

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.029114 seconds.