General Coding Tricks
From SizeCoding
Revision as of 15:33, 6 August 2016 by Trixter (talk | contribs) (→Jumping into the middle of instructions)
Data is code, code is data
Code is nothing more than data that the CPU interprets. For example, consider this multi-byte instruction:
mov ah,37h
This assembles to B4 37
. B4
by itself isn't interesting, but 37
is the opcode for AAS
. Let's say you had this code before a loop, and you needed to perform AAS
at the top of a loop. Rather than put AAS at the top of the loop, you can reuse the opcode that will already be there as part of the mov ah,37
that comes before it. Just jump directly into the middle of the mov ah,37h
, which will get interpreted and executed as AAS
:
label:
mov ah,37h
;misc. stuff
loop label+1