simple/
simple.rs

1use riscv_codec::{assembly::assemble_line, instruction::Instruction};
2fn main() {
3    // instruction can be assembled from strings
4    let instr: Instruction = assemble_line("addi t0, t1, 1024").unwrap().i();
5    // and disassembled
6    println!("assembled instruction: {}", instr);
7
8    // instructions can also be decoded from binary
9    let instr2 = Instruction::decode(0xe0058513).unwrap();
10
11    // and encoded
12    assert_eq!(Instruction::encode(&instr2), 0xe0058513);
13
14    let instr2 = assemble_line("fcvt.lu.s zero,ft0,rne").unwrap().i();
15    println!("assembled instruction: {}", instr2);
16}