
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  
Monitor:
    pushAll
		li $t5,'r'
		li $t6,'a'
		lw $t7,0($sp)
		jal ShowRegText                #;A5 A6 : A7
		nop
		
		li $t5,'s'
		li $t6,'p'
		lw $t7,8($sp)
		jal ShowRegText              #  ;A5 A6 : A7
		nop
		
		li $t5,'g'
		li $t6,'p'
		lw $t7,12($sp)
		jal ShowRegText              #  ;A5 A6 : A7
		nop
		
		li $t5,'t'
		li $t6,'p'
		lw $t7,16($sp)
		jal ShowRegText             #   ;A5 A6 : A7
		nop
		
		jal NewLine         
		nop

		li $t5,'a'
		li $t6,'0'
		lw $t7,40($sp)
		jal ShowReg              #  ;A5 A6 : A7
		nop
		lw $t7,44($sp)
		jal ShowReg             #   ;A5 A6 : A7      
		nop
		lw $t7,48($sp)
		jal ShowReg              #  ;A5 A6 : A7      
		nop
		lw $t7,52($sp)
		jal ShowReg             #   ;A5 A6 : A7      
		nop
		lw $t7,56($sp)
		jal ShowReg            #    ;A5 A6 : A7      
		nop
		lw $t7,60($sp)
		jal ShowReg             #   ;A5 A6 : A7      
		nop
		lw $t7,64($sp)
		jal ShowReg             #   ;A5 A6 : A7      
		nop
		lw $t7,68($sp)
		jal ShowReg               # ;A5 A6 : A7
		nop
		jal NewLine      
		nop
		li $t5,'s'
		li $t6,'0'
		lw $t7,32($sp)
		jal ShowReg               # ;A5 A6 : A7
		nop
		lw $t7,36($sp)
		jal ShowReg              #  ;A5 A6 : A7
		nop
		lw $t7,72($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,76($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,80($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,84($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,88($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,92($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,96($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,100($sp)
		jal ShowReg               # ;A5 A6 : A7
		nop
		lw $t7,104($sp)
		jal ShowReg            #    ;A5 A6 : A7
		nop
		lw $t7,108($sp)
		jal ShowReg            #    ;A5 A6 : A7
		nop
		jal NewLine      
		nop
		
		li $t5,'t'
		li $t6,'0'
		lw $t7,20($sp)
		jal ShowReg          #      ;A5 A6 : A7
		nop
		lw $t7,24($sp)
		jal ShowReg           #     ;A5 A6 : A7
		nop
		lw $t7,28($sp)
		jal ShowReg            #    ;A5 A6 : A7
		nop
		lw $t7,112($sp)
		jal ShowReg             #   ;A5 A6 : A7
		nop
		lw $t7,116($sp)
		jal ShowReg              #  ;A5 A6 : A7
		nop
		lw $t7,120($sp)
		jal ShowReg               # ;A5 A6 : A7
		nop
		lw $t7,124($sp)
		jal ShowReg                #;A5 A6 : A7
		nop
		jal NewLine        
		nop
    popAll
    jr $ra
	nop


ShowRegTextB:
	push $ra
	push $a0
	push $a1
	push $a3
		jal ShowRegText
		nop
	pop $a3
	pop $a1
	pop $a0
	pop $ra
	jr $ra
	nop

ShowRegText:            #    ;A5 A6 : A7
  # addi sp,sp,-4
  # sw ra,0($sp)
  push $ra
     move $a1,$t5
     jal PrintChar
	 nop
     move $a1,$t6
     jal PrintChar
	 nop
  j ShowRegB	
	nop
	
ShowReg:            #    ;A5 A6 : A7
	push $ra
  #; addi sp,sp,-4
  #; sw ra,0($sp)
     move $a1,$t5
     jal PrintChar
	 nop
     move $a1,$t6
     jal ShowHexChar
	 nop
ShowRegB:            #   h ;A5 A6 : A7
     li $a1,':'
    jal PrintChar
	nop
    move $a3,$t7
    jal ShowHex4
	nop
    li $a1,' '
    jal PrintChar
	nop
    addi $t6,$t6,1
	pop $ra
  #; lw ra,0($sp)
	#; addi sp,sp,4
  jr $ra
  nop
	
ShowHex4:
  addi $sp,$sp,-4
  sw $ra,0($sp)    
  li $t4,8
ShowHex4Again:  
        srl $a1,$a3,28
        sll $a3,$a3,4
        jal ShowHexChar
		nop
      addi $t4,$t4,-1
      bne $t4,$zero,ShowHex4Again
	  nop
  lw $ra,0($sp)
  addi $sp,$sp,4
  jr $ra
  nop
  
ShowHex2:
	push $ra
	pushAs
		li $t4,2
ShowHex2Again:  
			move $a1,$a3
			srl $a1,$a3,4
			sll $a3,$a3,4
			
			jal ShowHexChar
			nop
		  addi $t4,$t4,-1
		  bne $t4,$zero,ShowHex2Again
		  nop
	popAs
	pop $ra
	jr $ra
	nop
ShowHexChar:
	push $ra
	pushAs
	push $t0
		addi $sp,$sp,-4
		sw $ra,0($sp)
		andi $a1,$a1,0xF
		addi $a1,$a1,'0'
		li $t0,':'
		blt $a1,$t0,ShowHexCharOk
		nop
		addi $a1,$a1,7
ShowHexCharOk:
		jal PrintChar
		nop
		lw $ra,0($sp)
		addi $sp,$sp,4
	pop $t0
	popAs
	pop $ra
	jr $ra
	nop

#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
MemDumpNoLabel:
	pushAll
	j MemDumpb
	nop
MemDump:
	pushAll
		move $a3,$t7
		pushAs
			jal ShowHex4	
			nop
			li $a1,':'
			jal PrintChar
			nop
		popAs
MemDumpb:
MemDumpNextLine:		
		jal NewLine
		nop
		li $t5,8
MemDumpAgain:
		lb $a3,($t7)
		jal ShowHex2
		nop
		li $a1,' '
		jal PrintChar
		nop
		addi $t7,$t7,1
		addi $t5,$t5,-1
		bne $t5,$zero,MemDumpAgain
		nop
		
		addi $t7,$t7,-8
		li $t5,8
MemDumpAgainChar:
		lb $a1,($t7)
		li $a2,32
		blt $a1,$a2,MemDumpAgainCharBad
		nop
		li $a2,128
		bgt $a1,$a2,MemDumpAgainCharBad
		nop
		j MemDumpAgainCharOk
		nop
MemDumpAgainCharBad:				
		li $a1,'.'
MemDumpAgainCharOk:		
		jal PrintChar
		nop
		addi $t7,$t7,1
		addi $t5,$t5,-1
		bne $t5,$zero,MemDumpAgainChar
		nop
		
		addi $t6,$t6,-1
		bne $t6,$zero,MemDumpNextLine
		nop
		jal NewLine 
		nop
	popAll
	jr $ra
	nop