CS232mp3sol - .data dag : scan_done: xcoord : ycoord :...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
.data dag : .space 128 scan_done: .word 0 xcoord : .word 0 ycoord : .word 0 mystate : .word 0 # SPIMbot state .text main: li $t0, 0xa001 # enable scan and timer interrupts mtc0 $t0, $12 # set Status register li $t0, 128 # scan x coordinate li $t1, 128 # scan y coordinate li $t2, 200 # scan radius sll $t0, $t0, 16 # create scan circle sll $t1, $t1, 8 or $t0, $t0, $t1 or $t0, $t0, $t2 sw $t0, 0xffff0050($0) # save scan circle la $t0, dag sw $t0, 0xffff0054($0) # start scan scan_wait: lw $t0, scan_done # while(scan_done == 0) beq $t0, $0, scan_wait # ; // wait la $a0, dag # initialize argument registers lw $a1, 0xffff0054($0) # get root's offset li $a2, 0 addi $sp, $sp, -4 # grow stack sw $ra, 0($sp) # save $ra jal decodeAll # call decodeAll lw $ra, 0($sp) # restore $ra addi $sp, $sp, 4 # shrink stack jr $ra # return decode: # a0 = val andi $v0, $a0, 0xFF00 # v0 = second-least significant byte srl $v0, $v0, 8 # shift to least significant byte andi $a0, $a0, 0xFF # a0 = least significant byte li $v1, 0 # v1 = y = 0 li $t0, 0 # t0 = number of bits processed so far loop: beq $t0, 8, done # while(t0 < 8) sll $v1, $v1, 1 andi $t1, $a0, 1 or $v1, $v1, $t1 # srl $a0, $a0, 1 # a0 = a0 >> 1 addi $t0, $t0, 1 # t0++ j loop done: sw $v0, xcoord # save target x coordinate
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
sw $v1, ycoord
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/28/2011 for the course CS 232 taught by Professor Kumar during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 5

CS232mp3sol - .data dag : scan_done: xcoord : ycoord :...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online