In: Computer Science
Rars Rise V please
Write a program that inserts a minus “-“ between all (!) double-consonants:
Tunnel -> Tun-nel Busseat -> Bus-seat
And so on..
Howto:
Write a program that lets you enter a string.
Use ecall(12) readchar for that in a loop until carriage return.
The string can be limited to 30 letters.
Make a static string array in the data section holding at least 40 letters.
Loop over the string searching for double-consonants.
Have a second string for the result.
Print the result string.
You can use:
.global _start # Provide program starting address to linker _start:
#loop
addi a7, x0, 12 # linux write system call
ecall .data
sourcestring: .ascii " " #30
targetstring: .ascii " "#40
#Could you please leave a THUMBS Up for my work...
RARS -- RISC-V Assembler and Runtime Simulator:
It is used to assemble and simulate the execution of RISC-V assembly language programs.Its goal is to make an effective development environment.
Some features of RARS -- RISC-V Assembler and Runtime Simulator:
Number of system calls that match behaviour from MARS or SPIKE.
Debugging using breakpoints and/or ebreak is Supported.
RISC-V IMFDN Base (riscv32 and riscv64).
Simultaniously compare psuedo-instruction to machine code with intermediate steps.
Multifile assembly using either files open or a directory.
Program that inserts a minus “-“between all (!) double constants :
.global _start # Gives starting address to linker
_start:
la t1,sourcestring
li t2,10 #enter consonants
loop:
addi a7,x0,12 #readchar
ecall
# input is stored in a0
sb a0,0(t1)
addi t1,t1,1
bne a0,t2,loop
sb x0,0(t1)
.data
sourcestring: .word 30 #String Limit 30 letters
targetstring: .word 40 #Static String array holding 40 letters