;8085 undocumented opcode macros
;for m4+asm80
;Willard Goosey
;goosey@sdc.org
;7/19/2011
;$Id: 8085undoc.def,v 1.14 2016/04/05 22:18:27 goosey Exp goosey $

;derived from OPCODE.DOC
;by Tim Peters
;and the Tundra Semiconductor CA80C85 
;data sheet

;new flag bits in F:
;bit 76543210
;bit SZUHxPVC
;S=sign
;Z=zero
;U=underflow (opcode.doc calls this T for "true sign")
;H=half-carry
;x=unused
;P=Parity even
;V=oVerflow  (opcode.doc calls this O for Overflow)
;C=Carry

;Overflow set when the carry into the sign bit <> the carry out of the
;sign bit
;Tundra says: 2's complment overflow for both 8 and 16bit arithmatic

;True sign stores what the sign would be if 9-bit signed math was being
;used
;Tundra says: U = underflow on DCX or overflow on inx
;           U= 01 x 02 + 01 x R + 02 x R
;           01=sign of operand 1
;           02=sign of operand 2
;            R=sign of result
;           for subtraction and compare, replace 02 with *02


;08 (1 byte) HL=HL-BC `dsub'
define(`dsub', `;8085 undocumented opcode `dsub'
	;HL=HL-BC
	db 08h
	')

;10 (1 byte) 16-bit arithmetic `shift' right `arhl'
;HL=HL/2
define(`arhl', `;8085 undocumented opcode `arhl'
	;HL arithmetic `shift' right
	db 10h
	')

;18 (1 byte) rotate DE left thru carry `rdel'
;E[0]=c, c=D[7]
define(`rdel', `;8085 undocumented opcode `rdel'
	;DE rotate left arithmatic
	db 18h
	')

;28 (2 bytes) DE=HL+following (unsigned) byte `ldhi'
define(`ldhi', `;8085 undocumented opcode `ldhi'
	;DE=HL+byte
	db 28h
	db $1
	')

;38 (2 bytes) DE=SP+unsigned byte `ldsi'
define(`ldsi', `;8085 undocumented opcode `ldsi'
	;DE=SP+byte
	db 38h
	db $1
	')

;CB (1 byte) call 40h if overflow flag set `rstv'
define(`rstv', `;8085 undocumented opcode `rstv'
	;call 40h if overflow flag set
	db 0CBh
	')

;D9 (1 byte) (DE)=HL `shlx'
;store value of HL at address in DE
define(`shlx', `;8085 undocumented opcode `shlx'
	;(DE)=HL
	db 0D9h
	')

;ED (1 byte) HL=(DE) `lhlx'
;load HL from value at DE
define(`lhlx', `;8085 undocumented opcode `lhlx'
	;HL=(DE)
	db 0EDh
	')

;DD (3 bytes) jump <address> if flag bit 5 (undeflow) clear
;`jnui'
define(`jnui', `;8085 undocumented opcode `jnui'
	;jmp address if flag bit 5 (underflow) is clear
	db 0DDh
	dw $1
	')

;FD (3 bytes) jump <address> if flag bit 5 (undeflow) set
;`jui'
define(`jui', `;8085 undocumented opcode `jui'
	;jmp address if flag bit 5 (underflow) is set
	db 0FDh
	dw $1
	')

;SIM & RIM supported by asm80.. documented here:
;SIM set interrupt mask + serial send
;opcode=30h
; input: A=data+mask
;A=|SOD|SOE|x|R/7.5|MSE|M/7.5|M/6.5|M/5.5|
;   SOD   = serial out data
;   SOE   = serial out enable
;   x     = don't care
;   R/7.5 = Reset RST7.5 enable
;   MSE   = Mask Set Enable
;   M/7.5 = RST 7.5 mask
;   M/6.5 = RST 6.5 mask
;   M/5.5 = RST 5.5 mask

;RIM read interrupt mask
;opcode=20h
;output A=mask
;A=|SID|1/7.5|1/6.5|1/5.5|IE|M/7.5|M/6.5|M/5.5|
;   SID   = serial data in
;   1/7.5 = pending interrupts
;   1/6.5
;   1/5.5
;   IE	  = Interrupt Enable
;   M/7.5 = Interrupt masks
;   M/6.5
;   M/5.5

;;;end 8085undoc.h
