Question: I just need a hello world demo to see how machine code actually works.

Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**

How can I write/execute **PURE** machine code?

Answer: 
Everyone knows that the application we usually wrote is run on the operating system. And managed by it.

It means that the operating system is run on the machine. So I think that is PURE machine code which you said.

So, you need to study how an operating system works.

Here is some NASM assembly code for a boot sector which can print "Hello world" in PURE.

```
 org
   xor ax, ax
   mov ds, ax
   mov si, msg
boot_loop:lodsb
   or al, al 
   jz go_flag   
   mov ah, 0x0E
   int 0x10
   jmp boot_loop

go_flag:
   jmp go_flag

msg   db 'hello world', 13, 10, 0

   times 510-($-$$) db 0
   db 0x55
   db 0xAA

```

And you can find more resources here: <http://wiki.osdev.org/Main_Page>.

END.

If you had installed nasm and had a floppy, You can

```
nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=/dev/fd0

```

Then, you can boot from this floppy and you will see the message.
(NOTE: you should make the first boot of your computer the floppy.)

In fact, I suggest you run that code in full virtual machine, like: bochs, virtualbox etc.
Because it is hard to find a machines with a floppy.

So, the steps are 
First, you should need to install a full virtual machine.
Second, create a visual floppy by commend: bximage
Third, write bin file to that visual floppy.
Last, start your visual machine from that visual floppy.

NOTE: In <https://wiki.osdev.org> , there are some basic information about that topic.
The OS is not running the instructions, the CPU does (except if we're talking about a virtual machine OS, which do exist, I'm thinking about Forth or such things). The OS however does require some metainformation to know, that a file does in fact contain executable code, and how it expects its environment to look like. ELF is not just *near* machine code. It **is** machine code, together with some information for the OS to know that it's supposed to put the CPU to actually execute that thing.

If you want something simpler than ELF but \*nix, have a look at the a.out format, which is much simpler. Traditionally \*nix C compilers do (still) write their executable to a file called a.out, if no output name is specified.