Terminal program for MailStation devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Build: Automatically calculate data-loc

The segments in crt0 are not doing what I thought they were, and I
think to actually put things for the whole project in the particular
order in the final binary, I need a custom linker script which I
don't really want to deal with.

I would rather just put the data right after the code segments since
it's all in the same RAM page anyway, which would result in smaller
files being sent over the parallel interface each time, but this at
least gets things building and running reliably with data put as
high into the 16k page as possible.

+23 -19
+12 -6
Makefile
··· 17 17 # 18 18 19 19 ASZ80?= sdasz80 -l -ff 20 - SDCC?= sdcc -mz80 20 + SDCC?= sdcc -mz80 --opt-code-size 21 21 22 22 SRCDIR?= ${.CURDIR} 23 23 ··· 39 39 # added to $BASE_ADDR, must be far enough to hold _HEADER code in crt0 40 40 CODE_OFF= 0x100 41 41 42 - ADDRS_INC= ${SRCDIR}/addrs-${LOC}.inc 42 + # subtracted from the end of the flash/ram page to hold data 43 + DATA_SIZE= 4800 44 + 43 45 44 46 all: msterm.bin 45 47 ··· 47 49 rm -f *.{map,bin,ihx,lst,rel,sym,lk,noi} 48 50 49 51 # assembly 52 + 53 + ADDRS_INC= ${SRCDIR}/addrs-${LOC}.inc 50 54 51 55 crt0.rel: crt0.s 52 56 $(ASZ80) -o ${.TARGET} ${ADDRS_INC} $> ··· 90 94 msterm.ihx: crt0.rel isr.rel putchar.rel getchar.rel lpt.rel modem.rel \ 91 95 msterm.rel mslib.rel csi.rel settings.rel 92 96 $(SDCC) --no-std-crt0 \ 93 - --code-loc `perl -e 'print ${BASE_ADDR} + ${CODE_OFF}'` \ 94 - --data-loc 0x0000 -o ${.TARGET} $> 97 + --code-loc `ruby -e 'print ${BASE_ADDR} + ${CODE_OFF}'` \ 98 + --data-loc `ruby -e 'print ${BASE_ADDR} + 0x4000 - ${DATA_SIZE}'` \ 99 + -o ${.TARGET} $> 95 100 96 101 msterm.bin: msterm.ihx 97 102 objcopy -Iihex -Obinary $> $@ 98 103 @if [ `stat -f '%z' ${.TARGET}` -gt 16384 ]; then \ 99 - echo "${.TARGET} overflows a dataflash page, must be <= 16384"; \ 104 + ls -l ${.TARGET}; \ 105 + echo "${.TARGET} overflows a ${LOC} page, must be <= 16384; increase DATA_SIZE"; \ 100 106 exit 1; \ 101 107 fi 102 108 103 109 disasm: msterm.bin 104 - z80dasm -al -g 0x4000 $> > msterm.dasm 110 + z80dasm -al -g ${BASE_ADDR} $> > msterm.dasm 105 111 106 112 upload: all 107 113 sudo ../../mailstation-tools/obj/sendload -p 0x4000 msterm.bin
+7 -9
crt0.s
··· 102 102 xor a 103 103 out (#0x0d), a ; put the cpu in its highest speed 104 104 105 + ; all of our code expects to run in ram so when we're running from 106 + ; dataflash, we have to copy our page of flash into ram, then jump to 107 + ; it 108 + 105 109 ; swap in a page of ram 106 110 ld a, #DEVICE_RAM 107 111 out (#SLOT_DEVICE), a ··· 128 132 call _main ; main c code 129 133 jp _exit 130 134 131 - ; ordering of segments for the linker 132 - .area _HOME 135 + .area _DATA 133 136 134 - .area _CODE 137 + _msTERM_version:: 138 + .db #VERSION 135 139 136 140 ; variables 137 141 .area _BSS ··· 146 150 .db #0 147 151 _debug4:: 148 152 .db #0 149 - _msTERM_version:: 150 - .db #VERSION 151 - 152 - .area _DATA 153 - 154 - .area _HEAP 155 153 156 154 .area _CODE 157 155
+3 -3
isr.s
··· 23 23 .include "mailstation.inc" 24 24 .globl _modem_isr 25 25 26 - .area _CODE 26 + .equ isrjump, #0xf7 27 + .equ isrjumptable, #0xf800 27 28 28 29 ; we're going to put 0xf7 at 0xf800 - 0xf8ff and then put 0xf8 in the 29 30 ; 'i' register. when an interrupt happens in interrupt mode 2, some ··· 32 33 ; 0xf7f7, and then jump to 0xf7f7, which we contain our own code, 33 34 ; which will just be a 'jp isr' to our real ISR 34 35 35 - .equ isrjump, #0xf7 36 - .equ isrjumptable, #0xf800 36 + .area _CODE 37 37 38 38 patch_isr:: 39 39 di
+1 -1
modem.s
··· 24 24 .include "mailstation.inc" 25 25 .globl _new_mail 26 26 27 - .area _DATA 27 + .area _BSS 28 28 29 29 ; modem msr 30 30 _modem_curmsr::