Page 7 of 11

Re: Dragon emulator written in Python ???

Posted: Thu Oct 17, 2013 9:00 pm
by jedie
Thanks for the response.

I have the indexed addressing modes implemented, here: https://github.com/jedie/DragonPy/blob/ ... #L912-L998

But ok, it must have bugs in there...

Re: Dragon emulator written in Python ???

Posted: Thu Oct 17, 2013 9:14 pm
by tormod
Yes, there is a little short circuit here: https://github.com/jedie/DragonPy/blob/ ... y#L993-995

Re: Dragon emulator written in Python ???

Posted: Thu Oct 17, 2013 9:59 pm
by jedie
Thanks. Have found the error:

Code: Select all

-postbyte & 0x10 == 1
+postbyte & 0x10 != 0
fixed with: https://github.com/jedie/DragonPy/commi ... 973c259816

Now i can communicate a little bit with the BASIC interpreter. But there must be exist a few other bugs. Because crashed fast and often ;)


EDIT: Seems that i need some missing information for all opcodes, see: viewtopic.php?f=8&t=4388&p=9680#p9680

Re: Dragon emulator written in Python ???

Posted: Mon Oct 21, 2013 4:00 pm
by jedie
I'm done many updates and used the new 6809 opcode data, see: viewtopic.php?f=8&t=4388#p9703

Now the Simple6809 works a little bit more: I can input some code... but get allways "OM ERROR" Back.
Think there is a bug in carry flag, because of this:

Code: Select all

                        * CHECK TO SEE IF THERE IS ROOM TO STORE 2*ACCB
                        * BYTES IN FREE RAM - OM ERROR IF NOT
def0 4f                 LAC33     CLRA                            * ACCD CONTAINS NUMBER OF EXTRA
def1 58                           ASLB                            * BYTES TO PUT ON STACK
def2 d3 1f                        ADDD 001f(ARYEND)               END OF PROGRAM AND VARIABLES
def4 c3 00 3a           LAC37     ADDD #003a(STKBUF)              ADD STACK BUFFER - ROOM FOR STACK?
def7 25 08                        BCS  LAC44                      BRANCH IF GREATER THAN $FFFF
def9 10 df 17                     STS  0017(BOTSTK)               CURRENT NEW BOTTOM OF STACK STACK POINTER
defc 10 93 17                     CMPD 0017(BOTSTK)               ARE WE GOING TO BE BELOW STACK?
deff 25 ee                        BCS  deef(LAC32)                YES - NO ERROR
df01 c6 0c              LAC44     LDB  #6*2                       OUT OF MEMORY ERROR
debug output:

Code: Select all

def2| (30188) read byte $c3 from $def4
read pc byte: $c3 from $def4
	get m with get_m_immediate_word
def4| (30189) read byte $3a from $def6
def4| (30190) read byte $0 from $def5
	read pc word: $003a from $def5
	get_m_immediate_word(): $3a from $def5
def4| instruction_ADD16(m=$3a opcode=$c3 register=D=021c)
$def7 c3 3a ADD16 D: 540 + 58 = 598 (signed: 598)
def4| c3   ADDD   D=021c m:3a                 cc=50 a=02 b=56 dp=00 x=00f4 y=dd35 u=00ff s=0147 | .F.I....
-------------------------------------------------------------------------------
def4| (30195) read byte $25 from $def7
read pc byte: $25 from $def7
	get ea with get_ea_relative
def7| (30196) read byte $8 from $def8
read pc byte: $08 from $def8
	get_ea_relative(): ea = $def9 + 8 = $df01 	| $df01: $df01 - OUT OF MEMORY ERROR
def7| instruction_BLO(ea=$df01 opcode=$25)
$def9 BLO/BCS/LBLO/LBCS: don't branch to $df01, because C==0 	| $df01: $df01 - OUT OF MEMORY ERROR
def7| 25   BLO    ea:df01                     cc=50 a=02 b=56 dp=00 x=00f4 y=dd35 u=00ff s=0147 | .F.I....
	 new PC: def7 -> $def9	| $def9: $def9 - CURRENT NEW BOTTOM OF STACK STACK POINTER
EDIT: Dragon 32 ROM with XRoar trace compare differends after round 33.400 CPU cycles here:

Code: Select all

b3d3| 30   LEAX   X=0601 ea:0602              cc=50 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.I....
b3d3| 3001        LEAX    1,X                 cc=50 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.I....
b3d5| 63   COM    ea:0603 m:10                cc=59 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.IN..C
b3d5| 6301        COM     1,X                 cc=59 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.IN..C
b3d8| f1   CMPB   B=60 m:dd                   cc=53 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.I..VC
b3d7| 20f1        BRA     $b3ca               cc=59 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.IN..C
trace: b3d7| 20f1        BRA     $b3ca               cc=59 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.IN..C
own..: b3d8| f1   CMPB   B=60 m:dd                   cc=53 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.I..VC
b3d8|Error in CPU cycles: 33439
address ('b3d8' != 'b3d7') not the same as trace reference!

