Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:18 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CHIP-8 disassembler for Maximite

Author Message
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 03:31am 25 Apr 2012
Copy link to clipboard 
Print this post

Hi all,

I know this programme probably has limited appeal, but hey, it kept me busy for a day, so I thought I'd post it here. Some of you may remember the DREAM 6800 SBC, which appeared in Electronics Australia in 1979. Its high level language was CHIP-8.

Here's the code:

START:
Rem CHIP-8 Disassembler written in MMBASIC
Rem Copyright (c) 2012 by Bob Devries
Do
Cls : Locate 40,150 : Print "CHIP-8 Disassembler (c) 2012 by Bob Devries"
Locate 40,165 : Print Space$(70)
Locate 40,165
Print "Please type CHIP-8 Binary filename (or ENTER to exit) ";
Line Input fn$
If fn$ = "" Then Exit
Open fn$ For input As #1
If MM.Errno <> 0 Then Print "Error opening input file." : Exit
fo = Instr(1,fn$,".")
If fo = 0 Then
fo$ = fn$ + ".ch8"
Else
fo$ = Left$(fn$,fo-1) + ".ch8"
EndIf
Locate 40,180 : Print "Output to screen or file?"
Locate 40,195 : Print "Press 'S' or 'F'"
keyloop: k$ = Inkey$ : If k$ = "" Then GoTo keyloop
k$ = UCase$(k$)
If k$ <> "S" And k$ <> "F" GoTo keyloop
If k$ = "S" Then dev = 0 Else dev = 2
If k$ = "F" Then Locate 40,210 : Print "Output filename will be ";fo$
If dev <> 0 Then
Open fo$ For output As #dev
EndIf
If MM.Errno <> 0 Then Print "Error opening output file." : Exit
Do While Not(Eof(#1))
w1 = Asc(Input$(1,#1))
w2 = Asc(Input$(1,#1))
word = w1 * 256 + w2 : Rem make it decimal
whex$ = Hex$(word) : Rem make it hex
whex$ = "000" + whex$ : Rem we want leading zeroes
whex$ = Right$(whex$,4) : Rem but just 4 chars
lhex = Val("&H" + Left$(whex$,1))
If lhex = 0 Then GoSub zero : GoTo cont
If lhex = 1 Then GoSub one : GoTo cont
If lhex = 2 Then GoSub two : GoTo cont
If lhex = 3 Then GoSub three : GoTo cont
If lhex = 4 Then GoSub four : GoTo cont
If lhex = 5 Then GoSub five : GoTo cont
If lhex = 6 Then GoSub six : GoTo cont
If lhex = 7 Then GoSub seven : GoTo cont
If lhex = 8 Then GoSub eight : GoTo cont
If lhex = 9 Then GoSub nine : GoTo cont
If lhex = 10 Then GoSub ten : GoTo cont
If lhex = 11 Then GoSub eleven : GoTo cont
If lhex = 12 Then GoSub twelve : GoTo cont
If lhex = 13 Then GoSub thirteen : GoTo cont
If lhex = 14 Then GoSub fourteen : GoTo cont
If lhex = 15 Then GoSub fifteen : GoTo cont
cont: Pause 100
Loop
If dev = 2 Then
Close #dev
EndIf
Close #1
Print "Files closed"
Loop
Cls : Locate 40,150 : Print "CHIP-8 Disassembler"
Locate 40,165 : Print "End run. Goodbye!"
End

zero: Rem 0XXX
If whex$ = "0000" Then Print #dev,whex$;" : NOP" : Return
If whex$ = "00E0" Then Print #dev,whex$;" : ERASE" : Return
If whex$ = "00EE" Then Print #dev,whex$;" : RETURN" : Return
MMM$ = Right$(whex$,3)
If Val("&H"+MMM$) < &H200 Then
Print #dev,whex$;" : Unknown code" : Return
EndIf
Print #dev,whex$;" : CALL(M/C) $";MMM$
Return
one: Rem 1MMM
MMM$ = Right$(whex$,3)
Print #dev,whex$;" : GOTO $";MMM$
Return
two: Rem 2MMM
MMM$ = Right$(whex$,3)
Print #dev,whex$;" : DO $";MMM$
Return
three: Rem 3XXX
vx$ = Mid$(whex$,2,1) : kk$ = Right$(whex$,2)
Print #dev,whex$;" : SKF V";vx$;" = $";kk$
Return
four: Rem 4XXX
vx$ = Mid$(whex$,2,1) : kk$ = Right$(whex$,2)
Print #dev,whex$;" : SKF V";vx$;" <> $";kk$
Return
five: Rem 5XXX
vx$ = Mid$(whex$,2,1) : vy$ = Mid$(whex$,3,1)
Print #dev,whex$;" : SKF V";vx$;" = V";vy$
Return
six: Rem 6XKK
vx$ = Mid$(whex$,2,1) : kk$ = Right$(whex$,2)
Print #dev,whex$;" : V";vx$;" = $";kk$
Return
seven: Rem 7XXX
vx$ = Mid$(whex$,2,1) : kk$ = Right$(whex$,2)
Print #dev,whex$;" : V";vx$;" = V";vx$;" + $";kk$
Return
eight: Rem 8XXX
act$ = Right$(whex$,1)
vx$ = Mid$(whex$,2,1) : vy$ = Mid$(whex$,3,1)
If act$ = "0" Then
Print #dev,whex$;" : V";vx$;" = V";vy$ : Return
EndIf
If act$ = "1" Then
Print #dev,whex$;" : V";vx$;" = V";vx$;" OR V";vy$ : Return
EndIf
If act$ = "2" Then
Print #dev,whex$;" : V";vx$;" = V";vx$;" AND V";vy$ : Return
EndIf
If act$ = "4" Then
Print #dev,whex$;" : V";vx$;" = V";vx$;" + V";vy$ : Return
EndIf
If act$ = "5" Then
Print #dev,whex$;" : V";vx$;" = V";vx$;" - V";vy$ : Return
EndIf
Print #dev,whex$;" : Unknown code" : Return
nine: Rem 9XXX
vx$ = Mid$(whex$,2,1) : vy$ = Mid$(whex$,3,1)
Print #dev,whex$;" : SKF V";vx$;" <> V";vy$
Return
ten: Rem AMMM
MMM$ = Right$(whex$,3)
Print #dev,whex$;" : I = $";MMM$
Return
eleven: Rem BMMM
MMM$ = Right$(whex$,3)
Print #dev,whex$;" : GOTO $";MMM$;" + V0"
Return
twelve: Rem CXXX
vx$ = Mid$(whex$,2,1) : kk$ = Right$(whex$,2)
Print #dev,whex$;" : V";vx$;" = RND AND $";kk$
Return
thirteen: Rem DXYN
vx$ = Mid$(whex$,2,1) : vy$ = Mid$(whex$,3,1) : n$ = Right$(whex$,1)
Print #dev,whex$;" : SHOW ";n$;" @ V";vx$;", V";vy$
Return
fourteen: Rem EXXX
vx$ = Mid$(whex$,2,1) : ex$=Right$(when$,2)
If ex$ <> "9E" And ex$ <> "A1" Then
Print #dev,whex$;" : unknown code" : Return
EndIf
If ex$ = "9E" Then ne$ = " = "
If ex$ = "A1" Then ne$ = " <> "
Print #dev,whex$;" : SKF V";vx$;ne$;"KEY"
Return
fifteen: Rem FXXX
act$ = Right$(whex$,2) : vx$ = Mid$(whex$,2,1)
If act$ = "00" And vx$ = "0" Then
Print #dev,whex$;" : STOP"
EndIf
If act$ = "07" Then
Print #dev,whex$;" : V";vx$;" = TIME" : Return
EndIf
If act$ = "0A" Then
Print #dev,whex$;" : V";vx$;" = KEY" : Return
EndIf
If act$ = "15" Then
Print #dev,whex$;" : TIME = V";vx$ : Return
EndIf
If act$ = "18" Then
Print #dev,whex$;" : TONE = V";vx$ : Return
EndIf
If act$ = "1E" Then
Print #dev,whex$;" : I = I + V";vx$ : Return
EndIf
If act$ = "29" Then
Print #dev,whex$;" : I = DSP, V";vx$ : Return
EndIf
If act$ = "33" Then
Print #dev,whex$;" : MI = DEQ, V";vx$ : Return
EndIf
If act$ = "55" Then
Print #dev,whex$;" : MI = V0:V";vx$ : Return
EndIf
If act$ = "65" Then
Print #dev,whex$;" : V0:V";vx$;" = MI" : Return
EndIf
Print #dev,whex$;" : Unknown code" : Return
End

Bob Devries
Dalby, QLD, Australia
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 03:35am 25 Apr 2012
Copy link to clipboard 
Print this post

Cool Bob.

Next is the Chip 8 interpreter!

There goes another day!

Nick
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 03:53am 25 Apr 2012
Copy link to clipboard 
Print this post

original designer of the DREAM-6800 has a webpage including pdf's of original articles at Dream6800 Page

And great program Bob from Dalby (BTW i live a few Kms south at clifton)Edited by djuqa 2012-04-26
VK4MU MicroController Units

 
brucepython

Regular Member

Joined: 19/06/2011
Location: Australia
Posts: 64
Posted: 10:32am 25 Apr 2012
Copy link to clipboard 
Print this post

This is like seeing a ghost! I have dozens of DREAM 6800 programs on cassettes, probably mostly turned to rust by now, but even if they were OK getting them into the Mite could be quite a challenge. Come to think of it, most were highly dependent on 6800 code, especially those running on the teleprinter which I no longer have.

Oh well, I guess there's always Snake...

BruceEdited by brucepython 2012-04-26
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:34pm 25 Apr 2012
Copy link to clipboard 
Print this post

Hi Bruce,

Yes, most of the CHIP-8 programmes which were published in "The Dreamer" had some machine code embedded, and all the great games like SPACE INVADERS and GALACTICA were done in pure 6800 machine code.

As far as your tapes go, you may be surprised. However, to read them into Maximite would require that you built the tape input part of the DREAM. Once you have that, it's all software, and reasonably trivial. Just follow the code in Mike Bauer's CHIPOS ROM code. The assembly listing is available on his website:

Mike Bauer's DREAM 6800 site

Regards,
Bob Devries
Dalby, QLD, Australia
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:36pm 25 Apr 2012
Copy link to clipboard 
Print this post

Oh, and BTW,

I've added the address of each line to the output of the disassembler. I'll post the revision here later.

How and where does one upload programmes to this forum?

Regards,

Bob Devries
Dalby, QLD, Australia
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:38pm 25 Apr 2012
Copy link to clipboard 
Print this post

Hey, Nick,

Yeah, I'm thinking on that, and also a CHIP-8 assembler

Regards,
Bob Devries
Dalby, QLD, Australia
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 10:08pm 25 Apr 2012
Copy link to clipboard 
Print this post

  BobDevries said   Oh, and BTW,

I've added the address of each line to the output of the disassembler. I'll post the revision here later.

How and where does one upload programmes to this forum?

Regards,

Try the furthermost right toolbar icon.
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 10:26pm 25 Apr 2012
Copy link to clipboard 
Print this post

OK,
Here's the amended version with addresses (Line numbers)

2012-04-26_082524_CHIPDISA.zip

Regards,

Bob Devries
Dalby, QLD, Australia
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 05:44am 26 Apr 2012
Copy link to clipboard 
Print this post

I wonder if a CHIP 8 interpreter would not be too large to include into the Maximite.

Add a boot menu and choose MMBASIC or Chip8 Interpreter.

Super Maximite!!

Nick
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 05:49am 26 Apr 2012
Copy link to clipboard 
Print this post

Especially good idea
With a couple extra Commands to set and read pin values , it would be great for small apps, games and utilities.
VK4MU MicroController Units

 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024