|
Post by mirkosoft on Oct 15, 2018 10:17:55 GMT
Hi!
Like we all know that each Commodore computer has different location of Basic program - even - since Basic 3.5 is program relocated by GRAPHIC command.
I need to use "self-PEEK" like to get Basic location high byte. What I mean: Commodore computers have Basic-Text start pointer but not all on the same place - it is different, only on some machines common. So, reading this location is not useful. I need to make Self-PEEK like this: 10 POINTER = PEEK(*+1) * asterisk is meaning like in assembler determining current location address. This can be location at * character in Basic text. By this is possible to get at least high byte of Basic program if is line at beginning. Or other way is reading next line pointer in Basic code - in MLM it is possible to get.
But is it by any trick possible to do it in Basic and even universal in all Commodore 8-bit computers? PEEK command is AFAIK in each Commodore Basic available.
Why: Basic program can look: 10 POINTER = PEEK(*+1) 20 FORF=0TO1000:POKE4864+F,PEEK(((POINTER*256)+256)+F):NEXTF:REM ML PROGRAM IS LOCATED 256 BYTES AFTER BASIC START
30 SYS4864
It can allow to copy ML program from location in computer to location 4864 ($1300) and by Basic execute it.
So, any suggestion?
Miro
|
|
|
Post by bjonte on Oct 16, 2018 6:45:20 GMT
You can get the BASIC start pointer but it won’t be the same location on all computers so you’ll need to figure out the computer type first. What computers do you need to support?
|
|
|
Post by mirkosoft on Oct 16, 2018 12:39:01 GMT
Yes, it is not problem. But some Commodore 8-bit computers have not Basic pointer anywhere, or is not known. Why I need it without machine spec? We can name it e.g. UniApp - Universal Application. I can by easy way implement The Ace API on all without any other system requirements - The Ace API will be used only if will be not specified location where to copy - relocation is not problem incl. JMP or JSR jumps. So, if I want to run it on each machine (PET, CBM, VIC20, C64, C16+4, C128, CLCD, C65, M65) it needs this instead Basic pointer - or - if you know pointer on: PET (pointer is missing or really unknown) CLCD (nearly undocumented computer in Basic mode, while running system it is not applicable) - this I want to apply only in XEMU emulator (exist version with PRG command line paramenter) C65 (M65 is the same) - in documentation is AFAIK pointer not known
Miro
|
|
|
Post by bjonte on Oct 16, 2018 16:35:13 GMT
I don’t think it is difficult to figure this out. I made an attempt on PET by typing a one line program with a print statement. I searched for the string and found the program at $0401. Then I searched the memory for $01 $04 and found five instances. I changed the first one and got lucky. The BASIC start pointer is at address 40 and 41.
|
|
|
Post by bjonte on Oct 16, 2018 16:38:52 GMT
Finding which machine it is may be tricky but should be possible since they are different and will react differently when poking their I/O addresses. The ROM is a good source of data to compare with as well.
|
|
|
Post by bjonte on Oct 16, 2018 17:05:52 GMT
I have made a macro once to generate a small bootstrap BASIC program that starts a machine language program independent on machine that works on Vic-20, C64 and C128. It isn't perfect since it assumes that the BASIC start hasn't been tampered with in advance on the C128. Here it is anyway. The comments explain the BASIC lines generated by the define byte statements.
// This basic bootstrap works for relocatable BASIC programs for Vic20, C64 and // C128. The .sys_addr will be called relative to the start of the BASIC program. // There is a small window of failure here. The detection of the start of the // program text is not perfect. If the C128 BASIC program has been relocated, // it will not work and not if the end of the program on Vic20 or C64 is exactly // at $1c01 or $4001, since the program start vectors are not the same for C128 // and the older models. macro relocate_basic_line(.line_number, .sys_addr) { .start: define word = .line2 define word = .line_number define byte[] = { // s=peek(44)*256+peek(43):h=peek(46):l=peek(45) $53, $b2, $c2, $28, $34, $34, $29, $ac, $32, $35, $36, $aa, $c2, $28, $34, $33, $29, $3a, $48, $b2, $c2, $28, $34, $36, $29, $3a, $4c, $b2, $c2, $28, $34, $35, $29, $00 } define word .line2 = .line3 define word = .line_number + 1 define byte[] = { // ifl=1and(h=28orh=64)thens=h*256+l $8b, $4c, $b2, $31, $af, $28, $48, $b2, $32, $38, $b0, $48, $b2, $36, $34, $29, $a7, $53, $b2, $48, $ac, $32, $35, $36, $aa, $4c, $00 }
define word .line3 = .line4 define word = .line_number + 2 define byte[] = { // syss+OFFSET $9e, $53, $aa, string(.sys_addr - .start), $00 } define word .line4 = 0 }
|
|
|
Post by mirkosoft on Oct 17, 2018 0:17:50 GMT
Hm, solution, but not yet enough... Thank you for PET Basic pointer. In fact you wrote bootstrap for VIC20, C64, C128 - but also with relocation problem. These all incl. relocation problem can solve. Are you sure about PET 40, 41 pointer? What with CLCD & C65?
When I solve this problem I'll publish source code.
Miro
|
|
|
Post by bjonte on Oct 17, 2018 5:51:50 GMT
Are you sure about PET 40, 41 pointer? What with CLCD & C65? I relocated BASIC using 40 and 41 in Vice PET emulator, so I’m pretty sure that is correct. I don’t know about CLCD and C65. I don’t have the machines and no emulators either.
|
|
|
Post by mirkosoft on Oct 17, 2018 11:06:11 GMT
CLCD and C65, even M65 emulates XEMU emulator.
Thank you. Miro
|
|
|
Post by bjonte on Oct 17, 2018 19:12:51 GMT
I repeated the same process for C65 and CLCD in XEMU.
C65 BASIC start: 45-46 CLCD BASIC start: 101-102
|
|