Difference between revisions of "General Coding Tricks"
From SizeCoding
(→Jumping into the middle of instructions) |
|||
Line 16: | Line 16: | ||
loop label+1 | loop label+1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | The <code>+1</code> specifies the jump should go to 1 byte past the actual location. |
Revision as of 16:34, 6 August 2016
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
The +1
specifies the jump should go to 1 byte past the actual location.