From: Cameron Kaiser (spectre_at_stockholm.ptloma.edu)
Date: 2002-10-01 19:03:52
Well, last night was a very productive all-night hack session. (Medical
students aren't *always* studying.)
In between cranking more speed out of Nether G2's core renderer (10fps!
wahoo!), I finally threw together some ideas that had been floating through
my head about a software 6502-on-6502 emulator (i.e., an emulator in 6502
assembly that emulates a 6502). While this might seem like an academic
pursuit at best, I think it would be the most elegant way of adding things
to the 6502 that we don't have yet such as true MMU facilities, protected
memory, virtual memory, etc.
In any case, it was functional enough to run this:
testp lda $d020
sta $d021
tay
iny
sty $02
ldx #0
lda #1
tlup sta $0400,x
sta $0500,x
sta $0600,x
sta $0700,x
inx
bne tlup
brk
All memory access is trapped and checked, all instructions are byte-code
verified, and as you can see, immediate, absolute, implied, branch and
absolute,x addressing modes are all working. I just need to finish the rest
of the opcodes, which were pretty easy (just distill an instruction into a
safe variant, and then run that variant, which sets all the proper flags and
whatnot for me), as well as the other addressing modes.
While I was hand-typing the instruction decode table, there were some
intriguing instruction patterns that came out. The table is below. I don't
use any of these generalisations for decoding (just a simple raw lookup),
but they might be useful to someone trying to write a better (dis)assembler.
; master instruction decode table
vectab .word opbrk, opora, opbad, opbad
.word opbad, opora, opasl, opbad ; $00-7
.word opphp, opora, opasl, opbad
.word opbad, opora, opasl, opbad ; $08-f
.word opbpl, opora, opbad, opbad
.word opbad, opora, opasl, opbad ; $10-7
.word opclc, opora, opbad, opbad
.word opbad, opora, opasl, opbad ; $18-f
.word opjsr, opand, opbad, opbad
.word opbit, opand, oprol, opbad ; $20-7
.word opplp, opand, oprol, opbad
.word opbit, opand, oprol, opbad ; $28-f
.word opbmi, opand, opbad, opbad
.word opbad, opand, oprol, opbad ; $30-7
.word opsec, opand, opbad, opbad
.word opbad, opand, oprol, opbad ; $38-f
.word oprti, opeor, opbad, opbad
.word opbad, opeor, oplsr, opbad ; $40-7
.word oppha, opeor, oplsr, opbad
.word opjmp, opeor, oplsr, opbad ; $48-f
.word opbvc, opeor, opbad, opbad
.word opbad, opeor, oplsr, opbad ; $50-7
.word opcli, opeor, opbad, opbad
.word opbad, opeor, oplsr, opbad ; $58-f
.word oprts, opadc, opbad, opbad
.word opbad, opadc, opror, opbad ; $60-7
.word oppla, opadc, opror, opbad
.word opjmp, opadc, opror, opbad ; $68-f
.word opbvs, opadc, opbad, opbad
.word opbad, opadc, opror, opbad ; $70-7
.word opsei, opadc, opbad, opbad
.word opbad, opadc, opror, opbad ; $78-f
.word opbad, opsta, opbad, opbad
.word opsty, opsta, opstx, opbad ; $80-7
.word opdey, opbad, optxa, opbad
.word opsty, opsta, opstx, opbad ; $88-f
.word opbcc, opsta, opbad, opbad
.word opsty, opsta, opstx, opbad ; $90-7
.word optya, opsta, optxs, opbad
.word opbad, opsta, opbad, opbad ; $98-f
.word opldy, oplda, opldx, opbad
.word opldy, oplda, opldx, opbad ; $a0-7
.word optay, oplda, optax, opbad
.word opldy, oplda, opldx, opbad ; $a8-f
.word opbcs, oplda, opbad, opbad
.word opldy, oplda, opldx, opbad ; $b0-7
.word opclv, oplda, optsx, opbad
.word opldy, oplda, opldx, opbad ; $b8-f
.word opcpy, opcmp, opbad, opbad
.word opcpy, opcmp, opdec, opbad ; $c0-7
.word opiny, opcmp, opdex, opbad
.word opcpy, opcmp, opdec, opbad ; $c8-f
.word opbne, opcmp, opbad, opbad
.word opbad, opcmp, opdec, opbad ; $d0-7
.word opcld, opcmp, opbad, opbad
.word opbad, opcmp, opdec, opbad ; $d8-f
.word opcpx, opsbc, opbad, opbad
.word opcpx, opsbc, opinc, opbad ; $e0-7
.word opinx, opsbc, opnop, opbad
.word opcpx, opsbc, opinc, opbad ; $e8-f
.word opbeq, opsbc, opbad, opbad
.word opbad, opsbc, opinc, opbad ; $f0-7
.word opsed, opsbc, opbad, opbad
.word opbad, opsbc, opinc, opbad ; $f8-f
--
----------------------------- personal page: http://www.armory.com/~spectre/ --
Cameron Kaiser, Point Loma Nazarene University * ckaiser@stockholm.ptloma.edu
-- Math according to Pentium: 2 / 2 = 1.037587439439485486372112039523781385 ...
Message was sent through the cbm-hackers mailing list
Archive generated by hypermail 2.1.4.