Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion fails when assembling with two delayed definition instruction macros #108

Open
SamWilsn opened this issue Aug 5, 2022 · 0 comments
Labels
A-assembler Area: assembler C-bug Category: this is a bug, deviation, or other problem E-medium Experience: of moderate difficulty

Comments

@SamWilsn
Copy link
Contributor

SamWilsn commented Aug 5, 2022

I think these two test cases (in etk-asm/src/asm.rs) should pass:

    #[test]
    fn assemble_instruction_macro_two_delayed_definitions_mirrored() -> Result<(), Error> {
        let ops = vec![
            AbstractOp::new(GetPc),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro1".into(),
                parameters: vec![],
            }),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro0".into(),
                parameters: vec![],
            }),
            InstructionMacroDefinition {
                name: "macro0".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(JumpDest),
                ],
            }
            .into(),
            InstructionMacroDefinition {
                name: "macro1".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(Caller),
                ],
            }
            .into(),
        ];

        let mut asm = Assembler::new();
        let sz = asm.push_all(ops)?;
        assert_eq!(sz, 3);
        let out = asm.take();
        assert_eq!(out, hex!("58335b"));

        Ok(())
    }
    #[test]
    fn assemble_instruction_macro_two_delayed_definitions() -> Result<(), Error> {
        let ops = vec![
            AbstractOp::new(GetPc),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro0".into(),
                parameters: vec![],
            }),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro1".into(),
                parameters: vec![],
            }),
            InstructionMacroDefinition {
                name: "macro0".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(JumpDest),
                ],
            }
            .into(),
            InstructionMacroDefinition {
                name: "macro1".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(Caller),
                ],
            }
            .into(),
        ];

        let mut asm = Assembler::new();
        let sz = asm.push_all(ops)?;
        assert_eq!(sz, 3);
        let out = asm.take();
        assert_eq!(out, hex!("585b33"));

        Ok(())
    }
@SamWilsn SamWilsn added C-bug Category: this is a bug, deviation, or other problem A-assembler Area: assembler E-medium Experience: of moderate difficulty labels Aug 5, 2022
gzanitti added a commit to gzanitti/etk that referenced this issue Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assembler Area: assembler C-bug Category: this is a bug, deviation, or other problem E-medium Experience: of moderate difficulty
Projects
None yet
Development

No branches or pull requests

1 participant