Troubles running Tiny Basic on KIM-1
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
Troubles running Tiny Basic on KIM-1
Hello,
I have a KIM-1 equipped with a 4K RAM expansion and an I/O board providing in particular a RS232 socket (both boards were ordered from Bob Applegate, this is a nice piece of work by the way). Everything works fine, I managed to load/save/run several programs via Teraterm running on a W7 PC.
However, I have been unsuccessfully trying to run Tiny Basic, which is supposed to run on a 4K KIM (I saw it uses only 3K). Here is what I did so far :
- get the paper tape format file from the IttyBitty site : this file consists in three chunks of data (starting from 2000, 0100 and 0115 resp) so I used KIMPAPER and KIMTAPE to load them on the KIM. I verified the data was appropriately loaded, but got nothing
- I realized the 4K RAM is actually mapped up to 13FF so I assumed the above binary data was relocatable - which I'm not sure - and loaded the 2000 part to 0200. Nothing again
- I got a disassembled code with the above code from the same site but itis not designed for the KIM and the IO locations are different
Needless to say I spent a significant amount of time googling but could not find anything helpful.
Any advice, help or tricks to make TB work on my shiny new KIM would be greatly appreciated !
Thanks in advance
Philippe
I have a KIM-1 equipped with a 4K RAM expansion and an I/O board providing in particular a RS232 socket (both boards were ordered from Bob Applegate, this is a nice piece of work by the way). Everything works fine, I managed to load/save/run several programs via Teraterm running on a W7 PC.
However, I have been unsuccessfully trying to run Tiny Basic, which is supposed to run on a 4K KIM (I saw it uses only 3K). Here is what I did so far :
- get the paper tape format file from the IttyBitty site : this file consists in three chunks of data (starting from 2000, 0100 and 0115 resp) so I used KIMPAPER and KIMTAPE to load them on the KIM. I verified the data was appropriately loaded, but got nothing
- I realized the 4K RAM is actually mapped up to 13FF so I assumed the above binary data was relocatable - which I'm not sure - and loaded the 2000 part to 0200. Nothing again
- I got a disassembled code with the above code from the same site but itis not designed for the KIM and the IO locations are different
Needless to say I spent a significant amount of time googling but could not find anything helpful.
Any advice, help or tricks to make TB work on my shiny new KIM would be greatly appreciated !
Thanks in advance
Philippe
Hi Philippe
I'll have a quick look, but others with more direct experience may soon overtake me.
The paper tape image is on this site and as you say, it loads mostly to $2000 with a couple of short sections to page 1.
I ran a cheap disassembly, and see that the code starts with
so it will certainly need to be loaded at that address, or rather intrusively and delicately relocated.
But, you say you verified that it loaded - does that mean you do indeed have RAM at 2000?
Cheers
Ed
I'll have a quick look, but others with more direct experience may soon overtake me.
The paper tape image is on this site and as you say, it loads mostly to $2000 with a couple of short sections to page 1.
I ran a cheap disassembly, and see that the code starts with
Code: Select all
2000 4C8520 jmp 2085
2003 4CBD20 jmp 20BD
2006 4C0620 jmp 2006
2009 4C0920 jmp 2009
But, you say you verified that it loaded - does that mean you do indeed have RAM at 2000?
Cheers
Ed
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
thanks Ed for the quick reply.
I'm afraid my explanations were a bit confused. I do not have RAM above 2000, so I actually checked everything loaded OK after I relocated the data from 200.
You're right, I think my first task is to find a disassembler and check the absolute addresses to be modified by hand. It is clear, as you state, it cannot work without proper relocation work.
Cheers
Philippe
I'm afraid my explanations were a bit confused. I do not have RAM above 2000, so I actually checked everything loaded OK after I relocated the data from 200.
You're right, I think my first task is to find a disassembler and check the absolute addresses to be modified by hand. It is clear, as you state, it cannot work without proper relocation work.
Cheers
Philippe
It looks like the third and fourth JMPs are intended to be vectors for read and write.
So, if you start from that TB.asm file, and just adjust the corresponding code to use the KIM vectors (is that 1E5A and 1EA0?), perhaps you'll be OK? Obviously, also adjust the ORG statement, and be aware of the entry point.
Cheers
Ed
So, if you start from that TB.asm file, and just adjust the corresponding code to use the KIM vectors (is that 1E5A and 1EA0?), perhaps you'll be OK? Obviously, also adjust the ORG statement, and be aware of the entry point.
Cheers
Ed
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
I was thinking you pretty much need to assemble, starting from that TB.asm - are you thinking the same? (Which is to say, there should be no advantage in disassembly, and no advantage from that tape file.)
I am poking through a naive disassembly but I'm not sure what I'm expecting to learn! (Which is to say, I'm on a diversion, trying to get that basic to run in an emulator with lots of memory.)
(I use the '-d' feature of lib6502 which can dump a memory image with a disassembly. Ruud wrote a disassembler which is much more sophisticated but when I tried it I could not convince it to cover blocks which it had deemed unreachable.)
Cheers
Ed
Using linux (or cygwin) utilities:
I am poking through a naive disassembly but I'm not sure what I'm expecting to learn! (Which is to say, I'm on a diversion, trying to get that basic to run in an emulator with lots of memory.)
(I use the '-d' feature of lib6502 which can dump a memory image with a disassembly. Ruud wrote a disassembler which is much more sophisticated but when I tried it I could not convince it to cover blocks which it had deemed unreachable.)
Cheers
Ed
Using linux (or cygwin) utilities:
Code: Select all
sed 's/.......//;s/.....$//' TBtape.KIM > TBtape.hex
xxd -r -p < TBtape.hex > TBtape.bin
run6502 -l 2000 TBtape.bin -d 2000 28ff -x > TBtape.dis.txt
I've learnt a couple more tiny facts from Bill O'Neill's reconstructed source:
I haven't yet got TinyBasic running in run6502.
Cheers
Ed
- - you can't relocate by just changing ORG, because there's a table of byte-reversed addresses which isn't (presently) symbolic. The second address is given as $6415 which is byte-reversed $1564, corresponding to label LBL027 in Bill's code. One could probably do some arithmetic based on that to replace the constants with expressions.
- the cold start begins by scanning RAM to find the top. It's a non-destructive scan, but when it scans over a RAM-loaded TinyBasic it might just break itself.
I haven't yet got TinyBasic running in run6502.
Cheers
Ed
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
I should warn you, if you didn't already notice: the simple-minded disassembly from lib6502 is informative, but not suitable for re-assembly.
Fixing up Bill's source seems like the best hope to me, because patching the paper tape binary would be a lot more work. But investigating the binary, and investigating differences between that binary and a binary from Bill could tell us something - in fact it's already helped a bit.
Cheers
Ed
Fixing up Bill's source seems like the best hope to me, because patching the paper tape binary would be a lot more work. But investigating the binary, and investigating differences between that binary and a binary from Bill could tell us something - in fact it's already helped a bit.
Cheers
Ed
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
I'm surprised to hear you have trouble compiling run6502 - it's always been OK for me. Let me know if there's anything I can do.
Well, I've made a little more progress. I can now run Bill's tinybasic on run6502:
Those ? characters are features - control codes sent by tinybasic.
The cryptic perl is needed because linux sends \n for newlines but tinybasic likes to see \r carriage returns. There might be a better way to sort that out.
The options to run6502 set up the read and write hooks and the reset vector.
I did make a couple of changes to Bill's code. I had to adjust it place the user area after tinybasic, and to defang the memory test which would run forever:
By adding and removing 4 bytes I've kept the length the same, which means no other adjustments.
Cheers Ed
Well, I've made a little more progress. I can now run Bill's tinybasic on run6502:
Code: Select all
$ perl -p -e '$|++;$_=~s/\n/\r/' | ./run6502 -l 0 tinybasic.1400.65b -G 1406 -P 1409 -R 1400
PRINT 22000/7
?:?
?3142
The cryptic perl is needed because linux sends \n for newlines but tinybasic likes to see \r carriage returns. There might be a better way to sort that out.
The options to run6502 set up the read and write hooks and the reset vector.
I did make a couple of changes to Bill's code. I had to adjust it place the user area after tinybasic, and to defang the memory test which would run forever:
Code: Select all
COLD_S lda #$00 ; Load accumulator with $00
sta $20 ; Store $00 in $20
sta $22 ; Store $00 in $22
! ; lda #$02 ; Load accumulator with $02
! lda #$30 ; Load accumulator with page of user RAM
Code: Select all
; Begin test for free ram
;
ldy #$01 ; Load register Y with $01
!
! ; fake out the top of memory to a constant
! lda #$40
! sta $23
!
! MEM_T LDA (C_22),Y ; Load accumulator With the contents of a byte of memory
tax ; Save it to X
eor #$FF ; Next 4 instuctions test to see if this memeory location
sta (C_22),Y ; is ram by trying to write something new to it - new value
cmp (C_22),Y ; gets created by XORing the old value with $FF - store the
! ; patch out first of four bytes to defang the memory test
! ; php ; result of the test on the stack to look at later
txa ; Retrieve the old memory value
sta (C_22),Y ; Put it back where it came from
inc $22 ; Increment $22 (for next memory location)
bne SKP_PI ; Goto $14A6 if we don't need to increment page
inc $23 ; Increment $23 (for next memory page)
! ; patch out three more bytes to defang the memory test
! SKP_PI
! ; PLP ; Now look at the result of the memory test
! ; beq MEM_T ; Go test the next mempry location if the last one was ram
!
! DEY ; If last memory location did not test as ram, decrement Y (should be $00 now)
cld ; Make sure we're not in decimal mode
Cheers Ed
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France
-
philippe_elie
- Posts: 8
- Joined: 04 Nov 2011
- Location: France