pio-rs icon indicating copy to clipboard operation
pio-rs copied to clipboard

Fix encoding of IN instruction with bit_count == 32

Open jannic opened this issue 1 year ago • 2 comments

Thanks to @xeniarose for finding and reporting this bug

Fixes #57 Replaces #60

jannic avatar Mar 21 '24 07:03 jannic

maybe add a test?

devsnek avatar May 27 '24 01:05 devsnek

how about 4 tests?

instr_test!(r#in(InSource::Y, 10), 0b010_00000_010_01010);
instr_test!(r#in(InSource::Y, 32), 0b010_00000_010_00000);

instr_test!(out(OutDestination::Y, 10), 0b011_00000_010_01010);
instr_test!(out(OutDestination::Y, 32), 0b011_00000_010_00000);

#[test]
#[should_panic]
fn test_invalid_in_bit_width_should_panic() {
    let mut a = Assembler::<32>::new();
    a.r#in(InSource::Y, 33);
    a.assemble_program();
}

#[test]
#[should_panic]
fn test_invalid_out_bit_width_should_panic() {
    let mut a = Assembler::<32>::new();
    a.out(OutDestination::X, 33);
    a.assemble_program();
}

9names avatar May 27 '24 09:05 9names