How to disassemble instruction that takes string literal as param #7009
Replies: 3 comments 2 replies
-
So far I managed to get it working as arrays of hex bytes using a line of Sleigh for each length. Not ideal but useful while I wait to see if there's a better way:
etc. example output: 61c9 0b 42 41 54 54 4c 45 47 52 4f HTEX [0x42,0x41,0x54,0x54,0x4c,0x45,0x47,0x
55 4e 44
61d6 94 COL+ >0x15
61d7 09 4d 49 4e 45 20 46 49 45 4c HTEX [0x4d,0x49,0x4e,0x45,0x20,0x46,0x49,0x
44
61e2 95 COL+ >0x16
61e3 08 4f 42 53 54 41 43 4c 45 53 HTEX [0x4f,0x42,0x53,0x54,0x41,0x43,0x4c,0x
61ed fe 12 ROW 0x12
61ef ff 0f COL 0xf
61f1 fb FEND |
Beta Was this translation helpful? Give feedback.
-
Related: #5070 |
Beta Was this translation helpful? Give feedback.
-
Since it's fixed string ASCII, the best way may be to have a sub-constructor for the characters, along with context to track the length. Unfortunately, no matter what, it doesn't represent spaces very well.
possibly a simpler way is to handle this is:
Then you can define the data skipped over as a string and create a memory reference on the HTEX instruction to the data immediately following it. This could be handled in an analyzer. It doesn't look incredibly beautiful, but you can see the writes and it's very simple. |
Beta Was this translation helpful? Give feedback.
-
I'm working on just the disassembler for now for a bytecode from 1979 by Texas Instruments called "GPL".
It has an instruction called
htex
orhtext
that prints a string on the screen but its operand is a string literal. Here's an example from xdg99, which I'm using as the reference disassembler to compare my work against:So it mostly looks like an assembly language. But I've never seen string literals as operands so I'm wondering if there's a way to achieve this in Sleigh? If not, what would be my next-best options?
The instruction format for
htext
is000x xxxx
which gives us a 5-bit number that we add one to to get the length of the string, and that number of ASCII bytes of the string follow immediately, before the next instruction.Interpreting the bits I can figure out. I'm a bit fuzzy on how to deal with the variable length operand of up to 32 bytes. But I have no idea if or how I can actually make it render as an operand.
I suppose I can add 32 versions, one for each length. But aren't operands always expected to be numbers?
Beta Was this translation helpful? Give feedback.
All reactions