()
| 67 | |
| 68 | #[test] |
| 69 | fn test_la_pseudo_expansion() { |
| 70 | // Test specifically the 'la' pseudo-instruction expansion |
| 71 | let tokens = vec![ |
| 72 | RvInstruction::Directive("\t.text".to_string()), |
| 73 | RvInstruction::Label("main".to_string()), |
| 74 | RvInstruction::Directive("\t.globl main".to_string()), |
| 75 | |
| 76 | // Load address using la pseudo |
| 77 | RvInstruction::Pseudo(PseudoInstruction::La { |
| 78 | rd: 10, // a0 |
| 79 | symbol: "data_label".to_string(), |
| 80 | }), |
| 81 | |
| 82 | RvInstruction::Real(RealInstruction::Jalr(Jalr::new(0, 1, 0))), // ret |
| 83 | |
| 84 | RvInstruction::Directive("\t.data".to_string()), |
| 85 | RvInstruction::Label("data_label".to_string()), |
| 86 | RvInstruction::Directive("\t.word 42".to_string()), |
| 87 | ]; |
| 88 | |
| 89 | match Assembler::assemble(&tokens) { |
| 90 | Ok(output) => { |
| 91 | // la expands to auipc + addi = at least 2 instructions |
| 92 | assert!(output.text_bytes().len() >= 8, "Expected at least 2 instructions from la expansion"); |
| 93 | } |
| 94 | Err(e) => { |
| 95 | panic!("Assembly failed for la test: {}", e.message); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | #[test] |
| 101 | fn test_call_pseudo_expansion() { |
nothing calls this directly
no outgoing calls
no test coverage detected