-2

I made an AsmProgram that runs this hex code:

9D95:00
9D96:00
9D97:00
9D98:00
9D99:0E
9D9A:09
9D9B:3E
9D9C:00
9D9D:EF
9D9E:5D
9D9F:49
9DA0:06
9DA1:80
9DA2:A8
9DA3:CB
9DA4:47
9DA5:CB
9DA6:0F
9DA7:CA
9DA8:95
9DA9:9D
9DAA:10
9DAB:F9
9DAC:C9

it's supposed to wait until the + button is pressed then end, but it doesn't seem to be working.

pi_squared
  • 91
  • 6
  • 1
    What is this hex dump supposed to do? It does not look like Z80 machine code. – Jongware Apr 09 '16 at 18:50
  • @RadLexus looks like
    : pairs. Don't remember `AsmPrgm` allowing addresses though.
    – Ilja Everilä Apr 09 '16 at 18:59
  • @Ilja: yes I realize that. But the code part of this hex dump does not look like Z80 code. Even if it is: are we supposed to disassemble this ourself, while the OP *has* the correct assembly somewhere? (Surely?) – Jongware Apr 09 '16 at 19:02
  • @RadLexus sorry for being patronizing. And yeah, it's ugly leaving the disassembly for the readers. – Ilja Everilä Apr 09 '16 at 19:05
  • i do not have the actual assembly code. i programmed it in hex. it should do something like 1:nop x 4 2:ld c,09 3:ld a,00 4:call(b_GetKey) 5:ld b,80 6:xor b 7:bit 0,a 8:rrc a 9:jp z,9D95 10:djnz -3 11:ret – pi_squared Apr 09 '16 at 19:10
  • Got the same through disassembly, except you've got the jp z, 9d95 messed up in the original, currently it's going to 959d. Little endianness. – Ilja Everilä Apr 09 '16 at 20:44
  • i changed it, and it does nothing different. it just runs and completes in a split second, ignoring any input. – pi_squared Apr 09 '16 at 20:52
  • Didn't say it'd work. Your key code checking is rather complex. – Ilja Everilä Apr 09 '16 at 20:56
  • You call DispTail. GetKey is 4972. Other than that, the code is plain weird. – harold Apr 09 '16 at 21:04

2 Answers2

5

This is your original code, as far as I can tell:

        .org 9D95h
        nop
        nop
        nop
        nop
        ld c, 09h       ; ???
        ld a, 0         ; ???
        rst 28h         ; \
        .db 5Dh         ;  > DispTail, destroys AF, BC, DE, HL, aka
        .db 49H         ; /  undefined behaviour in this case (we don't
                        ;    know what A contains)
        ld b, 80h       ; B <- 0x80
        xor b           ; A <- A XOR B
        bit 0, a        ; A[0] == 0, Z is set, if so
loop:   rrc a           ; rotate right A, C <- A[0]
        jp z, 9D95h     ; Jump to 9D95, if Z set
        djnz loop       ; Decrease B, jump if not zero to loop
        ret             ; After 128 jumps, returns

So all in all, they key code checking part was incorrect from the get go (calling the wrong ROM call and overly convoluted). Here's what seemed to work:

        .org 9D95h
        rst 28h         ; \
        .db 72h         ;  > Call GetKey, A <- key code
        .db 49h         ; /
        cp 80h          ; Compare A with immediate value 0x80 (subtract),
                        ; key code for [+] is 0x80
        jp nz, 9D95h    ; Jump if Z is not set (was not 0x80)
        ret             ; return

or in hex:

EF 72 49 FE 80 C2 95 9D C9
Ilja Everilä
  • 50,538
  • 7
  • 126
  • 127
  • i've been using a b_call chart that i guess is only meant for the ti-84 so getkey was replaced with disptail. where is a good b_call hex list for ti-83? – pi_squared Apr 09 '16 at 21:56
  • Found http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4972, though it's for the 83+. – Ilja Everilä Apr 09 '16 at 22:01
2

The program you wrote is essentially for the TI-83+/84+/SE model calculators. Your intended target was for the TI-83. There are three main things you need to change:

  • Start your code at .org $9327, not $9D95
  • There are no bcall()s just system calls. Instead of bcall(_GetCSC) you would do call _GetCSC
  • You need ti83asm.inc instead of ti83plus.inc

So with all that, let's make an example program:

.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h
start:
    call _GetKey ;CDFE4C
    cp 80h       ;FE80
    jr nz,start  ;20F9
    ret          ;C9

I've never programmed for the TI-83, so I hope from the tutorials I read that I pieced together working code.

Zeda
  • 382
  • 4
  • 13