Fixed bug where offset was calculated incorrectly with register arrays
@@ -543,8 +543,18 @@ fn register_block(registers: &[Register], defs: &Defaults) -> Result<Tokens> {
fields.push( util::register_to_rust(&register) );
- offset =
- register.address_offset
+ offset = match register {
+ Register::Single(ref _into) => register.address_offset
+ +
+ register
+ .size
+ .or(defs.size)
+ .ok_or_else(
+ || {
+ format!("Register {} has no `size` field", register.name)
+ },
+ )? / 8,
+ Register::Array(ref _into, ref array_info) => register.address_offset
+
register
.size
@@ -553,7 +563,8 @@ fn register_block(registers: &[Register], defs: &Defaults) -> Result<Tokens> {
|| {
format!("Register {} has no `size` field", register.name)
},
- )? / 8;
+ )? * array_info.dim / 8,
+ };
}
Ok(quote! {
