I am working on a program that will send the state of the keyboard through the link cable. I am getting a strange error, and I can't find anything about on the sites I have searched. I am getting ERR:BREAK when I run the program, which I have deduced happens when the program tries to run "b_call(_SendPacket)". The rest of the code works, and when I take out that single line, it does everything else it is supposed to, displaying the state of the keyboard as a string.
This is my first assembly program, so I only know what I have read on tutorials and forums (and the start and keyloop sections were copy/pasted from here). If anyone has any tips or pointers I would greatly appreciate them.
Code:
Also, quick FYI about this program, it is designed to run on a loop, which I have implemented in a separate TI-BASIC program for simplicity.
This is my first assembly program, so I only know what I have read on tutorials and forums (and the start and keyloop sections were copy/pasted from here). If anyone has any tips or pointers I would greatly appreciate them.
Code:
; Program Name: Key Dump
; Author(s): Willllllliam
; Description: Sends the current state of the keyboard through the link cable.
.nolist
#include "ti83plus.inc"
.list
.org userMem-2
.db $BB,$6D
start:
ld hl,$9872 ;the current state of the keyboard will be saved to these 7 bytes
ld bc,$0701 ;repeat 7 times
ld de,$FEFF ;d = $FE (%11111110, reads first bit), e = $FF (resets the keyboard)
keyloop:
out (c),e ;output $FF to port 1 to reset keyboard
out (c),d ;
rlc d ;shift d left one bit, now we have the next scan group byte in d
; i'm not sure if you'll need a longer delay here or not, you might need a couple filler instructions here
ini ;decs b and reads a byte from port c and stores it to (hl), then incs hl.
jp nz,keyloop
send:
ld hl, $9872
ld (iMathPtr5), hl ;address of data to be sent
ld hl, $7315
ld (header), hl ;start of packet 1 (Machine ID byte, Command ID byte)
ld hl, $0700
ld (header+2), hl ;start of packet 2 (Size)
b_call(_SendPacket)
ld hl, $9872
b_call(_PutS)
b_call(_NewLine)
ret
.end
.end
Also, quick FYI about this program, it is designed to run on a loop, which I have implemented in a separate TI-BASIC program for simplicity.