spim

Storing values in HI and LO registers of MIPS

Hello, I am writing certain code in MIPS and I've come to the point where the requirement is to store the result, temporarily, in HI and LO special registers (both are 8 bytes wide). These instructions are at my disposal: divu s,t lo <-- s div t ; hi <-- s mod t multu s,t hi / lo < -- s * t ; So, divu stores result of divisi...

C to MIPS translation

Trying to convert this c code into MIPS and run it in SPIM. int A[100], B[100]; for(i=1; i<100; 1++){ A[i] = A[i-1] + B[i]; } So far this is what I have. # comments are delimted by has marks .data A: .word 0:100 # array of 12 integers B: .word 0:100 # array of 12 integers .text main: li $v0, 1 # l...

MIPS (or SPIM): Loading floating point numbers...

Hey hey, I am working on a little mini compiler while trying to learn some MIPS here. Here's my issue: MIPS has an instruction li (load immediate) which would work like this li $5,100 which would load 100 into register 5. However, I need to load floats into registers right now and am struggling with figuring out a way to do it...s...

Declaring more than one SPIM array causes a syntax error

Below is the beginning of a chunk of SPIM code: .data a: .space 20 b: .space 20 .text set_all: sw $ra,0($sp) li $t0,0 li $t1,10 ............ Unfortunately, the second array I declare ('b') causes the SPIM interpreter to spit out: spim: (parser) syntax error on line 3 of file spim.out b: .space 20 ...

Mips how can I convert Character to binary?

My problem is getting 64 bit key from user. For this I need to get 16 characters as string which contains hexadecimal characters (123456789ABCDEF). I got string from user and I reached characters with the code below. But I dont know how convert character to binary 4 bits. in .data insert_into: .word 8 Ask_Input: .asciiz...

ELF File Format

I'm attempting to manually load the hexdump of an elf file that I compiled using g++ into a processor simulation I designed. There are 30 sections to a standard elf file and I am loading all 30 segments with their proper memory location offset taken into account. I then start my program counter at the beginning of the .text section (0040...

Convert C++ Code to Assembly for SPIM

I'm having a lot of trouble getting my compiled assembly file working on SPIM. Basically I want to write a c++ file, and then generate a .s file that I can open in SPIM without error. This means that the assembly must be in MIPS32 ABI using MIPS I instructions (some MIPS II). How do I do this? Right now I'm using g++ but I'm having m...

Algorithmic Issue in MIPS

I'm rewriting my answer(s) to Project Euler questions in MIPS assembly, and I can't get this one to output the correct answer. I've gone over the code for the past hour, and I can't figure out what's wrong with my approach (as I am getting 33165 when the answer is a cool 200,00+ higher than that), so I figure the problem must be my shaki...

Converting Decimal to Binary and Printing in MIPS

Hello, I'm writing a simple snippet of code for an assignment and I need to convert a decimal number to binary, octal, and hexadecimal. I have it working, but I realized afterwards that because of the algorithm I'm using, I print the binary number backwards. The strategy I was using was to print one digit at a time. I'm still a beginn...