A 1980's-inspired RISC-V assembler quick reference card

26 views
Skip to first unread message

Dylan McNamee

unread,
Jun 30, 2022, 9:43:30 PM6/30/22
to RISC-V Developer Board Community
When I was first learning assembly one of my favorite type of learning resources were the tri-fold assembly reference cards, as produced for the PDP-10, Motorola 68K, and other CPUs of the era. I decided to create one for the RISC-V, attached. I used it to convert the Rust inline assembly example from x86 to RISC-V:
(compile with "rustc rv-asm.rs")
use std::arch::asm;

fn main() {

    // Multiply x by 6 using shifts and adds
    let mut x: u64 = 4;
    unsafe {
        asm!(
            "addi {tmp}, {x}, 0",
            "slli {tmp}, {tmp}, 1",
            "slli {x}, {x}, 2",
            "add {x}, {tmp}, {x}",
            x = inout(reg) x,
            tmp = out(reg) _,
        );
    }
    assert_eq!(x, 4 * 6);
}

A PDF of the reference card is attached.

best,
dylan

RISC-V quick ref card.pdf

Jeff Scheel

unread,
Jul 5, 2022, 10:29:15 AM7/5/22
to Dylan McNamee, RISC-V Developer Board Community
I'm sure I date myself by loving this, but I do!  Thanks, Dylan!!!
-Jeff

--
Jeff Scheel (he/him/his)
Linux Foundation, RISC-V Technical Program Manager

Akira Tsukamoto

unread,
Jul 6, 2022, 10:55:04 AM7/6/22
to Jeff Scheel, Dylan McNamee, RISC-V Developer Board Community
I also had one of the card for my z80.
I still keep it :)

Best,
Akira

On 7/5/2022 11:29 PM, Jeff Scheel wrote:
> I'm sure I date myself by loving this, but I do!  Thanks, Dylan!!!
> -Jeff
>
> --
> Jeff Scheel (he/him/his)
> Linux Foundation, RISC-V Technical Program Manager
>
>
> On Thu, Jun 30, 2022 at 9:43 PM Dylan McNamee <dylan....@gmail.com <mailto:dylan....@gmail.com>> wrote:
>
> When I was first learning assembly one of my favorite type of learning resources were the tri-fold assembly reference cards, as produced for the PDP-10, Motorola 68K, and other CPUs of the era. I decided to create one for the RISC-V, attached. I used it to convert the Rust inline assembly example from x86 to RISC-V:
> (compile with "rustc rv-asm.rs <http://rv-asm.rs>")
> *use std::arch::asm;
>
> fn main() {
>
>     // Multiply x by 6 using shifts and adds
>     let mut x: u64 = 4;
>     unsafe {
>         asm!(
>             "addi {tmp}, {x}, 0",
>             "slli {tmp}, {tmp}, 1",
>             "slli {x}, {x}, 2",
>             "add {x}, {tmp}, {x}",
>             x = inout(reg) x,
>             tmp = out(reg) _,
>         );
>     }
>     assert_eq!(x, 4 * 6);
> }*
>
> A PDF of the reference card is attached.
>
> best,
> dylan
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V Developer Board Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to devboard-commun...@riscv.org <mailto:devboard-commun...@riscv.org>.
Reply all
Reply to author
Forward
0 new messages