mirror of https://github.com/falsovsky/z80.git
Document
This commit is contained in:
parent
dc8797c576
commit
8d7e4dfcb0
|
|
@ -61,38 +61,40 @@ end_main
|
||||||
|
|
||||||
; -------------------------------------
|
; -------------------------------------
|
||||||
|
|
||||||
|
; opcode comes in A
|
||||||
loopup_table
|
loopup_table
|
||||||
pop de
|
pop de ; Remove return address from stack
|
||||||
ld de, lookup_tbl_opcodes
|
ld de, lookup_tbl_opcodes ; Start of opcodes_tbl in DE
|
||||||
ld hl, lookup_tbl_routines
|
ld hl, lookup_tbl_routines ; Start of routines_tbl in HL
|
||||||
ld c, $9
|
ld c, $9 ; Number of valid opcodes + 1
|
||||||
loopup_table_loop
|
loopup_table_loop
|
||||||
ld b, a
|
ld b, a ; B = A (opcode to run)
|
||||||
push bc
|
push bc ; Push BC to the stack
|
||||||
ld a, (de)
|
; B = Opcode, C = counter
|
||||||
cp b
|
ld a, (de) ; Read item from opcodes_tbl
|
||||||
jr z, lookup_table_found
|
cp b ; Is it the same?
|
||||||
pop bc
|
jr z, lookup_table_found ; Found it!
|
||||||
ld a, b
|
pop bc ; Get values from stack
|
||||||
inc de
|
ld a, b ; A = B (opcode to run)
|
||||||
|
inc de ; Next item in opcodes_tbl
|
||||||
inc hl
|
inc hl
|
||||||
inc hl
|
inc hl ; Next item in opcodes_routines
|
||||||
dec c
|
dec c ; C = C -1
|
||||||
jr z, lookup_table_default
|
jr z, lookup_table_default ; Is it 0? Non valid opcode
|
||||||
jr loopup_table_loop
|
jr loopup_table_loop ; Repeat
|
||||||
lookup_table_found
|
lookup_table_found
|
||||||
pop bc
|
pop bc
|
||||||
jr lookup_table_ret
|
jr lookup_table_ret
|
||||||
lookup_table_default
|
lookup_table_default
|
||||||
ld de, continue
|
ld de, continue ; DE = address to "continue" label
|
||||||
push de
|
push de ; Send it to the stack
|
||||||
ret
|
ret ; Return to last item in the stack
|
||||||
lookup_table_ret
|
lookup_table_ret
|
||||||
ld e, (hl)
|
ld e, (hl) ; Save the address of the routine to
|
||||||
inc hl
|
inc hl ; be RETurned in DE
|
||||||
ld d, (hl)
|
ld d, (hl)
|
||||||
push de
|
push de ; Send it to the stack
|
||||||
ret
|
ret ; Return to last item in the stack
|
||||||
|
|
||||||
; -------------------------------------
|
; -------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue