; 8608.asm
; Include this file into a CustomAsm assembly file to use the 8608 architecture, like so:
;   #include "8608.asm"
; See CustomAsm for more info: https://github.com/hlorenzi/customasm

; Generated by generate-architecture.lua using the definitions in 8608-definition.lua
; Definitions for all instructions in the 8608 architecture.
#subruledef rel8 {
	{addr} => {
		reladdr = addr - $ - 2
		assert(reladdr <=  127, "Relative jump target is too far away")
		assert(reladdr >= -128, "Relative jump target is too far away")
		reladdr`8
	}
}
#subruledef neg8 {
	{value} => {
		mvalue = -value
		mvalue`8
	}
}
#ruledef {
	RST => $41
	BRK => $00
	RTI => $40
	NOP => $EA
	CLI => $58
	SEI => $78
	HLT => $18
	RUN => $38
	INC A => $F6
	DEC A => $D6
	ICC A => $57
	INC B => $FE
	DEC B => $DE
	ICC B => $5F
	INC C => $FA
	DEC C => $DA
	ICC C => $5B
	INC {value: u8} => $E6 @ value
	DEC {value: u8} => $C6 @ value
	ICC {value: u8} => $47 @ value
	ADD #{value: i8} => $6B @ value
	SUB #{value: i8} => $EB @ value
	ADC #{value: i8} => $69 @ value
	SBC #{value: i8} => $E9 @ value
	CMP #{value: i8} => $C9 @ value
	AND #{value: i8} => $29 @ value
	ORA #{value: i8} => $09 @ value
	EOR #{value: i8} => $49 @ value
	ASL #{value: i8} => $15 @ value
	LSR #{value: i8} => $55 @ value
	ROL #{value: i8} => $35 @ value
	ROR #{value: i8} => $75 @ value
	ADD {value: u8} => $67 @ value
	SUB {value: u8} => $E7 @ value
	ADC {value: u8} => $65 @ value
	SBC {value: u8} => $E5 @ value
	CMP {value: u8} => $C5 @ value
	AND {value: u8} => $25 @ value
	ORA {value: u8} => $05 @ value
	EOR {value: u8} => $45 @ value
	ADD B => $7F
	SUB B => $FF
	ADC B => $7D
	SBC B => $FD
	CMP B => $DD
	AND B => $3D
	ORA B => $1D
	EOR B => $5D
	ADD C => $7B
	SUB C => $FB
	ADC C => $79
	SBC C => $F9
	CMP C => $D9
	AND C => $39
	ORA C => $19
	EOR C => $59
	BNE {value: rel8} => $D0 @ value
	BEQ {value: rel8} => $F0 @ value
	BLT {value: rel8} => $90 @ value
	BGE {value: rel8} => $B0 @ value
	BGT {value: rel8} => $30 @ value
	BLE {value: rel8} => $10 @ value
	BRA {value: rel8} => $98 @ value
	ADX #{value: i8} => $E8 @ value
	ADY #{value: i8} => $C8 @ value
	ADX #{value: i16} => $8A @ value
	ADY #{value: i16} => $88 @ value
	ADX A => $FC
	ADY A => $DC
	JMP {value: i16} => $CC @ value
	JSR {value: i16} => $20 @ value
	JMP [{value: i16}] => $6C @ value
	JSR [{value: i16}] => $2C @ value
	JMP [{value: i16},A] => $4C @ value
	JSR [{value: i16},A] => $0C @ value
	JMP X => $64
	JMP Y => $44
	JSR X => $24
	JSR Y => $04
	RTS => $60
	PHA => $48
	PHB => $5C
	PHC => $1C
	PHP => $08
	PHX => $54
	PHY => $14
	PLA => $68
	PLB => $7C
	PLC => $3C
	PLP => $28
	PLX => $74
	PLY => $34
	LDA #{value: i8} => $A9 @ value
	LDB #{value: i8} => $AB @ value
	LDC #{value: i8} => $2B @ value
	LDA {value: u8} => $A5 @ value
	LDB {value: u8} => $A7 @ value
	LDC {value: u8} => $27 @ value
	STA {value: u8} => $85 @ value
	STB {value: u8} => $87 @ value
	STC {value: u8} => $07 @ value
	LDA {value: i16} => $ED @ value
	LDB {value: i16} => $EF @ value
	LDC {value: i16} => $6F @ value
	STA {value: i16} => $CD @ value
	STB {value: i16} => $CF @ value
	STC {value: i16} => $4F @ value
	LDA X => $A1
	LDB X => $A3
	LDC X => $23
	LDA Y => $B1
	LDB Y => $B3
	LDC Y => $33
	STA X => $81
	STB X => $83
	STC X => $03
	STA Y => $91
	STB Y => $93
	STC Y => $13
	LDA X+ => $E1
	LDB X+ => $E3
	LDC X+ => $63
	LDA Y+ => $F1
	LDB Y+ => $F3
	LDC Y+ => $73
	STA X+ => $C1
	STB X+ => $C3
	STC X+ => $43
	STA Y+ => $D1
	STB Y+ => $D3
	STC Y+ => $53
	LDA X,{value: u8} => $BD @ value
	LDB X,{value: u8} => $BF @ value
	LDC X,{value: u8} => $3F @ value
	LDA Y,{value: u8} => $B9 @ value
	LDB Y,{value: u8} => $BB @ value
	LDC Y,{value: u8} => $3B @ value
	STA X,{value: u8} => $9D @ value
	STB X,{value: u8} => $9F @ value
	STC X,{value: u8} => $1F @ value
	STA Y,{value: u8} => $99 @ value
	STB Y,{value: u8} => $9B @ value
	STC Y,{value: u8} => $1B @ value
	LDX #{value: i16} => $AA @ value
	LDY #{value: i16} => $A8 @ value
	LDX {value: u8} => $A6 @ value
	LDY {value: u8} => $A4 @ value
	STX {value: u8} => $86 @ value
	STY {value: u8} => $84 @ value
	LDX {value: i16} => $AE @ value
	LDY {value: i16} => $AC @ value
	STX {value: i16} => $8E @ value
	STY {value: i16} => $8C @ value
	LDX X,{value: u8} => $BE @ value
	LDX Y,{value: u8} => $BA @ value
	LDY X,{value: u8} => $BC @ value
	LDY Y,{value: u8} => $B8 @ value
	STX Y,{value: u8} => $9A @ value
	STY X,{value: u8} => $9C @ value
	LDX X => $A2
	LDY X => $A0
	LDX Y => $B2
	LDY Y => $E2
	STX Y => $92
	STY X => $80
	LDX Y+ => $F2
	LDY X+ => $E0
	STX Y+ => $D2
	STY X+ => $C0
	TBA => $97
	TCA => $17
	TAB => $B7
	TCB => $D7
	TAC => $37
	TBC => $F7
	TYX => $B4
	TXY => $94
	TVX => $B6
	TXV => $96
	TAS => $95
	TSA => $B5
}
