<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 17 Aug 1994 10:48:30 EST
From   : Stephen Quan <quan@...>
Subject: Re: My Next Step

> I've had a few problems of late...
> 
> I have decided that the best way to procede for the moment is to slow my 
> emulator down and have it call procedures. At the moment, for example, 
> each derivative of the ADC instruction is coded separately and henceforth 
> changing it is a complete sod. I now have got it calling procedures for each.

Perhaps.  Seems like a lot of work here.

> I'm going to go through every single instruction and work out exactly 
> what the state of the flags *should* be and what they are. I think it is 
> here that my emulator is going wonky.

I think the better way to code is have your program generate debug
information.  The following is debug code taken straight from James B
emulator.  Have yours generate runtime disassembling.

d9cd: a9 40 8d, A=00, X=00, Y=00, S=ff, P=30 ; LDA #&40
d9cf: 8d 00 0d, A=40, X=00, Y=00, S=ff, P=30 ; STA &0D00
d9d2: 78 d8 a2, A=40, X=00, Y=00, S=ff, P=30 ; SEI 
d9d3: d8 a2 ff, A=40, X=00, Y=00, S=ff, P=34 ; CLD 
d9d4: a2 ff 9a, A=40, X=00, Y=00, S=ff, P=34 ; LDX #&FF

Use anonymous ftp to grab sol.surv.uta.edu.au:/pub/bbc38600/6502.asm and
in there you should find my disassembling routine for 6502 code.  It
generates a line similar to the above up to the first 43 characters.

Have your emulator generate disassemble code for the first 100 instructions
and then have a simple Pascal (or whatever language) program that does
string compares (limited to the first 43 characters).  Using UNIX and
James B emulator, you can generate a nominal number of debug code :

       beeb -d | head -100 > debug.txt

> As I mentioned, I *did* have it displaying "BBC Computer..." on the 
> screen but since I implemented SQ's ideas (grrrr!) it doesn't any more!

I um, sorry about that.  I wish you luck and hope it comes back up again.

> Anyway, I think I'll get started on it tonight. I've first got to get 
> something that'll tell me in detail what instructions do what to the 
> flags; I've just got a rough TASM guide that doesn't really say much (it 
> comes out with things like "altered to reflect result" - what does THAT 
> mean?  ;-)  ).

Well, actually, my TASM guide didn't really explain matters any clearer.
I mainly used HELPPC, the TASM quick reference guide, but mostly the idea
will compare your emulator to a working one and you needn't check everything
only where your emulator has gone wrong.

I was going the same track as you.  The thing wouldn't work, where to
go next, but once I thought about comparing disassemble code between
my emulator and one that works, I had the whole thing debugged in 2
days.

> Well, here we go... I appear to be miles behind everyone else... rather 
> ironic since I started the list!   ;-)   I think mine is the most recent 
> to have been started, mind you.

I reckon this list is great!  To be frank, I did start writing my
emulator after subscribing to this list, there is so many useful ideas
here!  Anyhow, catch you later, bye!

Below is a debug dump for James B emulator for the first 100 commands.

d9cd: a9 40 8d, A=00, X=00, Y=00, S=ff, P=30 ; LDA #&40
d9cf: 8d 00 0d, A=40, X=00, Y=00, S=ff, P=30 ; STA &0D00
d9d2: 78 d8 a2, A=40, X=00, Y=00, S=ff, P=30 ; SEI 
d9d3: d8 a2 ff, A=40, X=00, Y=00, S=ff, P=34 ; CLD 
d9d4: a2 ff 9a, A=40, X=00, Y=00, S=ff, P=34 ; LDX #&FF
d9d6: 9a ad 4e, A=40, X=ff, Y=00, S=ff, P=b4 ; TXS 
d9d7: ad 4e fe, A=40, X=ff, Y=00, S=ff, P=b4 ; LDA &FE4E
d9da: 0a 48 f0, A=ff, X=ff, Y=00, S=ff, P=b4 ; ASL A
d9db: 48 f0 09, A=fe, X=ff, Y=00, S=ff, P=b5 ; PHA 
d9dc: f0 09 ad, A=fe, X=ff, Y=00, S=fe, P=b5 ; BEQ &D9E7
d9de: ad 58 02, A=fe, X=ff, Y=00, S=fe, P=b5 ; LDA &0258
d9e1: 4a c9 01, A=00, X=ff, Y=00, S=fe, P=37 ; LSR A
d9e2: c9 01 d0, A=00, X=ff, Y=00, S=fe, P=36 ; CMP #&01
d9e4: d0 1d 4a, A=00, X=ff, Y=00, S=fe, P=b4 ; BNE &DA03
da03: a2 0f 8e, A=00, X=ff, Y=00, S=fe, P=b4 ; LDX #&0F
da05: 8e 42 fe, A=00, X=0f, Y=00, S=fe, P=34 ; STX &FE42
da08: ca 8e 40, A=00, X=0f, Y=00, S=fe, P=34 ; DEX 
da09: 8e 40 fe, A=00, X=0e, Y=00, S=fe, P=34 ; STX &FE40
da0c: e0 09 b0, A=00, X=0e, Y=00, S=fe, P=34 ; CPX #&09
da0e: b0 f8 e8, A=00, X=0e, Y=00, S=fe, P=35 ; BCS &DA08
da08: ca 8e 40, A=00, X=0e, Y=00, S=fe, P=35 ; DEX 
da09: 8e 40 fe, A=00, X=0d, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=0d, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=0d, Y=00, S=fe, P=35 ; BCS &DA08
da08: ca 8e 40, A=00, X=0d, Y=00, S=fe, P=35 ; DEX 
da09: 8e 40 fe, A=00, X=0c, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=0c, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=0c, Y=00, S=fe, P=35 ; BCS &DA08
da08: ca 8e 40, A=00, X=0c, Y=00, S=fe, P=35 ; DEX 
da09: 8e 40 fe, A=00, X=0b, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=0b, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=0b, Y=00, S=fe, P=35 ; BCS &DA08
da08: ca 8e 40, A=00, X=0b, Y=00, S=fe, P=35 ; DEX 
da09: 8e 40 fe, A=00, X=0a, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=0a, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=0a, Y=00, S=fe, P=35 ; BCS &DA08
da08: ca 8e 40, A=00, X=0a, Y=00, S=fe, P=35 ; DEX 
da09: 8e 40 fe, A=00, X=09, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=09, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=09, Y=00, S=fe, P=37 ; BCS &DA08
da08: ca 8e 40, A=00, X=09, Y=00, S=fe, P=37 ; DEX 
da09: 8e 40 fe, A=00, X=08, Y=00, S=fe, P=35 ; STX &FE40
da0c: e0 09 b0, A=00, X=08, Y=00, S=fe, P=35 ; CPX #&09
da0e: b0 f8 e8, A=00, X=08, Y=00, S=fe, P=b4 ; BCS &DA08
da10: e8 8a 20, A=00, X=08, Y=00, S=fe, P=b4 ; INX 
da11: 8a 20 2a, A=00, X=09, Y=00, S=fe, P=34 ; TXA 
da12: 20 2a f0, A=09, X=09, Y=00, S=fe, P=34 ; JSR &F02A
f02a: a0 03 8c, A=09, X=09, Y=00, S=fc, P=34 ; LDY #&03
f02c: 8c 40 fe, A=09, X=09, Y=03, S=fc, P=34 ; STY &FE40
f02f: a0 7f 8c, A=09, X=09, Y=03, S=fc, P=34 ; LDY #&7F
f031: 8c 43 fe, A=09, X=09, Y=7f, S=fc, P=34 ; STY &FE43
f034: 8e 4f fe, A=09, X=09, Y=7f, S=fc, P=34 ; STX &FE4F
f037: ae 4f fe, A=09, X=09, Y=7f, S=fc, P=34 ; LDX &FE4F
f03a: 60 71 33, A=09, X=ff, Y=7f, S=fc, P=b4 ; RTS 
da15: e0 80 66, A=09, X=ff, Y=7f, S=fe, P=b4 ; CPX #&80
da17: 66 fc aa, A=09, X=ff, Y=7f, S=fe, P=35 ; ROR &FC
da19: aa ca d0, A=09, X=ff, Y=7f, S=fe, P=b4 ; TAX 
da1a: ca d0 f4, A=09, X=09, Y=7f, S=fe, P=34 ; DEX 
da1b: d0 f4 8e, A=09, X=08, Y=7f, S=fe, P=34 ; BNE &DA11
da11: 8a 20 2a, A=09, X=08, Y=7f, S=fe, P=34 ; TXA 
da12: 20 2a f0, A=08, X=08, Y=7f, S=fe, P=34 ; JSR &F02A
f02a: a0 03 8c, A=08, X=08, Y=7f, S=fc, P=34 ; LDY #&03
f02c: 8c 40 fe, A=08, X=08, Y=03, S=fc, P=34 ; STY &FE40
f02f: a0 7f 8c, A=08, X=08, Y=03, S=fc, P=34 ; LDY #&7F
f031: 8c 43 fe, A=08, X=08, Y=7f, S=fc, P=34 ; STY &FE43
f034: 8e 4f fe, A=08, X=08, Y=7f, S=fc, P=34 ; STX &FE4F
f037: ae 4f fe, A=08, X=08, Y=7f, S=fc, P=34 ; LDX &FE4F
f03a: 60 71 33, A=08, X=ff, Y=7f, S=fc, P=b4 ; RTS 
da15: e0 80 66, A=08, X=ff, Y=7f, S=fe, P=b4 ; CPX #&80
da17: 66 fc aa, A=08, X=ff, Y=7f, S=fe, P=35 ; ROR &FC
da19: aa ca d0, A=08, X=ff, Y=7f, S=fe, P=b4 ; TAX 
da1a: ca d0 f4, A=08, X=08, Y=7f, S=fe, P=34 ; DEX 
da1b: d0 f4 8e, A=08, X=07, Y=7f, S=fe, P=34 ; BNE &DA11
da11: 8a 20 2a, A=08, X=07, Y=7f, S=fe, P=34 ; TXA 
da12: 20 2a f0, A=07, X=07, Y=7f, S=fe, P=34 ; JSR &F02A
f02a: a0 03 8c, A=07, X=07, Y=7f, S=fc, P=34 ; LDY #&03
f02c: 8c 40 fe, A=07, X=07, Y=03, S=fc, P=34 ; STY &FE40
f02f: a0 7f 8c, A=07, X=07, Y=03, S=fc, P=34 ; LDY #&7F
f031: 8c 43 fe, A=07, X=07, Y=7f, S=fc, P=34 ; STY &FE43
f034: 8e 4f fe, A=07, X=07, Y=7f, S=fc, P=34 ; STX &FE4F
f037: ae 4f fe, A=07, X=07, Y=7f, S=fc, P=34 ; LDX &FE4F
f03a: 60 71 33, A=07, X=ff, Y=7f, S=fc, P=b4 ; RTS 
da15: e0 80 66, A=07, X=ff, Y=7f, S=fe, P=b4 ; CPX #&80
da17: 66 fc aa, A=07, X=ff, Y=7f, S=fe, P=35 ; ROR &FC
da19: aa ca d0, A=07, X=ff, Y=7f, S=fe, P=b4 ; TAX 
da1a: ca d0 f4, A=07, X=07, Y=7f, S=fe, P=34 ; DEX 
da1b: d0 f4 8e, A=07, X=06, Y=7f, S=fe, P=34 ; BNE &DA11
da11: 8a 20 2a, A=07, X=06, Y=7f, S=fe, P=34 ; TXA 
da12: 20 2a f0, A=06, X=06, Y=7f, S=fe, P=34 ; JSR &F02A
f02a: a0 03 8c, A=06, X=06, Y=7f, S=fc, P=34 ; LDY #&03
f02c: 8c 40 fe, A=06, X=06, Y=03, S=fc, P=34 ; STY &FE40
f02f: a0 7f 8c, A=06, X=06, Y=03, S=fc, P=34 ; LDY #&7F
f031: 8c 43 fe, A=06, X=06, Y=7f, S=fc, P=34 ; STY &FE43
f034: 8e 4f fe, A=06, X=06, Y=7f, S=fc, P=34 ; STX &FE4F
f037: ae 4f fe, A=06, X=06, Y=7f, S=fc, P=34 ; LDX &FE4F
f03a: 60 71 33, A=06, X=ff, Y=7f, S=fc, P=b4 ; RTS 
da15: e0 80 66, A=06, X=ff, Y=7f, S=fe, P=b4 ; CPX #&80
da17: 66 fc aa, A=06, X=ff, Y=7f, S=fe, P=35 ; ROR &FC
da19: aa ca d0, A=06, X=ff, Y=7f, S=fe, P=b4 ; TAX 
da1a: ca d0 f4, A=06, X=06, Y=7f, S=fe, P=34 ; DEX 
-- 
Stephen Quan (quan@...                 )
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>