Hacker News new | ask | show | jobs
by thu 2001 days ago
What a coincidence, I was trying to compile it yesterday but for instance, the `fp` register is not recognized. I can rename it to `s0` (a synonym) but I'm wondering what should I do to avoid this error:

    jonesforth.S:540: Error: illegal operands `addi fp,fp,-8'
Any idea?

For those interested, I'm using the nixpkgs cross-toolchain. Some documentation is here[0]. Here is a possible `shell.nix` file content:

    { pkgs ? import <nixpkgs> {} }:
    let
      riscv64-pkgs = import <nixpkgs> {
        crossSystem = (import <nixpkgs/lib>).systems.examples.riscv64;
      };
    in
    {
      riscv64 = riscv64-pkgs.mkShell {
        buildInputs = [
        ];
        nativeBuildInputs = [
          riscv64-pkgs.buildPackages.gdb
        ];
      };
    }
This works well enough to compile my hello-world example (available here[1]) but I'd like to use that `fp` register naming...

[0]: https://nixos.wiki/wiki/Cross_Compiling

[1]: https://github.com/noteed/riscv-hello-asm

1 comments

FWIW I was able to compile it on RISC-V hardware (the SiFive Unleashed) running recent Fedora.

  $ make
  gcc -I /usr/include -I. -g -nostdlib -static -o jonesforth jonesforth.S
  $ gcc --version
  gcc (GCC) 10.0.1 20200121 (Red Hat 10.0.1-0.4)
  $ as --version
  GNU assembler version 2.34-2.fc32
The tests don't all pass, but the basic system seems to work.
BTW, thanks a lot for writing jonesforth.S, it's a joy to read !

I read it a year or two ago, and I was revisiting it these days, hoping to write some RISC-V assembly when I found the repository you just submitted.