TheThirdOne / rars

RARS -- RISC-V Assembler and Runtime Simulator
Other
1.14k stars 217 forks source link

Version 1.6 command line mode does not print register content after the run #199

Open zhijieshi opened 9 months ago

zhijieshi commented 9 months ago

Somehow the register options do not work in Version 1.6. They worked perfectly in Version 1.5.

For example,

# The following command is supposed to print register x1 at the end of run. However, register x1 is not printed.
java -jar rars1.6.jar example.s x1

# With the me option, register x1 is printed in stderr.
java -jar rars1.6.jar example.s x1 me
TheThirdOne commented 9 months ago

I cannot reproduce this error. I used the code:

li a7, 10
ecall

Please share a short program that shows this bug for you.

zhijieshi commented 9 months ago

OS: Windows 11. Java version:

java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

Assume a file e.s has the following code.


        .data
msg:    .asciz  "Hello, world!\n"

        .text
main:
        lui     a0, 0x10010     # a0 = the address of msg. hard-coded
        addi    a7, zero, 4     # a7 = 4, the system call number for printing a string
        ecall                   # system call

        # system call 10: exit with code 0
        addi    a7, zero, 10    # a7 = 10
        ecall                   # system call

Here is the command and the output, using RARS 1.5.

java -jar .\rars1_5.jar e.s a0 a7 
RARS 1.5  Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar

Hello, world!

Program terminated by calling exit
a0      0x10010000
a7      0x0000000a

Here is the command and the output when RARS 1.6 is used. The values of a0 and a7 are not printed. The line "Program terminated by calling exit" is also different.

java -jar .\rars1_6.jar e.s a0 a7
RARS 1.6  Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar

Hello, world!

Here is the command and the output when me option is used with RARS 1.6.


java -jar .\rars1_6.jar e.s a0 a7 me
RARS 1.6  Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar

Hello, world!

Program terminated by calling exit
a0      0x10010000
a7      0x0000000a
kpiche commented 7 months ago

Noticed that RARS doesn't output registers if your program prints anything:

$ cat reg1.asm 
.text
        li      a1, 0x1234
        li      a0, 65          # printchar A
        addi    a7, zero, 11
        ecall
$
$ rars a1 reg1.asm
RARS 1.6  Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar

A$ 

With no printchar call:

$ cat reg2.asm 
# rars nc a1 reg2.asm
.text
        li      a1, 0x1234
$ 
$ rars a1 reg2.asm
RARS 1.6  Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar

Program terminated by dropping off the bottom.
a1      0x00001234
$