I'm still getting these errors tho.

I've cleaned it up. You'll have to see if it compiles or not.

You'll need to finish the robot falls conditionals and switch( robot_state) code.

Good Night and good luck on your finals!

.data # variable declarations follow this line
iSAFE: 1
iCHASM: 2
iTRAP: 3
iDESTINATION: 4

maze: .space 144 # 9x9 stored in a 16x9 buffer 
robot_x: .word 0
robot_y: .word 0
robot_m_x: .word 0
robot_m_y: .word 0

robot_instructions: .space 256


MsgRS1: .asciiz "Robot is at a safe place\n" 
MsgRS2: .asciiz "Robot falls into Chasm\n"
MsgRS3: .asciiz "Robot falls into the trap\n"
MsgRS4: .asciiz "Robot reaches Destination\n"
MsgRS5: .asciiz "Robot fails to reach Destination\n"
MsgFinal:	.asciiz: "Robot final location X: "
MsgY:		.asciiz " Y: "
MsyCR:		.asciiz "\n"
MsgRobotState:  .asciiz  "Robot State: \n"
MsgFallenChasm:  .asciiz  "Robot has fallen into a chasm\n"
MsgFallenTrap:   .asciiz  "Robot has fallen into a trap\n"
MsgReachedDestination:  .asciiz  "Robot has reached Destination\n"
MsgSafePlace:    .asciiz  "Robot is at a safe place\n"
MsgFallsChasm:	.asciiz   "Robot falls into Chasm\n"
MsgFallsTrap:   .asciiz   "Robot falls into the trap\n"
MsgReachesDestination: .asciiz "Robot reaches Destination\n"
MsgFailsDestination:  .asciiz "Robot fails to reach Destination\n"


.text # CODE SECTION OF ASM FILE

#main:
li $v0,30 # Get time
syscall # CMD: Get Time
# $a0 = lower 32-bits, $a1=upper 32-bits

# Seed RNG (Random Number Generator)
move $a1,$a0 # get lower 32-bit time as seed
li $a0,0 # Rng#0
syscall # CMD: Seed the RNG


# Clear Entire Maze Array

la $t0, maze # load address of maze
li $t3, 0
li $t1, 144

clr: # repeat if not finished yet.
	la $t0, maze # base address
	li $t3, 2 				# maze[i] = 2
	sb $t3, 0($t0) 
	add $t0, $t0, 1 # address++
	add $t1, $t1, -1 # count--
	bgtz $t1, clr

	# Setup variables
	la $t0, maze # base address

	li $a1,1   # iSAFE: 
	sb $t1,0x11($t0) # maze[1][1] = 1;

	li $a1,2   # iCHASM:
	sb $t1,0, 0x12($t0) # maze[1][2] = 2
	sb $t1,0x24($t0) # maze[2][4] = 2

	li $a1, 3   #iTRAP: 
	sb $t1, 0x23($t0) # maze[2][3]
	sb $t1, 0x34($t0) # maze[3][4]

	li $a1, 4   #iDESTINATION: # maze[3][2] = 4;
	sb $t1, 0x32($t0) # 1 x 16 + 4

		# robot_x = 1
	la $t0,robot_x
	li $t1,1
	sw $t1,0($t0)

		# robot_y = 2
	la $t0,robot_y
	li $t1,2
	sw $t1,0($t0)

	# init robot_state = 5
	la $t0,robot_state
	li $t1,5
	sw $t1,0($t0)

	la	$t7,robot_instructions		# index
	li	$t6,64

MoveLoop:


	# Get a Random #

	li $a0, 0 # Rng#
	li $a1, 4 # rand() %4 {0...3}
	li $v0, 42
	syscall # Get RNG
	# $a0 = {0...3}
	add $a0, $a0, 1 # {1...4}

	sw	$a0,0($t7)		# robot_instructions[i] = rnd{ 1...4 }

	add	$a0, $a0, -1
	bne	RJump

		# case 1: MOVE

	la $t1,robot_mx
	la $t0,robot_x

	lw	$t2,0($t1)
	sw	$t2,0($t0)		# robot_x = robot_m_x

	la	$t1,robot_m_y
	la	$t0,robot_y
	lw	$t2,0($t1)
	add	$t2,$t2,1
	sw	$t2,0($t0)		# robot_y = robot_m_y + 1

	jr	PrtOut

	
RJump:
	add	$a0, $a0, -1
	bne	RLeft

		# case 2: Jump

	la $t1,robot_mx
	la $t0,robot_x

	lw	$t2,0($t1)
	sw	$t2,0($t0)		# robot_x = robot_m_x

	la	$t1,robot_m_y
	la	$t0,robot_y
	lw	$t2, 0($t1)
	add	$t2, $t2, 2
	sw	$t2, 0($t0)		# robot_y = robot_m_y + 2

	jr	PrtOut


RLeft:
	add	$a0, $a0, -1
	bne	RRight

		# case 3: Left

	la $t1,robot_mx
	la $t0,robot_x
	lw	$t2,0($t1)
	add	$t2, $t2, -1
	sw	$t2,0($t0)		# robot_x = robot_m_x - 1


	jr	PrtOut

RRight:

	la $t1,robot_mx
	la $t0,robot_x
	lw	$t2,0($t1)
	add	$t2, $t2, 1
	sw	$t2,0($t0)		# robot_x = robot_m_x + 1

	#	Process new robot posit5ions!

PrtOut:

		#	System.out.println("Robot final location X: " + robot_x + " Y: " + robot_y);

	la $a0, MsgFinal
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_x
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: Seed the RNG

	la $a0, MsgY
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_y
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: Seed the RNG

	la $a0, MsgCR
	li $v0, 4 				# specify Print String service
	syscall # print heading

		#	System.out.println ("Robot State: ");




#  <---   Insert conditional logic here



# <---  Insert switch(robot_state) here


    add $t7, $t7, 4
	add $t6, $t6, -1
	jgz  MoveLoop		# Loop 64 times


	jr $ra # return

Thank you so much for your help.

Double check the comments.
There are cut'n'paste mistakes
Replace this code near end of file...

PrtOut:

		#	System.out.println("Robot final location X: " + robot_x + " Y: " + robot_y);

	la $a0, MsgFinal
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_x
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: print robot x integer

	la $a0, MsgY
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_y
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: print robot Y integer

	la $a0, MsgCR
	li $v0, 4 				# specify Print String service
	syscall # print heading

		#	System.out.println ("Robot State: ");

Error in assembly line 69 position 2: "sb": Too many or incorrectly formatted operands. Expected: sb $1,-100($2)
Error in assembly line 73 position 2: "sb": Too many or incorrectly formatted operands. Expected: sb $1,-100($2)
Error in assembly line 112 position 2: "bne": Too few or incorrectly formatted operands. Expected: bne $1,$2,label
Error in assembly line 128 position 5: "PrtOut": operand is of incorrect type
Error in assembly line 133 position 2: "bne": Too few or incorrectly formatted operands. Expected: bne $1,$2,label
Error in assembly line 149 position 5: "PrtOut": operand is of incorrect type
Error in assembly line 154 position 2: "bne": Too few or incorrectly formatted operands. Expected: bne $1,$2,label
Error in assembly line 165 position 5: "PrtOut": operand is of incorrect type
Error in assembly line 217 position 2: "jgz" directive cannot appear in text segment
Assemble: operation completed with errors.

Could you start me off with the first conditional / switch statement, so I know I'm heading in the right direction.

I know its too late now but this morning after some sleep noticed some mistakes....

#MsyCR:		.asciiz "\n"
MsgCR:		.asciiz "\n"

Typo...

Type here

#sb $t1,0, 0x12($t0) # maze[1][2] = 2
  sb $t1, 0x12($t0) # maze[1][2] = 2

Wrong code

RJump:
	add	$a0, $a0, -1
	bne	RLeft

...Corrected...

RJump:
	add	$a0, $a0, -1
	bnez	RLeft

Same with the other switch cases! bnez instead of bne
bne is for comparing two registers to each other!

#	bne	RLeft
	bnez	RLeft

#	bne	RRight
	bnez	RRight
#	jgz  MoveLoop		# Loop 64 times
	jgtz  MoveLoop		# Loop up 63 times for 64 loops

# <--- Insert conditional logic here
Print the starting string "Robot State:"

if (( (robot_x == 1) && (robot_y == 2)) || ( (robot_x == 2) && (robot_y == 4)) )
{
  System.out.println("Robot has fallen into a chasm");
   robot_state = 2;
  }

You already know how to get a value within memory

la $t0,robot_x
  lw $t0,0($t0)           # $t0 = robot_x
  la $t5,robot_y
  lw $t5,0($t1)           # $t5 = robot_y

# since you have many comparisons of those to values to 1,2,3,4
# Using $t1 ... $t4 since they look similar to 1...4
  li  $t1,1
  li  $t2,2
  li  $t3,3
  li  $t4,4

  # so now use the register to register compares
  # Ref:  if (( (robot_x == 1) && (robot_y == 2)) || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t1,LineA3   # jump if robot_x <> 1
  beq $t5,$t2,LineA3   # jump if robot_y == 2

LineA3:                                              # || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t2,$LineB    #jump if robot_x <> 2
  bne $t5,$t4,$LineB    #jump if robot_y <> 4

LineAOK:   # SUCCESS

  la $a0, MsgFallenChasm
  li $v0, 4 				# specify Print String service
  syscall # print heading
  
  la $a0, robot_state
  sw $t2,0($a0)                          # robot_state = 2

  jr  Done:

  # _______________
  # Next conditional line
  # Ref: else if(( (robot_x == 2) && (robot_y == 3)) || ((robot_x == 3) && (robot_y == 4)))
LineB:

Done:

# <--- Insert switch(robot_state) here
Do the code the same way as the four move states after the random was done above only this time you're printing not calculating new coordinates. I personally would use a lookup table where the robot_state is used as in index into a table of string addresses, and then that address is used to print.

hey thanks I already turned it in this morning. it wouldnt compile I got a 70 tho..I can't complain.. And I didn't finish the code.

No problem. Thanks for letting me know. I was kind of curious.
I take it, no chance emailing the final version to your instructor?

Well, did you review the final notes and your code and figure out what was wrong? And how to finish it? That's how one learns! Even after they don't have to. They pick at it, figure out things without the time restraint and stress.

Like for example...

bne $t0,$t1,LineA3   # jump if robot_x <> 1
#  beq $t5,$t2,LineA3   # jump if robot_y == 2
  beq $t5,$t2,LineAOK   # jump if robot_y == 2

LineA3:                                              # || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t2,$LineB    #jump if robot_x <> 2
  bne $t5,$t4,$LineB    #jump if robot_y <> 4

LineAOK:   # SUCCESS

Upon review, I just noticed a mistake from this mornings post.
Still learning! Of course if I was working live with tools instead of in my head with an editor, some of the issues would have been exposed earlier. But again, not my assignment and as I tell my kids. I can't do your homework for you. I can only nudge you in the correct directions. (though I must admit, on this particular task I think I nudged a lot more then I should have!)

.data # variable declarations follow this line
iSAFE: 1
iCHASM: 2
iTRAP: 3
iDESTINATION: 4

maze: .space 144 # 9x9 stored in a 16x9 buffer 
robot_x: .word 0
robot_y: .word 0
robot_m_x: .word 0
robot_m_y: .word 0

robot_instructions: .space 256


MsgRS1: .asciiz "Robot is at a safe place\n" 
MsgRS2: .asciiz "Robot falls into Chasm\n"
MsgRS3: .asciiz "Robot falls into the trap\n"
MsgRS4: .asciiz "Robot reaches Destination\n"
MsgRS5: .asciiz "Robot fails to reach Destination\n"
MsgFinal:   .asciiz: "Robot final location X: "
MsgY:       .asciiz " Y: "
MsyCR:      .asciiz "\n"
MsgRobotState:  .asciiz  "Robot State: \n"
MsgFallenChasm:  .asciiz  "Robot has fallen into a chasm\n"
MsgFallenTrap:   .asciiz  "Robot has fallen into a trap\n"
MsgReachedDestination:  .asciiz  "Robot has reached Destination\n"
MsgSafePlace:    .asciiz  "Robot is at a safe place\n"
MsgFallsChasm:  .asciiz   "Robot falls into Chasm\n"
MsgFallsTrap:   .asciiz   "Robot falls into the trap\n"
MsgReachesDestination: .asciiz "Robot reaches Destination\n"
MsgFailsDestination:  .asciiz "Robot fails to reach Destination\n"


.text # CODE SECTION OF ASM FILE

#main:
li $v0,30 # Get time
syscall # CMD: Get Time
# $a0 = lower 32-bits, $a1=upper 32-bits

# Seed RNG (Random Number Generator)
move $a1,$a0 # get lower 32-bit time as seed
li $a0,0 # Rng#0
syscall # CMD: Seed the RNG


# Clear Entire Maze Array

la $t0, maze # load address of maze
li $t3, 0
li $t1, 144

clr: # repeat if not finished yet.
    la $t0, maze # base address
    li $t3, 2               # maze[i] = 2
    sb $t3, 0($t0) 
    add $t0, $t0, 1 # address++
    add $t1, $t1, -1 # count--
    bgtz $t1, clr

    # Setup variables
    la $t0, maze # base address

    li $a1,1   # iSAFE: 
    sb $t1,0x11($t0) # maze[1][1] = 1;

    li $a1,2   # iCHASM:
    sb $t1,0, 0x12($t0) # maze[1][2] = 2
    sb $t1,0x24($t0) # maze[2][4] = 2

    li $a1, 3   #iTRAP: 
    sb $t1, 0x23($t0) # maze[2][3]
    sb $t1, 0x34($t0) # maze[3][4]

    li $a1, 4   #iDESTINATION: # maze[3][2] = 4;
    sb $t1, 0x32($t0) # 1 x 16 + 4

        # robot_x = 1
    la $t0,robot_x
    li $t1,1
    sw $t1,0($t0)

        # robot_y = 2
    la $t0,robot_y
    li $t1,2
    sw $t1,0($t0)

    # init robot_state = 5
    la $t0,robot_state
    li $t1,5
    sw $t1,0($t0)

    la  $t7,robot_instructions      # index
    li  $t6,64

MoveLoop:


    # Get a Random #

    li $a0, 0 # Rng#
    li $a1, 4 # rand() %4 {0...3}
    li $v0, 42
    syscall # Get RNG
    # $a0 = {0...3}
    add $a0, $a0, 1 # {1...4}

    sw  $a0,0($t7)      # robot_instructions[i] = rnd{ 1...4 }

    add $a0, $a0, -1
    bnez    RJump

        # case 1: MOVE

    la $t1,robot_mx
    la $t0,robot_x

    lw  $t2,0($t1)
    sw  $t2,0($t0)      # robot_x = robot_m_x

    la  $t1,robot_m_y
    la  $t0,robot_y
    lw  $t2,0($t1)
    add $t2,$t2,1
    sw  $t2,0($t0)      # robot_y = robot_m_y + 1

    jr  PrtOut


RJump:
    add $a0, $a0, -1
    bnez    RLeft

        # case 2: Jump

    la $t1,robot_mx
    la $t0,robot_x

    lw  $t2,0($t1)
    sw  $t2,0($t0)      # robot_x = robot_m_x

    la  $t1,robot_m_y
    la  $t0,robot_y
    lw  $t2, 0($t1)
    add $t2, $t2, 2
    sw  $t2, 0($t0)     # robot_y = robot_m_y + 2

    jr  PrtOut


RLeft:
    add $a0, $a0, -1
    bnez    RRight

        # case 3: Left

    la $t1,robot_mx
    la $t0,robot_x
    lw  $t2,0($t1)
    add $t2, $t2, -1
    sw  $t2,0($t0)      # robot_x = robot_m_x - 1


    jr  PrtOut

RRight:

    la $t1,robot_mx
    la $t0,robot_x
    lw  $t2,0($t1)
    add $t2, $t2, 1
    sw  $t2,0($t0)      # robot_x = robot_m_x + 1

    #   Process new robot posit5ions!

PrtOut:
        #   System.out.println("Robot final location X: " + robot_x + " Y: " + robot_y);

    la $a0, MsgFinal
    li $v0, 4               # specify Print String service
    syscall # print heading

    la $t0,robot_x
    lw $a0,0($t0)
    li $v0, 1
    syscall # CMD: print robot x integer

    la $a0, MsgY
    li $v0, 4               # specify Print String service
    syscall # print heading

    la $t0,robot_y
    lw $a0,0($t0)
    li $v0, 1
    syscall # CMD: print robot Y integer

    la $a0, MsgCR
    li $v0, 4               # specify Print String service
    syscall # print heading

        #   System.out.println ("Robot State: ");



    add $t7, $t7, 4
    add $t6, $t6, -1
    jgz  MoveLoop       # Loop 64 times


    jr $ra # return 

I left it like that. Cause I dont understand assembly and I hope I never have to see it again unless we're really taught about it.But do you know what the end product would look like..I just wanna put it in mars and see how it would have ran..Mine didnt run..There were too many errors..

You're really close! If all your finals are done. Look at this mornings posting of errors, and make those corrections. Then look at the 1st conditional test. I called it LineA, and look at its comments. Along with the correction to it, I did about three minutes ago!

Look at it this way. It's an incomplete project. If you want a win in your own self-esteem, spend some time on it this weekend and try to figure it out.

.data
maze:.word 0 0 0 0 0 0 0 0 0 0 0 2 1 1 2 2 1 1 1 0 0 1 2 1 1 1 3 3 1 0
0 2 1 1 3 1 1 1 1 0 0 2 1 3 1 1 1 1 1 0 0 1 1 2 1 1 3 1 1 0 0 1 1 1 1
1 1 3 1 0 0 1 1 1 1 2 1 1 4 0 0 1 1 1 1 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0
inst:.word 1 4 2 1 3 2 1 4 1 2 1 3 1 1
swi1:.word 0 : 4
swi2:.word 0 : 5
swi4:.word 0 : 7

space:.asciiz " "
rus1:.asciiz "Robot final location X: "
rus2:.asciiz " Y: "
rus3:.asciiz " Robot: "
sat1:.asciiz "Robot is at a safe place"
sat2:.asciiz "Robot reaches Destination"
sat3:.asciiz "Robot falls into Chasm"
sat4:.asciiz "Robot falls into the trap "
sat5:.asciiz "robot go to out side of table"
sat6:.asciiz "Robot fails to reach Destination"
.text
main:
la $a0, maze
la $a1, inst
li $s0, 0
li $s1, 0
li $s2, 0
li $s3, 1
li $s4, 0
li $s5, 0
li $s6, 0
li $s0, 1
li $s1, 1

la $s7, swi2
la $t0, sw2_L1
sw $t0, 4($s7)
la $t0, sw2_L2
sw $t0, 8($s7)
la $t0, sw2_L3
sw $t0, 12($s7)
la $t0, sw2_L4
sw $t0, 16($s7)

la $s7, swi4
la $t0, sw4_L1
sw $t0, 4($s7)
la $t0, sw4_L2
sw $t0, 8($s7)
la $t0, sw4_L3
sw $t0, 12($s7)
la $t0, sw4_L4
sw $t0, 16($s7)
la $t0, sw4_L5
sw $t0, 20($s7)
la $t0, sw4_L6
sw $t0, 24($s7)


loop:
sll $t1, $s6, 2
add $t2, $t1, $a1
lw $t0, 0($t2)
beq $t0, $zero, loop_exit


sw2:
la $s7, swi2
sll $t3, $t0, 2
add $t3, $t3, $s7
lw $t4, 0($t3)
jr $t4
sw2_L1:
li $t8, 0
bne $s2, $t8, l1
addi $s1,$s1, 1
j l1_ex
l1:
li $t8, 1
bne $s2, $t8, l2
addi $s0,$s0, 1
j l1_ex
l2:
li $t8, 2
bne $s2, $t8, l3
addi $s1,$s1, -1
j l1_ex
l3:
addi $s0,$s0, -1
l1_ex:
sw2_L2:
li $t8, 0
bne $s2, $t8, l21
addi $s1,$s1, 1
j l21_ex
l21:
li $t8, 1
bne $s2, $t8, l22
addi $s0,$s0, 1
j l21_ex
l22:
li $t8, 2
bne $s2, $t8, l23
addi $s1,$s1, -1
j l21_ex
l23:
addi $s0,$s0, -1
l21_ex:
j sw2_exit
sw2_L3:
bne $s2, $zero, sw2_L3_else
li $s2, 3
j sw2_exit
sw2_L3_else:
addi $s2, $s2 , -1
j sw2_exit
sw2_L4:
li $t5, 3
bne $s2, $t5, sw2_L4_else
li $s2, 0
j sw2_exit
sw2_L4_else:
addi $s2, $s2, 1
j sw2_exit
sw2_exit:

li $t8, 0
sll $t8, $s1, 3
add $t8, $t8, $s1
add $t8, $t8, $s1
add $t8, $t8, $s0
sll $t8, $t8, 2
la $t3, maze
add $t8, $t3, $t8
lw $t3, 0($t8)
slti $t4, $t3, 0
bne $t3, 1, loop_exit
addi $s6, $s6, 1
j loop

loop_exit:


la $a0, rus1
li $v0, 4
syscall
add $a0, $s0, $zero
li $v0, 1
syscall
la $a0, rus2
li $v0, 4
syscall
add $a0, $s1, $zero
li $v0, 1
syscall
la $a0, rus3
li $v0, 4
syscall
sw4:
la $s7, swi4
sll $t3, $s3, 2
add $t3, $t3, $s7
lw $t4, 0($t3)
jr $t4

sw4_L1:
la $a0, sat1
li $v0, 4
syscall
j sw4_exit
sw4_L2:
la $a0, sat2
li $v0, 4
syscall
j sw4_exit
sw4_L3:
la $a0, sat3
li $v0, 4
syscall
j sw4_exit
sw4_L4:
la $a0, sat4
li $v0, 4
syscall
j sw4_exit
sw4_L5:
la $a0, sat5
li $v0, 4
syscall
j sw4_exit
sw4_L6:
la $a0, sat6
li $v0, 4
syscall
j sw4_exit
sw4_exit:

li $v0, 10
syscall

jr $ra # return


I did this at the lab today..but I liked the code we did better

It looks like you're just calling print functions!

Do you know why this error occurs?


Error in praccode line 208 position 1: "sb": Too many or incorrectly formatted operands. Expected: sb $1,-100($2)
Error in praccode line 209 position 1: "sb": Too many or incorrectly formatted operands. Expected: sb $1,-100($2)
Assemble: operation completed with errors.

So what are in lines 207 to 210 in your editor?

Did you miss a correction? Note the arrow.
But I see another mistake. We load an immediate value into $a1 but save $t1 So need to change those immediate loads!

#li $a1,1 # iSAFE: 
li $t1,1 # iSAFE: 
sb $t1,0x11($t0) # maze[1][1] = 1;

#li $a1,2 # iCHASM:
li $t1,2 # iCHASM:
#sb $t1,0, 0x12($t0) # maze[1][2] = 2
sb $t1, 0x12($t0) # maze[1][2] = 2       <---------------
sb $t1,0x24($t0) # maze[2][4] = 2

#li $a1, 3 #iTRAP: 
li $t1, 3 #iTRAP: 
sb $t1, 0x23($t0) # maze[2][3]
sb $t1, 0x34($t0) # maze[3][4]

#li $a1, 4 #iDESTINATION: # maze[3][2] = 4;
li $t1, 4 #iDESTINATION: # maze[3][2] = 4;
sb $t1, 0x32($t0) # 1 x 16 + 4

Error in Assembly2 line 117 position 2: "bnez": Too few or incorrectly formatted operands. Expected: bnez $1,label
Error in Assembly2 line 133 position 5: "PrtOut": operand is of incorrect type
Error in Assembly2 line 138 position 2: "bnez": Too few or incorrectly formatted operands. Expected: bnez $1,label
Error in Assembly2 line 154 position 5: "PrtOut": operand is of incorrect type
Error in Assembly2 line 159 position 2: "bnez": Too few or incorrectly formatted operands. Expected: bnez $1,label
Error in Assembly2 line 170 position 5: "PrtOut": operand is of incorrect type
Error in Assembly2 line 238 position 3: "jr": Too many or incorrectly formatted operands. Expected: jr $1
Error in Assembly2 line 248 position 2: "jgz" directive cannot appear in text segment
Assemble: operation completed with errors.

I'm still get these errors

can you post the entire code so I have a reference.

.data # variable declarations follow this line
iSAFE: 1
iCHASM: 2
iTRAP: 3
iDESTINATION: 4

maze: .space 144 # 9x9 stored in a 16x9 buffer 
robot_x: .word 0
robot_y: .word 0
robot_m_x: .word 0
robot_m_y: .word 0

robot_instructions: .space 256


MsgRS1: .asciiz "Robot is at a safe place\n" 
MsgRS2: .asciiz "Robot falls into Chasm\n"
MsgRS3: .asciiz "Robot falls into the trap\n"
MsgRS4: .asciiz "Robot reaches Destination\n"
MsgRS5: .asciiz "Robot fails to reach Destination\n"
MsgFinal:	.asciiz "Robot final location X: "
MsgY:		.asciiz " Y: "
MsyCR:		.asciiz "\n"
MsgRobotState:  .asciiz  "Robot State: \n"
MsgFallenChasm:  .asciiz  "Robot has fallen into a chasm\n"
MsgFallenTrap:   .asciiz  "Robot has fallen into a trap\n"
MsgReachedDestination:  .asciiz  "Robot has reached Destination\n"
MsgSafePlace:    .asciiz  "Robot is at a safe place\n"
MsgFallsChasm:	.asciiz   "Robot falls into Chasm\n"
MsgFallsTrap:   .asciiz   "Robot falls into the trap\n"
MsgReachesDestination: .asciiz "Robot reaches Destination\n"
MsgFailsDestination:  .asciiz "Robot fails to reach Destination\n"


.text # CODE SECTION OF ASM FILE

#main:
li $v0,30 # Get time
syscall # CMD: Get Time
# $a0 = lower 32-bits, $a1=upper 32-bits

# Seed RNG (Random Number Generator)
move $a1,$a0 # get lower 32-bit time as seed
li $a0,0 # Rng#0
syscall # CMD: Seed the RNG


# Clear Entire Maze Array

la $t0, maze # load address of maze
li $t3, 0
li $t1, 144

clr: # repeat if not finished yet.
	la $t0, maze # base address
	li $t3, 2 				# maze[i] = 2
	sb $t3, 0($t0) 
	add $t0, $t0, 1 # address++
	add $t1, $t1, -1 # count--
	bgtz $t1, clr

	# Setup variables
	la $t0, maze # base address

#li $a1,1 # iSAFE: 
li $t1,1 # iSAFE: 
sb $t1,0x11($t0) # maze[1][1] = 1;

#li $a1,2 # iCHASM:
li $t1,2 # iCHASM:
#sb $t1,0, 0x12($t0) # maze[1][2] = 2
sb $t1, 0x12($t0) # maze[1][2] = 2    
sb $t1,0x24($t0) # maze[2][4] = 2

#li $a1, 3 #iTRAP: 
li $t1, 3 #iTRAP: 
sb $t1, 0x23($t0) # maze[2][3]
sb $t1, 0x34($t0) # maze[3][4]

#li $a1, 4 #iDESTINATION: # maze[3][2] = 4;
li $t1, 4 #iDESTINATION: # maze[3][2] = 4;
sb $t1, 0x32($t0) # 1 x 16 + 4

		# robot_x = 1
	la $t0,robot_x
	li $t1,1
	sw $t1,0($t0)

		# robot_y = 2
	la $t0,robot_y
	li $t1,2
	sw $t1,0($t0)

	# init robot_state = 5
	la $t0,robot_state
	li $t1,5
	sw $t1,0($t0)

	la	$t7,robot_instructions		# index
	li	$t6,64

MoveLoop:


	# Get a Random #

	li $a0, 0 # Rng#
	li $a1, 4 # rand() %4 {0...3}
	li $v0, 42
	syscall # Get RNG
	# $a0 = {0...3}
	add $a0, $a0, 1 # {1...4}

	sw	$a0,0($t7)		# robot_instructions[i] = rnd{ 1...4 }

	add	$a0, $a0, -1
	bnez	RJump

		# case 1: MOVE

	la $t1,robot_mx
	la $t0,robot_x

	lw	$t2,0($t1)
	sw	$t2,0($t0)		# robot_x = robot_m_x

	la	$t1,robot_m_y
	la	$t0,robot_y
	lw	$t2,0($t1)
	add	$t2,$t2,1
	sw	$t2,0($t0)		# robot_y = robot_m_y + 1

	jr	PrtOut

	
RJump:
	add	$a0, $a0, -1
	bnez	RLeft

		# case 2: Jump

	la $t1,robot_mx
	la $t0,robot_x

	lw	$t2,0($t1)
	sw	$t2,0($t0)		# robot_x = robot_m_x

	la	$t1,robot_m_y
	la	$t0,robot_y
	lw	$t2, 0($t1)
	add	$t2, $t2, 2
	sw	$t2, 0($t0)		# robot_y = robot_m_y + 2

	jr	PrtOut


RLeft:
	add	$a0, $a0, -1
	bnez	RRight

		# case 3: Left

	la $t1,robot_mx
	la $t0,robot_x
	lw	$t2,0($t1)
	add	$t2, $t2, -1
	sw	$t2,0($t0)		# robot_x = robot_m_x - 1


	jr	PrtOut

RRight:

	la $t1,robot_mx
	la $t0,robot_x
	lw	$t2,0($t1)
	add	$t2, $t2, 1
	sw	$t2,0($t0)		# robot_x = robot_m_x + 1

	#	Process new robot posit5ions!

PrtOut:
		#	System.out.println("Robot final location X: " + robot_x + " Y: " + robot_y);

	la $a0, MsgFinal
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_x
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: print robot x integer

	la $a0, MsgY
	li $v0, 4 				# specify Print String service
	syscall # print heading

	la $t0,robot_y
	lw $a0,0($t0)
	li $v0, 1
	syscall # CMD: print robot Y integer

	la $a0, MsgCR
	li $v0, 4 				# specify Print String service
	syscall # print heading

		#	System.out.println ("Robot State: ");

la $t0,robot_x
  lw $t0,0($t0)           # $t0 = robot_x
  la $t5,robot_y
  lw $t5,0($t1)           # $t5 = robot_y

