Fix bug when generating single-source instructions
Single-source instructions need their source spec to be in the the top 4 bits of the source/dest spec, and it was incorrectly being set in the bottom 4 bits. This affected jump instructions, as they would be reading the instruction at the given address rather than jumping to it. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -226,13 +226,16 @@ impl Assemble for Inst {
|
|||||||
let mut bytes = Vec::with_capacity(len);
|
let mut bytes = Vec::with_capacity(len);
|
||||||
bytes.write_u16::<LE>($op).unwrap();
|
bytes.write_u16::<LE>($op).unwrap();
|
||||||
let source = $source;
|
let source = $source;
|
||||||
let source_encoding = source.source_encoding();
|
let source_encoding = source.source_encoding() << 4;
|
||||||
bytes.write_u8(source_encoding).unwrap();
|
bytes.write_u8(source_encoding).unwrap();
|
||||||
bytes.extend(source.assemble(asm)?);
|
bytes.extend(source.assemble(asm)?);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.len(), bytes.len(),
|
self.len(),
|
||||||
|
bytes.len(),
|
||||||
"instruction size mismatch in {} instruction - {:?} produces these bytes {:?}",
|
"instruction size mismatch in {} instruction - {:?} produces these bytes {:?}",
|
||||||
stringify!($op), self, bytes
|
stringify!($op),
|
||||||
|
self,
|
||||||
|
bytes
|
||||||
);
|
);
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}};
|
}};
|
||||||
|
|||||||
Reference in New Issue
Block a user