.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
  
CursorX equ 0x100 
CursorY equ 0x101
  
  li t7,UserRam
  
  li t8,0
  sb t8,CursorX(t7)
  sb t8,CursorY(t7)
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  
  

testSym equ 3

.macro MonitorA0A1RAPCm
	push ra
		move t6,ra
		jal MonitorA0A1RAPC
		nop
	pop ra
.endmacro


	li ra,0
	MonitorA0A1RAPCm	;Show Starting point
	jal NewLine  
	nop
	
	
	;j TestSigns
	j TestMultDiv
	nop
	
	
	
TestSigns:	
	li a0,5
	li a1,5
	li a2,-5
	
	jal MonitorA0A1A2 
	nop
	
	neg a0,a0			;A0 = -A0
	neg a1,a1			;A1 = -A1
	neg a2,a2			;A2 = -A2
	
	jal MonitorA0A1A2 
	nop
	
	neg a0,a0			;A0 = -A0
	neg a1,a1			;A1 = -A1
	neg a2,a2			;A2 = -A2
	
	jal MonitorA0A1A2 
	nop
	
	abs a0,a0			;A0 = Absolute value of A0
	abs a1,a1			;A1 = Absolute value of A1
	abs a2,a2			;A2 = Absolute value of A2
	
	jal MonitorA0A1A2 
	nop
	jal NewLine
	nop

	li a1,5
	li a1,-5
	li a2,0xE0000000
	jal MonitorA0A1A2 
	nop

	negu a0,a0		;Neg Unsigned - for large unsigned numbers
	negu a1,a1		;negu will have the same effect 
	negu a2,a2		; as neg but avoids an exception
	
	jal MonitorA0A1A2 
	nop
	
	j Shutdown
	
	
	
TestMultDiv:	
	li a0,0x6969
	
	li a1,3
	li a2,2
	mult a1,a2		;HI.LO = A1*A2
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
	jal NewLine
	nop
	
	mfhi a1			;Move From HI to a1
	mflo a2			;Move From LO to a2
	
	jal MonitorA0A1A2 
	nop
	
	mthi a0			;Move a0 To HI
	mtlo a0			;Move a0 To LO
	
	jal MonitorHILO
	nop
	
	jal NewLine
	nop
	jal NewLine
	nop
	
	li a1,0x10000000
	li a2,0x123
	mult a1,a2		;HI.LO=A1*A2
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
	jal NewLine
	nop
	
	
	li a1,0x80000000	;Is this a negative number?
	li a2,0x10
	mult a1,a2		;HI.LO=A1*A2 (Signed)
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
	multu a1,a2		;HI.LO=A1*A2 (Unsigned)
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
	
	jal NewLine
	nop
	jal NewLine
	nop
	
	
	li a1,0x9
	li a2,0x2
	div a1,a2		;LO=A1/A2 (Signed) HI=Remainder
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
	
	li a1,0xFFFFFFFF
	li a2,0x2
	divu a1,a2		;LO=A1/A2 (Unsigned) HI=Remainder
	
	jal MonitorA0A1A2 
	nop
	jal MonitorHILO
	nop
	
		
	j Shutdown
	nop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
	
Shutdown:
	j Shutdown
	nop

MonitorHILO:
	push ra
	pushAs
	pushTs
	    li t5,'H'
		li t6,'I'
		MFHI t7
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		li t5,'L'
		li t6,'O'
		MFLO t7
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		jal NewLine         
		nop
	popTs
	popAs
	pop ra
	jr ra
	nop	
	
MonitorA0A1RAPC:
	pushAs
	push ra
		push t6
			li t5,'a'
			li t6,'0'
			move t7,a0
			jal ShowRegTextB                ;A5 A6 : A7
			nop
			li t5,'a'
			li t6,'1'
			move t7,a1
			jal ShowRegTextB                ;A5 A6 : A7
			nop
			
			jal NewLine         
			nop			
			li t5,'r'
			li t6,'a'
		pop t7
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		li t5,'p'
		li t6,'c'
	pop t7
	push t7
		jal ShowRegTextB                ;A5 A6 : A7  
		nop
		jal NewLine         
		nop
	pop ra
	popAs
	jr ra
	nop
 
MonitorA0A1A2:
	push ra
	pushAs
	pushTs
	    li t5,'a'
		li t6,'0'
		move t7,a0
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		li t5,'a'
		li t6,'1'
		move t7,a1
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		li t5,'a'
		li t6,'2'
		move t7,a2
		jal ShowRegTextB                ;A5 A6 : A7
		nop
		jal NewLine         
		nop
	popTs
	popAs
	pop ra
	jr ra
	nop
  
TestData:	;Little Endian - so this is F3F2F1F0
	.byte 0xF0,0xF1,0xF2,0xF3	
	.byte 0,0,0,0,0,0,0,0,0,0,0,0
	
JumpAndLinkTo: 
  .ascii "JAL "
  .byte 255 
JumpTo: 
  .ascii "J   "
  .byte 255 
JumpToRegister: 
  .ascii "JR  "
  .byte 255 
JumpAndLinkToRegister: 
  .ascii "JALR"
  .byte 255 
  
  
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
MyFont:

.ifdef buildn64				;Can't use EQU to define with ifdef - use DefineLabel because reasons!
	.incbin "\ResN64\ChibiAkumas.fnt"
.endif
.ifdef buildPSX				;Can't use EQU to define with ifdef - use DefineLabel because reasons!
	.incbin "\ResPSX\ChibiAkumas.fnt"
.endif

.include "\SrcALL\graphics.asm"
	
.include "..\\SrcAll\monitor.asm"  	
.include "\SrcN64\Footer.asm"