📄 cpuaddr.inc
字号:
ADDR_Direct_Indirect_Long
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Direct_Indirect_Long 1
ADDR_Direct_Indirect_Long
mov eax,%1
SET_WORD
%endmacro
; Direct Indirect Indexed Long (corrupts eax)
; Read 8-bit and 16-bit
; ORA-17 AND-37 EOR-57 ADC-77 LDA-B7 CMP-D7 SBC-F7
; Write 8-bit and 16-bit
; STA-97
;
; 2 bytes, 6-8 clocks
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 DO 1
; (if DL != 0)
; (2) 2a 1 1 0 0 PBR,PC+1 IO 1
; 3 1 1 1 0 0,D+DO AAL 1
; 4 1 1 1 0 0,D+DO+1 AAH 1
; 5 1 1 1 0 0,D+DO+2 AAB 1
; 6 1 1 1 0 AAB,AA+Y Data Low 1/0
; (if 16-bit data)
; (1) 6a 1 1 1 0 AAB,AA+Y+1 Data High 1/0
%macro ADDR_Direct_Indirect_Indexed_Long 0
ADDR_Direct_Indirect_Long B_Y
%endmacro
%macro READ8_Direct_Indirect_Indexed_Long 0
ADDR_Direct_Indirect_Indexed_Long
GET_BYTE
%endmacro
%macro READ16_Direct_Indirect_Indexed_Long 0
ADDR_Direct_Indirect_Indexed_Long
GET_WORD
%endmacro
%macro WRITE8_Direct_Indirect_Indexed_Long 1
ADDR_Direct_Indirect_Indexed_Long
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Direct_Indirect_Indexed_Long 1
ADDR_Direct_Indirect_Indexed_Long
mov eax,%1
SET_WORD
%endmacro
; Direct index X (corrupts eax)
; Read 8-bit and 16-bit
; ORA-15 BIT-34 AND-35 EOR-55 ADC-75 LDY-B4 LDA-B5 CMP-D5
; SBC-F5
; Write 8-bit and 16-bit
; STZ-74 STY-94 STA-95
; RMW 8-bit and 16-bit
; ASL-16 ROL-36 LSR-56 ROR-76 DEC-D6 INC-F6
;
%macro ADDR_Direct_Index_X 0
ADDR_Direct B_X
%endmacro
%macro READ8_Direct_Index_X 0
ADDR_Direct_Index_X
GET_BYTE
%endmacro
%macro READ16_Direct_Index_X 0
ADDR_Direct_Index_X
%if S_8bit
GET_WORD wrap
%else
GET_WORD
%endif
%endmacro
%macro WRITE8_Direct_Index_X 1
ADDR_Direct_Index_X
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Direct_Index_X 1
ADDR_Direct_Index_X
mov eax,%1
%if S_8bit
SET_WORD wrap
%else
SET_WORD
%endif
%endmacro
%macro RMW_Direct_Index_X 1
READ %+ M_size %+ _Direct_Index_X
add R_Cycles,_5A22_FAST_CYCLE
%1
%if M_8bit
SET_BYTE
%else
%if S_8bit
SET_WORD_HL wrap
%else
SET_WORD_HL
%endif
%endif
%endmacro
; Direct index Y (corrupts eax)
; Read 8-bit and 16-bit
; LDX-B6
; Write 8-bit and 16-bit
; STX-96
;
; 2 bytes, 4-6 clocks
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 DO 1
; (if DL != 0)
; (2) 2a 1 1 0 0 PBR,PC+1 IO 1
; 3 1 1 0 0 PBR,PC+1 IO 1
; 4 1 1 1 0 0,D+DO+Y Data Low 1/0
; (if 16-bit data)
; (1) 4a 1 1 1 0 0,D+DO+Y+1 Data High 1/0
%macro ADDR_Direct_Index_Y 0
ADDR_Direct B_Y
%endmacro
%macro READ8_Direct_Index_Y 0
ADDR_Direct_Index_Y
GET_BYTE
%endmacro
%macro READ16_Direct_Index_Y 0
ADDR_Direct_Index_Y
%if S_8bit
GET_WORD wrap
%else
GET_WORD
%endif
%endmacro
%macro WRITE8_Direct_Index_Y 1
ADDR_Direct_Index_Y
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Direct_Index_Y 1
ADDR_Direct_Index_Y
mov eax,%1
%if S_8bit
SET_WORD wrap
%else
SET_WORD
%endif
%endmacro
; Direct Indexed Indirect (corrupts eax)
; Read 8-bit and 16-bit
; ORA-01 AND-21 EOR-41 ADC-61 LDA-A1 CMP-C1 SBC-E1
; Write 8-bit and 16-bit
; STA-81
;
; 2 bytes, 6-8 clocks
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 DO 1
; (if DL != 0)
; (2) 2a 1 1 0 0 PBR,PC+1 IO 1
; 3 1 1 0 0 PBR,PC+1 IO 1
; 4 1 1 1 0 0,D+DO+X AAL 1
; 5 1 1 1 0 0,D+DO+X+1 AAH 1
; 6 1 1 1 0 DBR,AA Data Low 1/0
; (if 16-bit data)
; (1) 6a 1 1 1 0 DBR,AA+1 Data High 1/0
%macro ADDR_Direct_Indexed_Indirect 0
ADDR_Direct_Indirect B_X,0
%endmacro
%macro READ8_Direct_Indexed_Indirect 0
ADDR_Direct_Indexed_Indirect
GET_BYTE
%endmacro
%macro READ16_Direct_Indexed_Indirect 0
ADDR_Direct_Indexed_Indirect
GET_WORD
%endmacro
%macro WRITE8_Direct_Indexed_Indirect 1
ADDR_Direct_Indexed_Indirect
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Direct_Indexed_Indirect 1
ADDR_Direct_Indexed_Indirect
mov eax,%1
SET_WORD
%endmacro
; Absolute Index X (corrupts eax)
; Read 8-bit and 16-bit
; ORA-1D BIT-3C AND-3D EOR-5D ADC-7D LDY-BC LDA-BD CMP-DD
; SBC-FD
; Write 8-bit and 16-bit
; STZ-9E STA-9D
; RMW 8-bit and 16-bit
; ASL-1E ROL-3E LSR-5E ROR-7E DEC-DE INC-FE
;
%macro ADDR_Absolute_Index_X 0-1 0
ADDR_Absolute B_X
%ifnidni %1,0
add R_Cycles,%1
%endif
%endmacro
%macro READ8_Absolute_Index_X 0-1 0
ADDR_Absolute_Index_X %1
GET_BYTE
%endmacro
%macro READ16_Absolute_Index_X 0-1 0
ADDR_Absolute_Index_X %1
GET_WORD
%endmacro
%macro WRITE8_Absolute_Index_X 1
ADDR_Absolute_Index_X _5A22_FAST_CYCLE
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Absolute_Index_X 1
ADDR_Absolute_Index_X _5A22_FAST_CYCLE
mov eax,%1
SET_WORD
%endmacro
%macro RMW_Absolute_Index_X 1
READ %+ M_size %+ _Absolute_Index_X _5A22_FAST_CYCLE
add R_Cycles,_5A22_FAST_CYCLE
%1
%if M_8bit
SET_BYTE
%else
SET_WORD_HL
%endif
%endmacro
; Absolute Index Y (corrupts eax)
; Read 8-bit and 16-bit
; ORA-19 AND-39 EOR-59 ADC-79 LDA-B9 LDX-BE CMP-D9 SBC-F9
; Write 8-bit and 16-bit
; STA-99
;
; 3 bytes, 4-6 clocks
;
; 1 1 1 1 1 PBR,PC Op code 1
; 2 1 1 0 1 PBR,PC+1 AAL 1
; 3 1 1 0 1 PBR,PC+2 AAH 1
; (if index across page boundary, write, or X=0)
; (4) 3a 1 1 0 0 DBR,AAH,AAL+YL IO 1
; 4 1 1 1 0 DBR,AA+Y Data Low 1/0
; (if 16-bit data)
; (1) 4a 1 1 1 0 DBR,AA+Y+1 Data High 1/0
%macro ADDR_Absolute_Index_Y 0-1 0
ADDR_Absolute B_Y
%ifnidni %1,0
add R_Cycles,%1
%endif
%endmacro
%macro READ8_Absolute_Index_Y 0
ADDR_Absolute_Index_Y
GET_BYTE
%endmacro
%macro READ16_Absolute_Index_Y 0
ADDR_Absolute_Index_Y
GET_WORD
%endmacro
%macro WRITE8_Absolute_Index_Y 1
ADDR_Absolute_Index_Y _5A22_FAST_CYCLE
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Absolute_Index_Y 1
ADDR_Absolute_Index_Y _5A22_FAST_CYCLE
mov eax,%1
SET_WORD
%endmacro
; Absolute Long Index X (corrupts eax)
; Read 8-bit and 16-bit
; ORA-1F AND-3F EOR-5F ADC-7F LDA-BF CMP-DF SBC-FF
; Write 8-bit and 16-bit
; STA-9F
;
; 4 bytes, 5-6 clocks
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 AAL 1
; 3 1 1 0 1 PBR,PC+7 AAH 1
; 4 1 1 0 1 PBA,PC+3 AAB 1
; 5 1 1 1 0 AAB,AA+X Data Low 1/0
; (if 16-bit data)
; (1) 5a 1 1 1 0 AAB,AA+X+1 Data High 1/0
%macro ADDR_Absolute_Long_Index_X 0
ADDR_Absolute_Long B_X
%endmacro
%macro READ8_Absolute_Long_Index_X 0
ADDR_Absolute_Long_Index_X
GET_BYTE
%endmacro
%macro READ16_Absolute_Long_Index_X 0
ADDR_Absolute_Long_Index_X
GET_WORD
%endmacro
%macro WRITE8_Absolute_Long_Index_X 1
ADDR_Absolute_Long_Index_X
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Absolute_Long_Index_X 1
ADDR_Absolute_Long_Index_X
mov eax,%1
SET_WORD
%endmacro
; Stack Relative (corrupts eax)
; Read 8-bit and 16-bit
; ORA-03 AND-23 EOR-43 ADC-63 LDA-A3 CMP-C3 SBC-E3
; Write 8-bit and 16-bit
; STA-83
;
; 2 bytes, 4-5 cycles
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 SO 1
; 3 1 1 0 0 PBR,PC+1 IO 1
; 4 1 1 1 0 0,S+SO Data Low 1/0
; (if 16-bit data)
; (1) 4a 1 1 1 0 0,S+SO+1 Data High 1/0
%macro ADDR_Stack_Relative 0
READ8_Immediate
mov ebx,B_S ; Add stack pointer to make address
add R_Cycles,_5A22_FAST_CYCLE
add ebx,eax
and ebx,(1 << 16) - 1
%endmacro
%macro READ8_Stack_Relative 0
ADDR_Stack_Relative
GET_BYTE
%endmacro
%macro READ16_Stack_Relative 0
ADDR_Stack_Relative
GET_WORD
%endmacro
%macro WRITE8_Stack_Relative 1
ADDR_Stack_Relative
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Stack_Relative 1
ADDR_Stack_Relative
mov eax,%1
SET_WORD
%endmacro
; Stack Relative Indirect Indexed (corrupts eax)
; Read 8-bit and 16-bit
; ORA-13 AND-33 EOR-53 ADC-73 LDA-B3 CMP-D3 SBC-F3
; Write 8-bit and 16-bit
; STA-93
;
; 2 bytes, 7-8 cycles
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 SO 1
; 3 1 1 0 0 PBR,PC+1 IO 1
; 4 1 1 1 0 0,S+SO AAL 1
; 5 1 1 1 0 0,S+SO+1 AAH 1
; 6 1 1 0 0 0,S+SO+1 IO 1
; 7 1 1 1 0 DBR,AA+Y Data Low 1/0
; (if 16-bit data)
; (1) 7a 1 1 1 0 DBR,AA+Y+1 Data High 1/0
%macro ADDR_Stack_Relative_Indirect_Indexed 0
ADDR_Stack_Relative
mov eax,B_DB_Shifted
GET_WORD
mov ebx,B_Y
add R_Cycles,_5A22_FAST_CYCLE
add ebx,eax
and ebx,(1 << 24) - 1 ; Ensure 24-bit address
%endmacro
%macro READ8_Stack_Relative_Indirect_Indexed 0
ADDR_Stack_Relative_Indirect_Indexed
GET_BYTE
%endmacro
%macro READ16_Stack_Relative_Indirect_Indexed 0
ADDR_Stack_Relative_Indirect_Indexed
GET_WORD
%endmacro
%macro WRITE8_Stack_Relative_Indirect_Indexed 1
ADDR_Stack_Relative_Indirect_Indexed
mov al,%1
SET_BYTE
%endmacro
%macro WRITE16_Stack_Relative_Indirect_Indexed 1
ADDR_Stack_Relative_Indirect_Indexed
mov eax,%1
SET_WORD
%endmacro
; Absolute Indexed Indirect (corrupts eax)
; Returns new PC in %ax
; Address = (PB:X+a16)
; Address set to PC
; JMP-7C
;
; 3 bytes, 6 cycles
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 AAL 1
; 3 1 1 0 1 PBR,PC+2 AAH 1
; 4 1 1 0 0 PBR,PC+2 IO 1
; 5 1 1 0 1 PBR,AA+X NEW PCL 1
; 6 1 1 0 1 PBR,AA+X+1 NEW PCH 1
; 1 1 1 1 1 PBR,NEWPC New Op Code 1
;
; JSR-FC
;
; 3 bytes, 8 cycles
;
; 1 1 1 1 1 PBR,PC Op Code 1
; 2 1 1 0 1 PBR,PC+1 AAL 1
; 3 1 1 1 0 0,S PCH 0
; 4 1 1 1 0 0,S-1 PCL 0
; 5 1 1 0 1 PBR,PC+2 AAH 1
; 6 1 1 0 0 PBR,PC+2 IO 1
; 7 1 1 0 1 PBR,AA+X NEW PCL 1
; 8 1 1 0 1 PBR,AA+X+1 NEW PCH 1
; 1 1 1 1 1 PBR,NEWPC New Op Code 1
%macro ADDR_Absolute_Indexed_Indirect 0-1 0
%ifidni %1,JSR
mov eax,B_PB_Shifted
READ8_Immediate
push eax
GET_PBPC eax
PUSH_W New
pop eax
mov ah,al
GET_PBPC ebx
GET_BYTE
ror ax,8
mov ebx,eax
%else
mov eax,B_PB_Shifted
READ16_Immediate JMP
mov ebx,eax
%endif
add R_Cycles,_5A22_FAST_CYCLE
add bx,B_X
xor eax,eax
GET_WORD
%endmacro
; Absolute (corrupts eax)
; Address = a16
; Address set to PC
; JSR-20
; 3 bytes, 6 cycles
;
; JMP-4C
; 3 bytes, 3 cycles
;
%macro ADDR_Absolute_JMP 0
READ16_Immediate JMP
%endmacro
%macro ADDR_Absolute_JSR 0
READ16_Immediate JSR
%endmacro
; Absolute Long (corrupts eax,ebx)
; Address = a24
; Address set to PB:PC
; JSL-22
; 4 bytes, 7 cycles
;
; JML-5C
; 4 bytes, 4 cycles
;
%macro ADDR_Absolute_Long_JMP 0
READ24_Immediate JMP
%endmacro
%macro ADDR_Absolute_Long_JSR 0
READ24_Immediate JSR
%endmacro
; Absolute Indirect (corrupts eax,ebx)
; Address = (00:a16)
; Address set to PC
; JMP-6C
; 3 bytes, 5 cycles
;
%macro ADDR_Absolute_Indirect_JMP 0
READ16_Immediate JMP
mov ebx,eax
GET_WORD
%endmacro
; Absolute Indirect Long (corrupts eax,ebx)
; Address = [00:a16]
; Address set to PB:PC
; JML-DC
; 3 bytes, 5 cycles
;
%macro ADDR_Absolute_Indirect_Long_JMP 0
READ16_Immediate JMP
mov ebx,eax
GET_LONG
%endmacro
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -