Difference between revisions of "General Coding Tricks"
(→Jumping into the middle of instructions)
|Line 16:||Line 16:|
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:
This assembles to
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
label: mov ah,37h ;misc. stuff loop label+1
+1 specifies the jump should go to 1 byte past the actual location.