Questions tagged [rars-simulator]

RISC-V Assembler and Runtime Simulator (RARS) is an IDE with a debugger, like the MARS MIPS simulator with similar toy system calls.

RARS is inspired by and named after the MIPS simulator, MARS. ()

RARS is a simulator for RISC-V, simulating a simple environment for programs to run in, with a simple set of ecall system calls that do things which are handled by libraries in a system like GNU/Linux. e.g. printInt is call number 4, just like MARS.

Like MARS, these toy system calls don't return a length for readString, although there is a full Unix-like Read system call (a7=63) which takes a file descriptor and returns a length or -1, instead of just leaving a 0-terminated string in the supplied buffer for readString (a7=8).

22 questions
2
votes
2 answers

How do I get rid of '\n' in RISC-V?

I've been given a task to create a program that would read the name of a file and then copy its insides to other file, name of which is also read from the input. I wrote the program itself, but it appeared to do nothing. Experimenting further, I've…
el_bulm
  • 19
  • 5
1
vote
1 answer

How to solve the error "Load address not aligned to word boundary" in RISC-V?

I'm working on translating MIPS assembly programs written for the MARS simulator into RISCV assembly for RARS simulator. This program is to divide the source image from a BMP file into 3 by 4 pieces and put them in new order after inputting it from…
Yuka
  • 11
  • 3
1
vote
0 answers

Invalid language element error in Assembly

I am trying to execute this riscv assembly code but I keep getting the error :Invalid language element This is the code part that error happend. (last row) main: addi sp,sp,-32 sw ra,28(sp) sw s0,24(sp) …
1
vote
1 answer

RISC-V educational hexacode listing

I want to change my educational-purpose simulator from Y86 to RISC-V. I like the Y86 combined hexacode+listing file, like | # Execution begins at address 0 0x000: | .pos 0 0x000: 30f400010000 | init: …
katang
  • 2,474
  • 5
  • 24
  • 48
0
votes
1 answer

Reading an RGB formatted file into a buffer in RISCV (32-bit) assembly

I'm trying to read the RGB values from the file into an array, but when I check the buffer it's full of zeros instead of the values. First I tried it in C and then, implemented it in riscv assembly. I'm not sure what's causing this. Here are the…
emirbalci
  • 1
  • 1
0
votes
0 answers

How do you check if a letter in a string is upper or lower case in RISC-V assemby

I cannot manage to compare current character that I'm checking in a loop with ascii code, it pops up type error The initial task is to Convert all lower case letters to * Input string > Wind On The Hill Conversion results> W*** O* T**…
ZaAnanasa
  • 3
  • 2
0
votes
1 answer

RISC-V two lables on the same line?

Does anyone know if its possible in any way to put two labels on the same line when writing in RISC-V. I can't seem to find an answer on the documentation. Here is an example Where I want to compute the sum of every integer in the array. v: .word…
0
votes
0 answers

Runtime exception address out of range in RARS String Manipulation

#asciis for l and U li t4, 108 li t5, 'U' la t1, str1 # t1 is ptr repeat: lb s1, (t1) # the char beq s1, t2, tapos # check for \r beq s1, t3, tapos # check for \n beq s1, t5, tapos # check for null beq s1, t4, test_replace j…
Rocklon1427
  • 251
  • 1
  • 2
  • 5
0
votes
0 answers

How do you read text (.txt) files in RISC V (using RARS simulator)?

I have a text file called dna.txt which contains ACGGTGCTGTATCCATATCCGTTAACTCTCTTGTGTCACC. I want to count the occurrences of characters C and G in the text file, and the length of the original string. I want the program to read the input from a…
lowrain
  • 21
  • 4
0
votes
1 answer

Is there a way to make MARS or RARS disassemble an instruction given in hex?

MARS & RARS contain a disassembler, but don't allow .word within .text will only disassemble the .text section Is there a way to get these simulators to disassemble an instruction from hex? (The common online disassemblers also don't support RISC…
Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
0
votes
0 answers

Reading pixels from a bmp file in RISC-V assembly [RARS]

I'm trying to access a bmp file using RARS and I have a problem with accessing pixels of it. I'm trying to find a black pixel in my bitmap image but the way I did it gives me address out of range error when loading a byte from t3 to t5. Therefore I…
Hollow172
  • 1
  • 3
0
votes
0 answers

Can someone explain this factorial exercise to me step by step? Risc-v in Rars simulator

.data .text .globl main main: li a0, 5 jal fact li a7, 1 ecall li a7, 10 ecall fact: li t0, 2 bge a0, t0, else li a0, 1 jr ra else: addi sp, sp, -8 sw a0, 4(sp) sw ra, 0(sp) addi a0, a0, -1 jal fact lw t0, 4(sp) mul a0, a0, t0 lw ra,…
0
votes
0 answers

AND in RISC-V (RARS) doesn't give me "out of bound" error

I'm new to RISC-V and I was making some exercises, I have to take the bits in 3rd and 4th position in x5 register and substitute them to the bits in 7th and 8th position in x6 register. That's what I did (my Professor did it too but i tried to make…
0
votes
0 answers

Is there any way to divide 64-bit integer by 10 on RARS?

I have been trying to divide two 32-bit registers by 10. I know how to divide a register if a dividend is 32-bit like the following code, but I cannot solve if it's 64-bit. div s8, s0, a6 # divide a result by 10 (for example, 1234->123) mul …
Yuka
  • 11
  • 3
0
votes
0 answers

I cannot find a solution to muliply unsigned integers

I tried to make a program which read 64 bit integer into two registers on RARS. Then, when multiplying 32 bit unsigned integers by 10, I wrote mulhu s3, s3, s2 #s2 is 10 , but s3 doesn't change form 0. Then when I wrote mul s3, s3, s2 it worked,…
1
2