Question

I'm learning MIPS assembly right now, and I want to figure out how to store values into certain a certain RAM adress,

This is what I have right now:

.global main

.text

.set noreorder

.ent main

main:
    lw $a0, 0x500
    sw $t0, 0($a0)          #set up contiguous memory
    lui $t0, 0x1122
    ori $t0, $t0, 0x3344
    lui $t1, 0x2233
    ori $t1, $t1, 0x4455
    lui $t2, 0x3344
    ori $t2 , $t2 , 0x5566
    lui $t3, 0x4455
    ori $t3 , $t3 , 0x6677
    lui $t4, 0x5566
    ori $t4 , $t4 , 0x7788
    lui $t5, 0x6677
    ori $t5 , $t5 , 0x8899
    lui $t6, 0x7788
    ori $t6 , $t6 , 0x99AA
    lui $t7, 0x8899
    ori $t7 , $t7 , 0xAABB
    lui $t8, 0x99AA
    ori $t8 , $t8 , 0xBBCC
    lui $t9, 0xAABB
    ori $t9 , $t9 , 0xCCDD
    nop
loop:
    nop
    b loop
    nop
    .end main

What I want to is set it up so that the values that I make (the 0x1122 ... etc) can be stored into contiguous RAM locations. The code I have right now keeps giving me this weird error?

CORE-E0003: Bus Exception. Unimplemented RAM memory access, from instruction at 0x9d0000d8

I'm using MPLAB 8.92

Was it helpful?

Solution

There's nothing weird about that error... but your code, well, that is kinda weird.

Tell me again what you think these lines are doing?

lw $a0, 0x500          #set up contiguous memory
sw $t0, 0($a0)

What I see is:

lw $a0, 0x500 # Load the *contents* of (invalid) memory address 0x00000500 into register $a0
sw $t0, 0($a0) # Store the (uninitialized) value in $t0 into the address pointed to by $a0

Note that even if the first line works, $a0 won't contain 0x00000500. It contains the value of the word that happens to be stored at memory address 0x00000500.

The problem is that 0x00000500 is not accessible by your code. As I understand, a MIPS processor has different modes, and the normal mode doesn't allow access to that segment of memory. That's why you would expect an error like "Unimplemented RAM memory access".

I think you may have to go back to your textbook for the right answer to your original problem. If, however, your only goal is what you said - "the values that I make (the 0x1122 ... etc) can be stored into contiguous RAM locations." - then this will do it, no code required. But probably not the way you expected or wanted...

.data
.byte 0x00
.byte 0x11
.byte 0x22
.byte 0x33
.byte 0x44
.byte 0x55
.byte 0x66
.byte 0x77
.byte 0x88
.byte 0x99
.byte 0xaa
.byte 0xbb
.byte 0xcc
.byte 0xdd
.byte 0xee
.byte 0xff
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top