• entries
72
51
• views
60668

# NASM SYSEXIT bug=Invalid OPCode

239 views

Ugh.

It seems some of the older versions of NASM has an error in it.

They translate the SYSCALL instruction just fine, but the translated OPCode for the SYSEXIT instruction is off by one, which produces an illegal instruction.

These versions output SYSEXIT into the OPCode 0x0F36. This OPCode is not correct, so a valid SYSEXIT instruction in the source will still assemble--It will just crash because of the unknown / illegal instruction.

There are two ways around this. The first, is to embed the machine language directly within the source to be executed.

Because SYSEXIT uses the OPCode 0xF35 (Not the invalid OPCode 0xF36 produced by NASM), we can use this:
; here we are executing the code...dw 0x0F35    ; Embedded machine opcode--this is our sysexit instruction

This will assembly as just binary data--but, when executed, it is executed as a valid SYSEXIT instruction.

OS Development Series Tutorial 12
This should be completed by either today or tomorrow. It is another 2 part tutorial, covering all of the basic groundwork for a Kernel at its core.

Afterwords, Tutorial 14.1, 14.2, 14.x will be special tutorials that describe setting up individual toolset envirements, and setting up the C compiliers and linkers for use at Kernelland.

There are no comments to display.

## Create an account

Register a new account