MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / minimal_output

Function minimal_output

crates/asm-to-binary/tests/elf_output.rs:37–58  ·  view source on GitHub ↗

Build a minimal assembled program: _start calls main, main returns 42.

()

Source from the content-addressed store, hash-verified

35 .try_into()
36 .expect("ELF field should have the expected width"),
37 )
38}
39fn u64_le(buf: &[u8], off: usize) -> u64 {
40 u64::from_le_bytes(
41 buf[off..off + 8]
42 .try_into()
43 .expect("ELF field should have the expected width"),
44 )
45}
46
47// Build a minimal program: _start calls main, main returns 42.
48fn minimal_tokens() -> Vec<RvInstruction> {
49 let a7: u8 = 17;
50 let a0: u8 = 10;
51 let ra: u8 = 1;
52
53 vec![
54 RvInstruction::Directive(".text".to_owned()),
55 RvInstruction::Label("_start".to_owned()),
56 RvInstruction::Pseudo(PseudoInstruction::Call {
57 symbol: "main".to_owned(),
58 }),
59 RvInstruction::Pseudo(PseudoInstruction::Li { rd: a7, imm: 93 }),
60 RvInstruction::Real(RealInstruction::Ecall(Ecall)),
61 RvInstruction::Label("main".to_owned()),

Calls

no outgoing calls

Tested by

no test coverage detected