tags:

views:

205

answers:

2

Every time I assemble an application for the TI-83+ calculator (Z80 processor), it stops running at CALL. Here is an example ("Hello") — it starts running just fine, but the calculator freezes at the CALL instruction. Anything I put before CALL works just fine, and anything I put after doesn't run. This is a disassembly of the code, to show addresses rather than labels. I have "touched it up" to show DB lines where those fall in, to make it easier to read.

I have never had this problem writing assembly "programs" (which are loaded into RAM). The only problems that I know of with running "applications" (which are kept in Flash ROM) are that they cannot be self-modifying, and that because paging is necessary, accessing data on a separate page is not possible. This is not self-modifying and only has one page... What have I done wrong?

0080 218900        LD   HL, 0089h
0083 cd9900        CALL 0099h        ;                      --- App stops here
0086 c38f00        JP   008fh
0089 48656c6c6f00  DB   "Hello", 0
008f fd360500      LD   (IY+05h), 0
0093 ef            RST  28h          ; B_CALL (
0094 364c          DB   4C36h        ;   _ReloadAppEntryVecs)
0096 ef            RST  28h          ; B_CALL (
0097 2740          DB   4027h        ;   _JForceCmdNoChar)  --- App should end here
0099 7e            LD   A, (HL)      ;                      --- Call goes to here
009a ef            RST  28h          ; B_CALL (
009b 0445          DB   4504h        ;   _PutC)
009d fe00          CP   0
009f c8            RET  Z
00a0 23            INC  HL
00a1 18f6          JR   0099h
+3  A: 

Apparently, you are assembling to address 0080h. This can't be correct because the address range 0000h--3FFFh is locked to ROM page 0. Indeed, according to this example, you assemble to 4000h. So your problem is that your CALL is jumping into the firmware, not a part of your application.

Cirno de Bergerac
Yeah, that was a dumb moment. I threw in 'ORG 4000h' and now it works. I've got another problem now though... Nothing I 'PutC' is going to the screen — probably a moronic mistake. Jeez — the first freaking language I ever programmed in was 8080 assembler, and now it's been so long my assembly code looks like it was written by a chimpanzee.
c4757p
Ok. Problem solved. Yep, the PutC problem as a moronic mistake as well. Thank you.
c4757p
+1  A: 

Here's a memory map I found for the Ti-83+. You can't be loading this program at address $0080, that's where ROM lives. It gets loaded elsewhere. That works for a while until you make a JP or CALL. The CALL $0099 doesn't jump to your expected jump address, it jumps into ROM. That's a quick end.

You need to choose a proper ORG directive in your .asm so it gets loaded into RAM at the expected address. Wherever that might be.

Hans Passant