

#include "\SrcAll\v1_Header.asm"


	;jp SimpleLoads
	;jp ExtendedCommands
	;jp ToAndFromRam
	;jp StrangeNewRegisters
	jp Multiply		 	;- New MLT command
	;jp TestTst			 	;- New TST command
	;jp EffectiveAddress 	;- New LEA and PEA commands
	
	
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
	
SimpleLoads:
		ld a,128		;Load 8 bit register A with Decimal 128
		
		ld hl,$123456	;Load 24 bit register HL (UHL H L) with HEX 123456
		
		ld IX,$123456	;HL,BC,DE, IX and IY are all capable of 24 bit
		
		ld IY,$1234		;We can load just 16 bit if we need.
		
		call monitor
		
		call NewLine	
		call ShowTestData
		call NewLine	
		
		
		jp FinishProgram
		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ExtendedCommands:
		ld hl,$100000
		ld de,$010000
		call MiniMonitor
		add hl,de			;All previously 16 bit commands are now 24 bit! (Even LDIR uses 24 bit BC)
		call MiniMonitor
		or a				;Clear Carry
		sbc hl,de
		call MiniMonitor
		dec hl
		call MiniMonitor
		inc h				;8 Bit commands are still 8 bit!
		call MiniMonitor
		
		call NewLine
		call MiniMonitorSP
		Push hl				;Push commands now push 3 bytes... 
							;even AF pushes 3... A F and a 0 byte
			ld hl,0
			call MiniMonitorSP
		pop hl
		call MiniMonitorSP
		
		call NewLine
		
		ld hl,$112233	;Can't directly access the top byte ;-(
						;No LD A,HLU command - can use stack
		push hl
			ld ix,0
			add ix,sp
			ld a,(ix+2)	;Get HLU
		pop hl
		call MiniMonitorSP
		
		
		jp FinishProgram


ToAndFromRam:

		
		ld hl,TestData
		
		ld a,(hl)		;Load a byte from HL
		
		;We can now load 24 bit triples from an indirect address!
		ld bc,(hl)		;Load 24 bit from HL (BCU B C)
		
		ld e,(hl)		;Load a byte from HL
		call monitor
		
		ld ix,TestData
		ld hl,(ix+4)	;Works with IX too!
		call monitor
		
		
		call NewLine	
					
		ld a,$A1
		ld bc,$B2B3B4
		ld d,$D5
		call monitor
		
		ld hl,TestData
		ld (hl),a
		inc hl
		ld (hl),bc
		inc hl
		inc hl
		inc hl
		ld (hl),d
		
		call ShowTestData
		
		jp FinishProgram
		
TestData:
	.db $11,$22,$33,$44,$55,$66,$77,$88,$99,$AA,$BB,$CC,$DD,$EE,$FF
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
StrangeNewRegisters:

	ld hl,I				;I register is now 16 bit (only used in IM2)
	
	call monitor
	
	ld hl,$123456
	ld I,HL				;As we don't use IM2, We can use it for temp storage!
	
	call monitor
	
	ld a,mb				;MB is the top byte of the 24 bit address
						;in Z80 mode (the segment)
	call monitor
	
	di				;Need to disable interrupts before messing with MB
	
	ld a,$FF
	ld mb,a			;Can Set MB via the accumulator
	
	STMIX			;Set mixed mode (eZ80+Z80 modes)
	RSMIX			;Reset mixed mode (eZ80 mode only)
	
	call monitor
	
	jp FinishProgram
		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Multiply:
	ld bc,$0204			;MULT is only 16 bit BC=B*C
	ld de,$1003			;MULT is only 16 bit DE=D*E
	ld hl,$F011			;MULT is only 16 bit HL=H*L
	call MiniMonitor
	mlt bc				;BC=B*C
	mlt de				;DE=D*E
	mlt hl				;HL=H*L
	;also works on SP for some reason!
	
	call MiniMonitor
	
	di
	SLP ;We also have a SLP command - it will stop the CPU until interrupted
		;So that's something to enjoy, it's intended for power saving, 
		;as the internal clock of the cpu still works
		
	call MiniMonitor
		
	jp FinishProgram
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TestTst:
	ld a,$F0
	ld b,$0F
	ld c,$F0
	
	
	tst a,b		;Set flags the same as AND B  (Z)
	tst a,c		;Set flags the same as AND C (NZ)
	
	call MiniMonitor
	
	jr z,ShowZ	;Jump if Zero
	
	ld a,'N'
	call PrintChar
ShowZ:
	ld a,'Z'
	call PrintChar
	jp FinishProgram


	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
EffectiveAddress:
	ld ix,$123400
	call MiniMonitorIX
	
	lea bc,IX+7
	
	lea de,IX-1
	
	pea IX+6
	pop hl
	
	call MiniMonitorIX
	
	
	jp FinishProgram
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


	
	
ShowTestData:
	call Newline		
	ld hl,TestData	;Load the address of TestData (24 bit)
	ld bc,16
	call Monitor_MemDump 
	call Newline
	ret	
	
	
MiniMonitor:
	push af
	push bc
	push de
	push hl
		push bc
			ld b,'A'
			ld c,'F'
			push AF
			pop ix
			call MonitorOne8
			
			;call NewLine
			
			ld b,'B'
			ld c,'C'

		pop ix
		call MonitorOnE
		
		ld b,'D'
		ld c,'E'
		push DE
		pop ix
		call MonitorOne
		
		ld b,'H'
		ld c,'L'
		push HL
		pop ix
		call MonitorOne
		
		call NewLine
	pop hl
	pop de
	pop bc
	pop af
	ret
	

MiniMonitorIX:
	push ix
	push af
	push bc
	push de
	push hl
		push bc
			ld b,'I'
			ld c,'X'
			call MonitorOne8
			
			;call NewLine
			
			ld b,'B'
			ld c,'C'

		pop ix
		call MonitorOnE
		
		ld b,'D'
		ld c,'E'
		push DE
		pop ix
		call MonitorOne
		
		ld b,'H'
		ld c,'L'
		push HL
		pop ix
		call MonitorOne
		
		call NewLine
	pop hl
	pop de
	pop bc
	pop af
	pop ix
	ret
	
MiniMonitorSP:
	push af
	push bc
	push de
	push hl
	
			ld b,'A'
			ld c,'F'
			push AF
			pop ix
			call MonitorOne8

		
		ld b,'D'
		ld c,'E'
		push DE
		pop ix
		call MonitorOne
		
		ld b,'H'
		ld c,'L'
		push HL
		pop ix
		call MonitorOne
		
	ld ix,3*5
	add ix,sp
	
	ld b,'S'
	ld c,'P'
	call MonitorOne 
	
		call NewLine
	pop hl
	pop de
	pop bc
	pop af
	ret	
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	

 
	
#include "\SrcAll\Functions.asm"
#include "\SrcAll\Monitor.asm"
	
Font:
#import "\ResAll\Font96.FNT"

#include "\SrcAll\v1_Footer.asm"
