Adds `data:int` and `data:short` for asm output

Fixes #41
This commit is contained in:
Luke Street 2024-04-30 18:03:45 -06:00
parent bfa926ebbf
commit fdafe59e13
4 changed files with 18 additions and 4 deletions

View File

@ -19,8 +19,8 @@ pub fn detect_objects(obj: &mut ObjInfo) -> Result<()> {
} }
let expected_size = match symbol.data_kind { let expected_size = match symbol.data_kind {
ObjDataKind::Byte => 1, ObjDataKind::Byte => 1,
ObjDataKind::Byte2 => 2, ObjDataKind::Byte2 | ObjDataKind::Short => 2,
ObjDataKind::Byte4 | ObjDataKind::Float => 4, ObjDataKind::Byte4 | ObjDataKind::Float | ObjDataKind::Int => 4,
ObjDataKind::Byte8 | ObjDataKind::Double => 8, ObjDataKind::Byte8 | ObjDataKind::Double => 8,
_ => 0, _ => 0,
}; };

View File

@ -172,6 +172,8 @@ pub enum ObjDataKind {
String16, String16,
StringTable, StringTable,
String16Table, String16Table,
Int,
Short,
} }
#[derive(Debug, Clone, Default, Eq, PartialEq)] #[derive(Debug, Clone, Default, Eq, PartialEq)]

View File

@ -704,8 +704,8 @@ where W: Write + ?Sized {
_ => {} _ => {}
} }
let chunk_size = match data_kind { let chunk_size = match data_kind {
ObjDataKind::Byte2 => 2, ObjDataKind::Byte2 | ObjDataKind::Short => 2,
ObjDataKind::Unknown | ObjDataKind::Byte4 | ObjDataKind::Float => 4, ObjDataKind::Unknown | ObjDataKind::Byte4 | ObjDataKind::Float | ObjDataKind::Int => 4,
ObjDataKind::Byte | ObjDataKind::Byte8 | ObjDataKind::Double => 8, ObjDataKind::Byte | ObjDataKind::Byte8 | ObjDataKind::Double => 8,
ObjDataKind::String ObjDataKind::String
| ObjDataKind::String16 | ObjDataKind::String16
@ -740,10 +740,18 @@ where W: Write + ?Sized {
writeln!(w, "\t.float {data}")?; writeln!(w, "\t.float {data}")?;
} }
} }
4 if data_kind == ObjDataKind::Int => {
let data = i32::from_be_bytes(chunk.try_into().unwrap());
writeln!(w, "\t.int {data}")?;
}
4 => { 4 => {
let data = u32::from_be_bytes(chunk.try_into().unwrap()); let data = u32::from_be_bytes(chunk.try_into().unwrap());
writeln!(w, "\t.4byte {data:#010X}")?; writeln!(w, "\t.4byte {data:#010X}")?;
} }
2 if data_kind == ObjDataKind::Short => {
let data = i16::from_be_bytes(chunk.try_into().unwrap());
writeln!(w, "\t.short {data}")?;
}
2 => { 2 => {
writeln!(w, "\t.2byte {:#06X}", u16::from_be_bytes(chunk.try_into().unwrap()))?; writeln!(w, "\t.2byte {:#06X}", u16::from_be_bytes(chunk.try_into().unwrap()))?;
} }

View File

@ -321,6 +321,8 @@ fn symbol_data_kind_to_str(kind: ObjDataKind) -> Option<&'static str> {
ObjDataKind::String16 => Some("wstring"), ObjDataKind::String16 => Some("wstring"),
ObjDataKind::StringTable => Some("string_table"), ObjDataKind::StringTable => Some("string_table"),
ObjDataKind::String16Table => Some("wstring_table"), ObjDataKind::String16Table => Some("wstring_table"),
ObjDataKind::Int => Some("int"),
ObjDataKind::Short => Some("short"),
} }
} }
@ -372,6 +374,8 @@ fn symbol_data_kind_from_str(s: &str) -> Option<ObjDataKind> {
"wstring" => Some(ObjDataKind::String16), "wstring" => Some(ObjDataKind::String16),
"string_table" => Some(ObjDataKind::StringTable), "string_table" => Some(ObjDataKind::StringTable),
"wstring_table" => Some(ObjDataKind::String16Table), "wstring_table" => Some(ObjDataKind::String16Table),
"int" => Some(ObjDataKind::Int),
"short" => Some(ObjDataKind::Short),
_ => None, _ => None,
} }
} }