.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
  
CursorX equ 0x100 
CursorY equ 0x101
  

	jal Cls				;Zero Graphics cursor pos
	nop
  
  

	;j LogicalOps

	j BitShifts
	nop
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  

LogicalOps:	
	li a0,0x12345678
	li a1,0x12345678
	li a2,0xFFFF0000
	
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop
	
	xor  a0,a0,a2		;a0= a0 XOR a2
	xori a1,a1,0xFF		;a1= A1 XOR 0xFF
	
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop

	and  a0,a0,a2		;a0 = a0 AND a2
	andi a1,a1,0xFF		;a1 = a1 AND 0xFF
		
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop
	
	li a2,0xCD000000
	
	or  a1,a1,a2		;a1 = a1 OR a2
	ori a0,a0,0xCD		;a0 = a0 OR 0xCD
	
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop	
	
	jal NewLine
	nop
	
	li a2,0xFF000000
	li a1,0x000000FF
	
	nor a0,a1,a2		;Neither a1 OR a2 (NOT OR)
	
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop	
	
	li a2,0
	li a1,0x00001234
	
	not a0,a1			;NOT - Flip bits of a1
	
	jal MonitorA0A1A2 	; Show A0,A1,A2 to screen
	nop
	
	
	j Shutdown
	nop
BitShifts:	
;Bit Shifts

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Logical Shifts
	li t4,4
	li a0,0x80002001
	move a1,a0
	move a2,a0
	li a3,1
	jal MonitorA0A1A2 
	nop
ShiftLoop:
	;sllv a1,a1,a3		;Shift Bits Left by a3
	sll a1,a1,1			;Shift Bits Left by 1
	
	srlv  a2,a2,a3		;Shift bits Right by a3
	;srl a2,a2,1		;Shift bits Right by 1
	
	jal MonitorA0A1A2 
	nop
	
	addi t4,t4,-1
	bne t4,zero,ShiftLoop
	nop
	
	jal NewLine
	nop

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Arithmetic Shifts
	li t4,4
	li a0,0x80002001
	move a1,a0
	move a2,a0
	li a3,1
	jal MonitorA0A1A2 
	nop
ArithmeticShiftLoop:
	sra a1,a1,1			;Arithmetic Shift bits Right by 1
	srav  a2,a2,a3		;Arithmetic Shift bits Right by a3
	jal MonitorA0A1A2 
	nop
	
	addi t4,t4,-1
	bne t4,zero,ArithmeticShiftLoop
	nop
	
	jal NewLine
	nop
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Rotations
	li t4,4
	li a0,0x80002001
	move a1,a0
	move a2,a0
	li a3,1
	jal MonitorA0A1A2 
	nop
RotationLoop:
	rol a1,a1,a3		;Rotate left a3 bits
	
	ror a2,a2,a3		;Rotate Right a3 bits
	jal MonitorA0A1A2 
	nop
	
	addi t4,t4,-1
	bne t4,zero,RotationLoop
	nop
	
	
	jal NewLine
	nop
	j Shutdown
	nop
	
	
Shutdown:
	j Shutdown
	
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"