Plain binary format spec

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
eeoam
Posts: 5
Joined: Sat May 16, 2009 5:39 pm

Plain binary format spec

Post by eeoam »

Hi all,

The NASM compiler can generate plain binary format files e.g. for bootloader code. Does anyone have a link to the plain binary format specification?
User avatar
scgtrp
Member
Member
Posts: 30
Joined: Sat Mar 28, 2009 7:32 pm

Re: Plain binary format spec

Post by scgtrp »

There is no format. The code is just dumped into a file.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Plain binary format spec

Post by Troy Martin »

Yeah, that about sums it up. That's why it's called a plain flat binary.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
eeoam
Posts: 5
Joined: Sat May 16, 2009 5:39 pm

Re: Plain binary format spec

Post by eeoam »

Thanks for your replies!

So, if I understand you write compiling

mov ah 0Eh

to plain binary would just be the binary representation of the mov instruction? Interesting.
Where might I find the binary representations of the intel instructions? (I glanced at the Intel manual but I couldn't seem to find it...)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Plain binary format spec

Post by pcmattman »

Intel manuals, volumes 2A and 2B - Instruction set reference.
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Re: Plain binary format spec

Post by ehenkes »

In my tutorial I run a flat binary as a demo within a task in mulktitasking:

Code: Select all

[BITS 32]
start:
   Mov [0x000b8000], byte 'T'
   Mov [0x000b8002], byte 'e'
   Mov [0x000b8004], byte 's'
   Mov [0x000b8006], byte 't'
   Ret
Result as a falt binary in the memory:
c6 05 00 80 0b 00 54 c6 05 02 80 0b 00 65 c6 05 04 80 0b 00 73 c6 05 06 80 0b 00 74 c3
http://www.henkessoft.de/OS_Dev/OS_Dev2 ... ocId188270
eeoam
Posts: 5
Joined: Sat May 16, 2009 5:39 pm

Re: Plain binary format spec

Post by eeoam »

Are the binary codes for register names also in the intel instruction manual?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Plain binary format spec

Post by pcmattman »

Every opcode is in the Intel manuals (2A and 2B). For example, it has tables showing the unique opcodes for each different variation of mov.
eeoam
Posts: 5
Joined: Sat May 16, 2009 5:39 pm

Re: Plain binary format spec

Post by eeoam »

What I mean ito ask is, what is the 'name' in binary of, say, the AH register?
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: Plain binary format spec

Post by kop99 »

Every opcode is in the Intel manuals (2A and 2B)
You could find that in the Intel manuals (2A and 2B).
Did you ever read that reference?????
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Plain binary format spec

Post by neon »

eeoam wrote:So, if I understand you write compiling

mov ah 0Eh

to plain binary would just be the binary representation of the mov instruction? Interesting.
That is not compiling, it is assembling. And yes, it would be 0xb40e. You can find this out yourself by looking at the intel manuals or (what I used) the debug program that comes with Windows.

If you are looking for why it is a certain opcode, look at the instruction format used in the i86 architecture (located in the Intel manuals posted earlier.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
eeoam
Posts: 5
Joined: Sat May 16, 2009 5:39 pm

Re: Plain binary format spec

Post by eeoam »

Quote:
Every opcode is in the Intel manuals (2A and 2B)
You could find that in the Intel manuals (2A and 2B).
Did you ever read that reference?????
I've downloaded Intel manual 2A and I am currently making my way through it. Unfortunately I have not yet been able to commit the 812 page document to memory.

By the by is there a way to obtain a hard copy of these documents? (I thought I saw a link to do so on the Intel site but I can't find it again.)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Plain binary format spec

Post by pcmattman »

You don't need to memorise the entire thing. You use it as a reference when you want to know the opcode for an instruction.

The only reasons I can think of for doing that are:
  • Debugging - you read what's at EIP and get the instruction
  • Creating binary files by hand - rather than using assembly and an assembler, you use a hex editor to create a binary with the correct opcodes
  • Understanding how assembly links to machine code
And you can obtain a copy of the Intel Manuals. Go to the page at which you get the PDFs for each manual and there should be a link for ordering.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Plain binary format spec

Post by Brynet-Inc »

The hard copy editions are free.. that includes shipping.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
whowhatwhere
Member
Member
Posts: 199
Joined: Sat Jun 28, 2008 6:44 pm

Re: Plain binary format spec

Post by whowhatwhere »

Brynet-Inc wrote:The hard copy editions are free.. that includes shipping.
For most places. I've heard of people in the UK and parts of the EU getting charged extra but it insignificant.
Post Reply