Page 1 of 2
Plain binary format spec
Posted: Sat May 16, 2009 5:43 pm
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?
Re: Plain binary format spec
Posted: Sat May 16, 2009 5:45 pm
by scgtrp
There is no format. The code is just dumped into a file.
Re: Plain binary format spec
Posted: Sat May 16, 2009 6:08 pm
by Troy Martin
Yeah, that about sums it up. That's why it's called a plain flat binary.
Re: Plain binary format spec
Posted: Tue May 19, 2009 3:58 am
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...)
Re: Plain binary format spec
Posted: Tue May 19, 2009 4:36 am
by pcmattman
Intel manuals, volumes 2A and 2B - Instruction set reference.
Re: Plain binary format spec
Posted: Tue May 19, 2009 4:12 pm
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
Re: Plain binary format spec
Posted: Wed Jun 03, 2009 7:16 am
by eeoam
Are the binary codes for register names also in the intel instruction manual?
Re: Plain binary format spec
Posted: Wed Jun 03, 2009 7:18 am
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.
Re: Plain binary format spec
Posted: Fri Jun 05, 2009 3:59 am
by eeoam
What I mean ito ask is, what is the 'name' in binary of, say, the AH register?
Re: Plain binary format spec
Posted: Fri Jun 05, 2009 4:25 am
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?????
Re: Plain binary format spec
Posted: Fri Jun 05, 2009 7:23 am
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.)
Re: Plain binary format spec
Posted: Mon Jun 08, 2009 2:29 am
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.)
Re: Plain binary format spec
Posted: Mon Jun 08, 2009 2:55 am
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.
Re: Plain binary format spec
Posted: Mon Jun 08, 2009 9:16 am
by Brynet-Inc
The hard copy editions are free.. that includes shipping.
Re: Plain binary format spec
Posted: Mon Jun 08, 2009 9:18 am
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.