Aha! I'd completely missed the point of the relocation table, which is why my efforts to use the relocater were going wrong.
Then, I think there are a couple of bugs in the demo, corrected below. And it doesn't work well if it overwrites itself!
Code: Select all
$ ./bbc-emu basic.bbc
> REM input the bootstrap
>!&4000=&02550216
>!&4004=&00810690
>!&4008=&40A900F6
>!&400C=&E0200295
>!&4010=&9021C9FF
>!&4014=&60E9D0F9
>X%=&70
>!X%=&5000
> REM load the hex loader
>CALL &400A
<h<|,h=x9)<xx(lx<xxh|m=y|m=xxhx98-l(=yx8l(98,x<x<xx99)l(m,xx|(i=
x9(||(8|lm=x|y<xm,<x|(x-m,<ylhx)x9<8|(9xlm=x|m<xlm=y|m<ylhy989,h
x99x|h9|8y,xx9,9l(=l(9xxx9i(|hil(y9}lx<|=l=x-l=yxx|(h)<m=x8h|hh|
,8=y<i<x<x<x<x!
>>
>
> REM patch the output routine
>!&5016=&C9FFE020
> REM load the assembler
>!X%=&0FFA
>CALL &5000
(10,04,30,02,00,01,D8,A9,00,85,79,20,1F,10,A2,00,8A,C9,29,F0,01,E8,20,E0,FF,C9,
28,F0,F8,CA,D0,F1,C9,5F,D0,E7,60,C9,3B,D0,0F,A5,78,81,76,E6,76,D0,02,E6,77,A5,
75,85,78,60,C9,3E,D0,08,18,A5,74,E5,76,81,76,60,C9,27,D0,59,A0,FF,20,E0,FF,C9,
20,90,F9,C8,49,27,91,72,D0,F2,A9,00,85,7A,A9,12,85,7B,A6,79,F0,27,A0,FF,18,C8,
B1,7A,B0,06,51,72,C9,01,B1,7A,D0,F3,C8,B1,7A,85,76,C8,B1,7A,90,30,38,98,65,7A,
85,7A,90,02,E6,7B,CA,D0,D9,A0,FF,C8,B1,72,91,7A,D0,F9,E6,79,C8,A5,74,91,7A,C8,
A5,75,91,7A,60,A4,76,C9,3D,D0,0E,B1,70,85,76,C8,B1,70,85,77,A5,74,85,78,60,C9,
2A,D0,0A,A5,74,91,70,C8,A5,75,91,70,60,C9,2C,F0,09,C9,3C,D0,13,18,98,E5,74,A8,
98,81,74,A5,77,85,76,E6,74,D0,02,E6,75,60,C9,40,D0,06,84,74,A4,77,84,75,49,30,
C9,0A,90,0A,09,20,69,88,C9,FA,90,0F,29,0F,A2,04,06,76,26,77,CA,D0,F9,05,76,85,
76,60,Q)
>
Syntax error
>
> REM call the assembler and give it the demo program
>CALL &1000
10 @ 'BPL'
20 @ 'JSR'
60 @ 'RTS'
A2 @ 'LDX #'
B5 @ 'LDA ,X'
BD @ 'LDA W,X'
CA @ 'DEX'
FFEE @ 'OUTPUT' (a system-dependent address, of course)
7000 @ ( was 1000 @ )
'LDX #',11,
00* 'LDA W,X','STRING',,
'STX'
'JSR','OUTPUT' ,, (added double comma)
'DEX',
'BPL',00=<
'RTS' , (added comma)
'STRING';;
(DB) 21,64,6C,72,6F,47,20,69,48,20,20,21,6D,6F,4D,20,69,48
_
>>
>
>CALL &7000
i Mom! Hi Gorld!>
>
I hand-relocated the assembler, and compacted the hex for pasting purposes. The version above uses zero page from &70 and calls &FFE0 for 'get'
(BBC BASIC has a built-in assembler so it's an odd place to be trying this out)
The spurious error is from the closing ) after the Q. I'm going to ignore the initial H going missing, and regard this as success!
Edit: oops, I didn't initialise the pointers LABELS and SYMBUF - will only work if I'm lucky.
(The TUBE emulator is by Michael Firth. The program doesn't work on a real Beeb, but I haven't yet figured out why. The assembler works!)