;;; test7.asm
;;; 
;;; CALL, RET, PUSH, POP

	CPU	8080
	org 0000H
START:
	LXI SP, 0FD0H
	MVI A, 0FFH		;A=FF
	ADI 01H			;A=00, SZC=011
	MVI A, 12H		;A=12

	LXI B, 1234H		;BC=1234
	LXI D, 5678H		;DC=5678
	LXI H, 9ABCH		;HL=9ABC

	PUSH PSW
	PUSH B
	PUSH D
	PUSH H

	XRA A			; A=0, SZC=000
	LXI B, 0BBCCH		;BC=BBCC
	LXI D, 0DDEEH		;DE=DDEE
	LXI H, 1212H		;HL=1212

	POP H
	POP D
	POP B
	POP PSW
	
	CALL CHECK_RET

	;; check false condition
	XRA A			;A=00, SZC=010
	ADI 01H			;A=01, SZC=000
	CC CALL_ERROR
	CM CALL_ERROR
	CZ CALL_ERROR

	SBI 01H			;A=00, SZC=010
	CNZ CALL_ERROR
	SBI 01H			;A=FF, SZC=101
	CNC CALL_ERROR
	CP CALL_ERROR

	XRA A
	CZ CHECK_RZ

	XRA A
	ADI 01H
	CNZ CHECK_RNZ

	XRA A
	CNC CHECK_RNC
	SBI 01H
	CC CHECK_RC

	XRA A
	CP CHECK_RP
	SBI 01H
	CM CHECK_RM
CALL_ERROR:
	HLT

	org 0123H
CHECK_RET:
	MVI A, 0ABH
	RET
	HLT

	org 0200H
CHECK_RZ:
	RNZ
	RZ
	HLT
CHECK_RNZ:
	RZ
	RNZ
	HLT
CHECK_RC:
	RNC
	RC
	HLT
CHECK_RNC:
	RC
	RNC
	HLT
CHECK_RM:
	RP
	RM
	HLT
CHECK_RP:
	RM
	RP
	HLT
	END