trace: b3d7| 20f1        BRA     $b3ca               cc=59 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.IN..C
own..: b3d8| f1   CMPB   B=60 m:dd                   cc=53 a=00 b=60 dp=00 x=0602 y=b39b u=0000 s=03d7 | .F.I..VC
b3d8|Error in CPU cycles: 33439
mnemonic ('CMPB' != 'BRA') not the same as trace reference!
Think also because of wrong CC values.


Simple 6809 looks now like this:

Re: Dragon emulator written in Python ???

Posted: Mon Oct 21, 2013 10:44 pm
by jedie
After a few updates i get no OM ERROR anymore. But not really working. Often a SN ERROR or something else.

Re: Dragon emulator written in Python ???

Posted: Tue Oct 22, 2013 5:25 pm
by jedie
I adapted now the XRoar CC routines with: https://github.com/jedie/DragonPy/commi ... 77742423c2
OM ERROR is away. But unuseable anyway :(
But maybe my python translation it's not enough.

Re: Dragon emulator written in Python ???

Posted: Fri Oct 25, 2013 5:27 pm
by jedie
After bugfixes in the CC register code, i had the hope that Simple6809 is a little but useable... Is not :cry:

Now i have hacked a simple script for copy&paste origin ROM code into a python unittest: https://github.com/jedie/DragonPy/blob/ ... nittest.py

e.g.: source code is this:

Code: Select all

db16 34 02 PSHS A
db18 81 0d CMPA #000d(CR) IS IT CARRIAGE RETURN?
db1a 27 0b BEQ NEWLINE YES
Script transforms it to this:

Code: Select all

        self.cpu_test_run2(start=0x4000, count=3, mem=[
            # origin start address in ROM: $db16
            0x34, 0x02, # PSHS A
            0x81, 0x0d, # CMPA #000d(CR)       ; IS IT CARRIAGE RETURN?
            0x27, 0x0b, # BEQ  NEWLINE         ; YES
        ])
Then copy&paste and create a real unittests here: https://github.com/jedie/DragonPy/blob/ ... #L583-L601


With this i will create more and more tests in the hope to find all bugs...

Re: Dragon emulator written in Python ???

Posted: Sun Oct 27, 2013 1:45 am
by jedie
I found http://lennartb.home.xs4all.nl/m6809.html there is a archive to download with GPL sources: http://lennartb.home.xs4all.nl/sbc09.tar.gz

Very interesting stuff!

With https://github.com/jedie/DragonPy/commi ... 042b8151c7 i added this to DragonPy.
The content of sbc09.tar.gz is here: https://github.com/jedie/DragonPy/tree/ ... bc09/sbc09

The Achive contains (C code) e.g.:
* 6809 assembler: https://github.com/jedie/DragonPy/blob/ ... bc09/a09.c
* 6809 simulator: https://github.com/jedie/DragonPy/blob/ ... bc09/v09.c
* A ROM with ASM source code. included a monitor programm: https://github.com/jedie/DragonPy/blob/ ... onitor.asm

information is in the README and LaTeX files, e.g.:
https://github.com/jedie/DragonPy/blob/ ... README.txt
https://github.com/jedie/DragonPy/blob/ ... /sbc09.tex

The "6809 Simulator" can also create trace files like XRoar, e.g.:

Code: Select all

pc=e400 i=1a    x=0000 y=0000 u=0000 s=0000 a=00 b=00 cc=00
pc=e402 i=4f    x=0000 y=0000 u=0000 s=0000 a=00 b=00 cc=ff
pc=e403 i=1f    x=0000 y=0000 u=0000 s=0000 a=00 b=00 cc=f4
pc=e405 i=10 ce x=0000 y=0000 u=0000 s=0000 a=00 b=00 cc=f4
pc=e409 i=8e    x=0000 y=0000 u=0000 s=0400 a=00 b=00 cc=f0
pc=e40c i=ce    x=e520 y=0000 u=0000 s=0400 a=00 b=00 cc=f8
pc=e40f i=c6    x=e520 y=0000 u=0280 s=0400 a=00 b=00 cc=f0
...
So i can also use the ROM and compare the trace...


EDIT: One thing i found out is that the half-carry flag is updated where it should be undefined, e.g.: https://github.com/jedie/DragonPy/commi ... 6b80a3adfb

Re: Dragon emulator written in Python ???

Posted: Sun Oct 27, 2013 11:12 am
by jedie
The sbc09 ROM works quite well almost. Looks like this:
DragonPy_sbc09_01.png
DragonPy_sbc09_01.png (46.77 KiB) Viewed 8797 times

I update the README and insert more information there:
https://github.com/jedie/DragonPy#current-status
https://github.com/jedie/DragonPy/tree/ ... c09#readme

Re: Dragon emulator written in Python ???

Posted: Mon Jun 23, 2014 4:40 pm
by jedie
I made a quick hack and add the Multicomp ROM from: http://searle.hostei.com/grant/Multicomp/ (See also: viewtopic.php?f=8&t=4338&p=11241#p11241 )

The reaction is similar to the "Simple6809" ROM. IMHO it's the same with a few address changes.

I have to cleanup the code and start debugging it, again...