I have a tios_crt0.s file, This is used for linking when compiling c code on the TI-84+ (non-ce). It goes like this:


Code:
; tios_crt0.s - TIOS assembly program header

   .module crt
   .globl _main
   .area _HEADER (ABS)
   .org #0x9D93

   .dw #0x6DBB
   
   call gsinit
   jp _main
   .org 0x9d9b ;9d9b
   .area _HOME
   .area _CODE
   .area _GSINIT
   .area _GSFINAL
   .area _DATA
   .area _BSEG
   .area _BSS
   .area _HEAP
   .area _CODE
   ;; Twice ???

__clock::
   ld a,#2
   ret ; needed somewhere...

   .area _GSINIT
gsinit::
   .area _GSFINAL
   ret

My issue is I'm trying to change it for compiling flash apps instead of asm programs. I found a form topic about a working header for making flash apps here but not sure how to combine them. This is the non-working file I have so far:

Code:


   .module crt
   .globl _main
   .area _HEADER (ABS)
   .org #0x4000

    .db 0x80, 0x0F, 0, 0, 0, 0
    ; Name. While this is a variable-length field (0x40 | length for the second byte),
    ; spasm requires that names always be 8 characters. See
    ; https://github.com/alberthdev/spasm-ng/issues/53
    .db 0x80, 0x48
    .ascii "nop     "
    ; Disable TI splash screen.
    .db 0x80, 0x90
    ; Pages
    .db 0x80, 0x81, 1
    ; Signing Key ID
    .db 0x80, 0x12, 1, 4 ; or 15 for the TI-84+CSE
    ; Date stamp.  Apparently, the calculator doesn't mind if you put
    ; nothing in this.
    .db 0x03220900
    ; Date stamp signature.  Since nothing ever checks this, there's no
    ; reason ever to update it.  Or even have data in it.
    .db 0x0200
    ; Final field
    .db 0x8070



   
   call gsinit
   jp _main

   .area _HOME
   .area _CODE
   .area _GSINIT
   .area _GSFINAL
   .area _DATA
   .area _BSEG
   .area _BSS
   .area _HEAP
   .area _CODE
   ;; Twice ???

__clock::
   ld a,#2
   ret ; needed somewhere...

   .area _GSINIT
gsinit::
   .area _GSFINAL
   ret

However, it crashes the emulator when I upload it and rabbitsign gives me these warnings:

Code:

rapp.bin: warning: application has an incorrect page count (actual: 2)
rapp.bin: warning: application has no date stamp
rapp.bin: warning: application has no program image field

If anybody can help me it would be greatly appreciated, I'm not too experienced with z80 asm and sdcc's z80 assembler is different in some ways from spasm. If it helps I'm using this

Code:
rabbitsign -t 8xk -g -f app.bin
to sign the app with this bin generated from sdcc that would normally be packed with binpac8x.
Got the rabbitsign errors to go away with this but the emulator still crashes:

Code:


   .module crt
   .globl _main
   .area _HEADER (ABS)
   .org #0x4000


   ; Master Field
   .db   0x80, 0x0F, 0, 0, 0, 0
   ; Name
   .db   0x80, 0x44
   .ascii "Test"
   ; Disable TI splash screen.
   .db   0x80, 0x90
   ; Pages
   .db   0x80, 0x81, 2
   ; Signing Key ID
   .db   0x80, 0x12, 1, 4
   ; Date stamp.  Nothing ever checks this, so you can put nothing in it.
   .db   0x03, 0x22, 0x09, 0x00
   ; Date stamp signature.  Since nothing ever checks this, there's no
   ; reason ever to update it.  Or even have data in it.
   .db   0x02, 00
   ; Final field
   .db   0x80, 0x70



   
   call gsinit
   jp _main

   .area _HOME
   .area _CODE
   .area _GSINIT
   .area _GSFINAL
   .area _DATA
   .area _BSEG
   .area _BSS
   .area _HEAP
   .area _CODE
   ;; Twice ???

__clock::
   ld a,#2
   ret ; needed somewhere...

   .area _GSINIT
gsinit::
   .area _GSFINAL
   ret

Update:
After investigation, it appears that there is ~50kb of null bytes in the .bin https://imgur.com/a/2GhkXrs
Here is my current broken crt

Code:


   .module crt
   .globl _main
   .area _HEADER (ABS)

.org 0x4000

   ; Master Field
   .db   0x80, 0x0F, 0, 0, 0, 0
   ; Name
   .db   0x80, 0x43
   .ascii "nop"
   ; Disable TI splash screen.
   .db   0x80, 0x90
   ; Pages
   .db   0x80, 0x81, 2
   ; Signing Key ID
   .db   0x80, 0x12, 1, 4
   ; Date stamp.  Nothing ever checks this, so you can put nothing in it.
   .db   0x03, 0x22, 0x09, 0x00
   ; Date stamp signature.  Since nothing ever checks this, there's no
   ; reason ever to update it.  Or even have data in it.
   .db   0x02, 00
   ; Final field
   .db   0x80, 0x70



   rst 0x28 ; bcall(_ForceFullScreen)
   .dw 0x508F
   rst 0x28 ; bcall(_ForceFullScreen)
   .dw 0x4540


   call gsinit
   jp _main

   .area _HOME
   .area _CODE
   .area _GSINIT
   .area _GSFINAL
   .area _DATA
   .area _BSEG
   .area _BSS
   .area _HEAP
   .area _CODE
   ;; Twice ???


__clock::
   ld a,#2
   ret ; needed somewhere...

   .area _GSINIT
gsinit::
   .area _GSFINAL
   ret

And here is my build script

Code:

export MAINC="main.c"
export OUT_NAME="rapp"


sdasz80 -p -g -o tios_crt0.rel ../../tios_crt0_app.s
sdcc -Ilibti --no-std-crt0 --code-loc 40347 --data-loc 0 --std-sdcc99 -mz80 --reserve-regs-iy -o $OUT_NAME.ihx tios_crt0.rel $MAINC


objcopy -Iihex -Obinary $OUT_NAME.ihx $OUT_NAME.bin


rm $OUT_NAME.lk $OUT_NAME.lst $OUT_NAME.map $OUT_NAME.noi $OUT_NAME.rel $OUT_NAME.sym tios_crt0.rel

../../rabbitsign -t 8xk -g -f rapp.bin
I suspect the --code-loc flag you're passing is wrong, since 40347 is 0x9D9B which seems like it refers to where RAM programs execute from. I think you'll want to set it to 0x4028, since your app header is 0x28 bytes and apps get loaded at 0x4000; that seems consistent with the original crt0 you shared in the first post, where the value for --code-loc matches the address of the header end.
Thanks that seems to work! Now I need to rewrite 75% of my functions to work with apps lol. If anybody else needs it the working build tools will be on my github with the crt0 in tios_crt0_app.s and the build script in templates/
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement