Hello everyone I am having trouble figuring this out, the question wants me to give the value of the line of code in a binary value of the offset field not too sure what to do please help.
add $t0, $zero, $zero
addi $a0, $zero, 21
loop:
beq $a0, $zero, end
add $t0, $t0, $a0
addi $a0, $a0, -3
j loop
end
For beq $a0, $zero, end give the binary value of the offset field. Briefly explain.
Related
I was trying to let MMIO output display some text like "please enter" before we type input. Can someone help pls?
Read: lui $t0, 0xffff
Loop1: lw $t1, 0($t0)
andi $t1,$t1,0x0001
beq $t1,$zero,Loop1
lw $v0, 4($t0)
jr $ra
Write: lui $t0, 0xffff
la $t2, text
Loop2: lw $t1, 8($t0)
andi $t1,$t1,0x0001
beq $t1,$zero,Loop2
sw $t2, 12($t0)
sw $a0, 12($t0)
jr $ra
Here is my read loop and write loop. In the last part of write loop, "text" is just some random words I hope to display first. This code is not working and whatever I typed, in the output window there's just 1s.
To clear my questions, what I was trying to do is:
mmio output window: text(like enter the character please)
input window: start to input something
I am a newcomer to MIPS and I am confused with the following 3 operations when it comes to accessing elements in an array. For example, if I want to change the value of an integer array at index 1 to 6 and right now I only get $s0 for the base address of the array, A[], then what should I do? Code example is like this:
addi $t0, $zero, 4
add $s0, $s0, $t0
addi ($s0), $zero, 6
or
addi $t0, $zero, 4
addu $s0, $s0, $t0
addi ($s0), $zero, 6
or
addi $s0, $s0, 4
addi ($s0), $zero, 6
Could you explain the reason and point out special cases as well.
I was wondering if anyone can help in a simple solution. I have a program in assembly that counts decimals from 0-31 and counts in binary beginning from the 5th left digit. I want to transform the program to count 0-31 in binary and show it in console in normal count starting from the right digit. Here's the first code:
main:
addi $9,$0,27 #example number
addi $10,$0,5
addi $2,$0,1
L1:
and $4,$9,$2
syscall
srl $9,$9,1
addi $10,$10,-1
nbe $10,$0,L1
end
Thank you in advance!
Just found it:
.data
.text
main:
addi $9,$0,23
addi $10,$0,5
addi $2,$0,1
sll $8,$2,4
Loop1:
and $4,$8,$9
srl $4,$4,4
syscall
sll $9,$9,1
addi $10,$0,-1
bne $10,$0, Loop1
.end main
I am new to MIPS trying to figure out Branches and Switches. All I want to do is set switch 0 to add and switch 1 to subtract. Can someone help and explain what I am doing wrong because every video I watch does not help. Every time I run the program I previously had, all it did was run the add: switch over and over again.
li $a0, 2
li $a1, 1
main:
li $s0, 0xf0100000
li $s1, 0b00000001
li $s2, 0b00000010
start:
lw $t0, 0($s0)
beq <------ This is what I don't understand
nop
add:
addu $v0, $a0, $a1
j start
nop
subtract:
subu $v0, $a0, $a1
j start
nop
I'm very confused about a question in a university past paper. It is as follows:
What is the value in register $s1 after executing the following piece of MIPS
assembly code?
li $t0, 0x1
li $s0, 0x0
li $s1, 0xa5a5a5a5
loop: and $t1, $t0, $s1
beq $t1, $zero, skip
addi $s0, $s0, 1
skip: sll $t0, $t0, 1 # Shift left logical
bne $t0, $zero, loop
(a) 0x10
(b) 0xa5a5a5a5
(c) 0x0
(d) 0x5a5a5a5a
(e) 0x1
The given answer is A - now, as far as I'm aware, the value of $s1 is not changed after its initial declaration - so how is this the case? I'd have thought it would be B?
This shows the QTSpim:
This shows the PCSpim: