Borrowing code from FASM x86