EduMIPS64 / edumips64

Free cross-platform educational MIPS64 CPU Simulator. Experimental web version: https://web.edumips.org.
https://www.edumips.org
GNU General Public License v2.0
165 stars 57 forks source link

SYSCALL 5 not implemented in CLI mode #1178

Closed Anyone789 closed 16 hours ago

Anyone789 commented 2 days ago

Version: 1.3.0, 2023-10-17T18:28:27.407233900, master@f7753dc JRE version: 21.0.5 OS: Linux

java.lang.NullPointerException: Cannot invoke "org.edumips64.utils.io.Writer.write(String)" because "w" is null
        at org.edumips64.core.IOManager.write(IOManager.java:246)
        at org.edumips64.core.is.SYSCALL.MEM(SYSCALL.java:255)
        at org.edumips64.core.CPU.stepMEM(CPU.java:551)
        at org.edumips64.core.CPU.step(CPU.java:403)
        at org.edumips64.utils.cli.RunCommand.execute(RunCommand.java:29)
        at org.edumips64.utils.cli.RunCommand.run(RunCommand.java:17)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at org.edumips64.CliRunner.handleTokens(CliRunner.java:80)
        at org.edumips64.CliRunner.runReplLoop(CliRunner.java:69)
        at org.edumips64.CliRunner.start(CliRunner.java:56)
        at org.edumips64.Main.startCli(Main.java:244)
        at org.edumips64.Main.main(Main.java:155)

Loaded file:
; Autor reseni: jmeno prijmeni login

; Projekt 2 - INP 2024
; Vigenerova sifra na architekture MIPS64

; DATA SEGMENT
                .data
msg:            .asciiz "Hello world!" ; sem doplnte vase "jmenoprijmeni"
cipher:         .space  31 ; misto pro zapis zasifrovaneho textu
; zde si muzete nadefinovat vlastni promenne ci konstanty,
; napr. hodnoty posuvu pro jednotlive znaky sifrovacho klice

params_sys5:    .space  8 ; misto pro ulozeni adresy pocatku
                          ; retezce pro vypis pomoci syscall 5
                          ; (viz nize "funkce" print_string)

; CODE SEGMENT
                .text

main:           ; ZDE NAHRADTE KOD VASIM RESENIM
                daddi   r4, r0, msg ; vozrovy vypis: adresa msg do r4
                jal     print_string ; vypis pomoci print_string - viz nize

; NASLEDUJICI KOD NEMODIFIKUJTE!

                syscall 0   ; halt

print_string:   ; adresa retezce se ocekava v r4
                sw      r4, params_sys5(r0)
                daddi   r14, r0, params_sys5    ; adr pro syscall 5 musi do r14
                syscall 5   ; systemova procedura - vypis retezce na terminal
                jr      r31 ; return - r31 je urcen na return address
lupino3 commented 19 hours ago

Thank you for the bug report, @Anyone789! Let me try to reproduce it and fix it.

lupino3 commented 19 hours ago

I see that you are running the simulator with the --headless option, to use the CLI UI.

Unfortunately, some I/O syscalls are not implemented in the CLI version as of now, so it is known that they don't work.

We should be handling this failure a bit more gracefully, though.

image

Just for good measure, I tested the GUI version and it works as expected. I'll rename this issue and use it to track this new feature.

lupino3 commented 18 hours ago

Need to do something similar to https://github.com/EduMIPS64/edumips64/blob/master/src/main/java/org/edumips64/Main.java#L377-L384

lupino3 commented 16 hours ago

Fixed in master, thanks for the report @Anyone789