G+_Lee Crocker Posted January 30, 2015 Share Posted January 30, 2015 One thing the last show didn't make clear at all was the concept of "Macro". "MASM" is short for "Macro Assembler", a primary feature of which accounts for Steve's ability to do things like those .IF / .THEN blocks. Other assemblers do this as well. Most lines of assembly code represent actual machine instructions, and are simply translated one-for-one into the machine-code of the processor. But MASM and other assemblers also have the ability to define and use macros, much like C's preprocessor. You give a name to a macro, and it expands into one or more lines of code (which might be further nested macros, or final instructions). They can take arguments, do assemble-time computations, and other things, but when they are finally invoked, they eventually end up outputting actual code. For example, Steve's .IF (eax < ecx) probably expands to something like cmp eax, ecx ; compare registers jge ; jump if first >= second while his .THEN expands to nothing, .ELSE expands to jmp ; skip else block : and finally .ENDIF expands to : So there's actual instructions (or labels, or nothing) being emitted, but the macros take care of things like making the label for you, figuring out which compare and jump instructions to use, etc. So assembly is actually two languages: the instruction set of the processor, and instructions to the assembler itself, including its macro expansion ability. Link to comment Share on other sites More sharing options...
G+_Travis Hershberger Posted February 1, 2015 Share Posted February 1, 2015 Steve Gibson has actually touched on this topic in a Security Now episode earlier this year (sorry, don't remember which one.) He was saying that nobody else would be able to use his programming environment because he has so many macros defined. Link to comment Share on other sites More sharing options...
G+_Charles Kelly Posted February 5, 2015 Share Posted February 5, 2015 Some assemblers include native support for structured code. Link to comment Share on other sites More sharing options...
Recommended Posts