flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Don't know if this has been posted... |
Author |
|
tantrikwizard 14 Dec 2006, 04:03
this is a great idea, i've use something similar in c++ apps wrapped in a macro EmbedString(psz) which would be turned off or on with conditional compilation, it makes things a bit easier when disassembling memory dumps, though I'm a bit of a noob with fasm's macro syntax, is it possible to do in fasm? I'm curious if a macro can take an instruction as a parameter and both embed the textual representation of the instruction and emit the opcode. It could be very handy in debugging to have say, a .d or .dump macro .dump mov eax, ebx.
jmp @F db 'mov eax, ebx' @@: mov eax, ebx[/code] |
|||
14 Dec 2006, 04:03 |
|
kohlrak 14 Dec 2006, 04:08
Not sure what you mean, but you could probably do it in 2 seperate instructions. And if you mean using fasm to take a source code and assemble it and put the source beside it, only jumped over, you could probably edit the fasm source to do that.
|
|||
14 Dec 2006, 04:08 |
|
vid 14 Dec 2006, 12:43
[code]
DEBUG=1 ;change to 0 to disable macro embedstring str { local ..forward if DEBUG=1 jmp ..forward db str,0 ..forward: end if } embedstring "abcd" embedstring <"abcd",10,13,"xxx"> |
|||
14 Dec 2006, 12:43 |
|
tantrikwizard 14 Dec 2006, 15:07
kohlrak wrote: Not sure what you mean Sorry I was unclear, what I mean is it would be nice to have a single macro that both embeds the text of the instruction being executed and encodes the instruction. something quick and dirty like a D macro. Code: D NOP produces jmp ..forward db 'NOP' ..forward NOP This way the NOP instruction is both assembled and the string 'NOP' is embedded in the binary before it's executed. It would help when looking at memory dumps, one could read which instructions were being executed at given locations because the string representation of the instruction will be displayed. It would certainly over-bloat the binary but should be able to turn off instruction string embedding after debugging similar to vid's example. |
|||
14 Dec 2006, 15:07 |
|
Tomasz Grysztar 14 Dec 2006, 15:21
Well, the listing is a much more traditional approach to this problem, however here's my quick try to make a macro like what you proposed:
Code: macro record_instruction [ins] { macro ins [operand] \{ \common \local ..skip jmp ..skip irps symbol, ins operand \\{ db 20h,\\`symbol \\} ..skip: ins operand \} } ; with this macro you define which instructions ; will make the textal dumps of themselves: record_instruction add,mov,nop |
|||
14 Dec 2006, 15:21 |
|
kohlrak 14 Dec 2006, 23:54
I take it that listing is the same thing only it dosn't rely on the macro?
|
|||
14 Dec 2006, 23:54 |
|
Adam Kachwalla 12 Aug 2007, 08:20
But they could easily find this by opening your app in a hex editor and then replace your string with theirs (if it is equal in length; and if it is shorter, pad it up with spaces or NULs)
|
|||
12 Aug 2007, 08:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.