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

Function test_la_pseudo_relocation

crates/asm-to-binary/tests/assembler_encode.rs:31–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29 // Test that `la a0, label` expands to correct auipc + addi
30 let tokens = vec![
31 RvInstruction::Directive("\t.text".to_owned()),
32 RvInstruction::Pseudo(PseudoInstruction::La {
33 rd: 10, // a0
34 symbol: "my_label".to_owned(),
35 }),
36 RvInstruction::Label("my_label".to_owned()),
37 RvInstruction::Real(asm_to_binary::real::RealInstruction::Addi(
38 asm_to_binary::riscv::rv64i::Addi::new(0, 0, 0),
39 )),
40 ];
41
42 let output = Assembler::assemble(&tokens).expect("la relocation should assemble");
43 assert!(output.has_symbol("my_label"));
44}
45
46#[test]
47fn test_tail_pseudo_relocation() {
48 // Test that `tail target` expands to correct auipc + jalr
49 let tokens = vec![
50 RvInstruction::Directive("\t.text".to_owned()),
51 RvInstruction::Pseudo(PseudoInstruction::Tail {
52 symbol: "end_func".to_owned(),
53 }),

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected