|
Written by Jan Verhoeven
|
Assembly Snippets
;Summary: exchange the contents of two registers using
; as few storage locations as possible
;Compatibility: all x86 assemblers
;Notes: Will work for memory locations, etc
xor ax, bx
xor bx, ax
xor ax, bx
Trailing Calls
by Jan Verhoeven
;This is really more of a trick than a snippet. It is quite common to come
;across code such as
cmp ax, [Sector][2]
jne >L0
inc ax
L0: call TestDrive
ret
;This amounts to two ret's, one in the above code and one in the TestDrive
;routine. To save a bit of space and overhead, we can make use of TestDrive's
;ret to return from our own routine:
cmp ax, [Sector][2]
jne >L0
inc ax
L0: jmp TestDrive
|