# Using $t1 ... $t4 since they look similar to 1...4
  li  $t1,1
  li  $t2,2
  li  $t3,3
  li  $t4,4

  #  register to register compares
  # Ref:  if (( (robot_x == 1) && (robot_y == 2)) || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t1,LineA3   # jump if robot_x <> 1
  beq $t5,$t2,LineA3   # jump if robot_y == 2

LineA3:                                              # || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t2,$LineB    #jump if robot_x <> 2
  bne $t5,$t4,$LineB    #jump if robot_y <> 4

LineAOK:   # SUCCESS

  la $a0, MsgFallenChasm
  li $v0, 4 				# specify Print String service
  syscall # print heading
  
  la $a0, robot_state
  sw $t2,0($a0)                          # robot_state = 2

  jr  Done:

  # Next conditional line
  # Ref: else if(( (robot_x == 2) && (robot_y == 3)) || ((robot_x == 3) && (robot_y == 4)))
LineB:

Done:

    add $t7, $t7, 4
	add $t6, $t6, -1
	jgz  MoveLoop		# Loop 64 times


	jr $ra # return

Okay, have it. Go back edit and change

So that I can get line numbers![code=Asm]

So that I can get line numbers!

Line#117
# bnez RJump
bgrtz RJump

# jr PrtOut
jump PrtOut

Line138
# bnez RLeft
bgtz RLeft

# jr PrtOut
jump PrtOut

Line 159
# bnez RRight
bgtz RRight

# jr PrtOut
jump PrtOut

Line 248
# jgz MoveLoop
bgtz MoveLoop

put where?[code=Asm] where?

Its giving me diff errors now:


Error in Assembly2 line 117 position 2: "bgrtz" directive cannot appear in text segment
Error in Assembly2 line 133 position 2: "jump" directive cannot appear in text segment
Error in Assembly2 line 138 position 2: "bgtz": Too few or incorrectly formatted operands. Expected: bgtz $1,label
Error in Assembly2 line 154 position 2: "jump" directive cannot appear in text segment
Error in Assembly2 line 159 position 2: "bgtz": Too few or incorrectly formatted operands. Expected: bgtz $1,label
Error in Assembly2 line 170 position 2: "jump" directive cannot appear in text segment
Error in Assembly2 line 238 position 3: "jr": Too many or incorrectly formatted operands. Expected: jr $1
Error in Assembly2 line 248 position 2: "bgtz": Too few or incorrectly formatted operands. Expected: bgtz $1,label
Assemble: operation completed with errors.

Line 212

# System.out.println ("Robot State: ");

la $t0,robot_x
  lw $t0,0($t0)           # $t0 = robot_x
  la $t5,robot_y
#  lw $t5,0($t1)           # $t5 = robot_y
  lw $t5,0($t5)           # $t5 = robot_y

Line 229

#  register to register compares
  # Ref:  if (( (robot_x == 1) && (robot_y == 2)) || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t1,LineA3   # jump if robot_x <> 1
#  beq $t5,$t2,LineA3   # jump if robot_y == 2
  beq $t5,$t2,LineAOK   # jump if robot_y == 2

LineA3:                                              # || ( (robot_x == 2) && (robot_y == 4)) )
  bne $t0,$t2,$LineB    #jump if robot_x <> 2
  bne $t5,$t4,$LineB    #jump if robot_y <> 4

LineAOK:   # SUCCESS

Line 238

la $a0, robot_state
  sw $t2,0($a0)                          # robot_state = 2

#  jr  Done:
    jmp Done

  # Next conditional line
  # Ref: else if(( (robot_x == 2) && (robot_y == 3)) || ((robot_x == 3) && (robot_y == 4)))
LineB:

is it supposed to be .data? or main?

bgrtz"
bgtz No <r>

Instead of jump use just j

Sorry those bgtz 's should
have a $a0

Ex: if ($a0 > 0) then goto RJump

bgtz $a0, RJump
bgtz $a0, RLeft
bgtz $a0,RRight

so i replace bgtz to bgrtz

No
there is no bgrtz its a typo.

the line(s) should be

bgtz $a0, ______ <--- the function label that's there!

bgtz $a0, RJump
bgtz $a0, RLeft
bgtz $a0,RRight

that worked


Error in Assembly2 line 95 position 9: Symbol "robot_state" not found in symbol table.
Assemble: operation completed with errors.


Do i declare it in .data?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.