MIPS, put values from registers into RAM?

Tropical_Peach

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

RobertB

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MIPS registers preservation

From Dev

MIPS registers regex

From Java

MIPS loading values from address

From Dev

How to know the values of CR registers from linux user and kernel modes

From Dev

How to know the values of CR registers from linux user and kernel modes

From Dev

What are shadow registers in MIPS and how are they used?

From Dev

put values from query into array

From Dev

Put values from DB into array

From Dev

Swapping values using registers

From Dev

array on mips from C to MIPS?

From Dev

Are GDB registers different from processor registers?

From Dev

Link values in MIPS

From Dev

Declaring integer values in MIPS

From Dev

From data memory to registers

From Dev

How to use MIPS $k0 and $k1 registers

From Dev

MIPS assembly language - temporary register vs saved registers

From Dev

MIPS - Simple Addition - Input Storage Issue using Temp registers

From Dev

Why can't exception handlers in mips overwrite registers?

From Dev

Print out values in XMM registers

From Java

put the resulting values from for loop into a table in r

From Dev

How to put values from array in td elements

From Dev

MIPS translation from java

From Dev

Mips function arguments and return values

From Dev

Accessing CPU Registers from C

From Dev

PHP - Get dynamic values from keys from array and put into a list

From Dev

Printf Change values in registers, ARM Assembly

From Dev

Keeping more values at once than there are registers in assembly

From Dev

Why is gdb printing registers values in that way

From Dev

PCI configuration space registers - write values