Page 1 of 1
8086 Opcodes
Posted: Fri Jun 28, 2013 5:33 am
by computertrick
I have looked at the opcodes of a short jump to 0x00 with org set to 0x7c00 and the opcodes I get are
I can understand if it said
But where the hell does the FD and 83 come from? Can anyone explain this and prehap's suggest a good reference for opcodes of 8086 please? I have looked around and I am having trouble with understanding short jumps.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 5:43 am
by sortie
Consult the Intel/AMD CPU documentation.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 5:45 am
by iansjack
And, when reading it, bear in mind that the jump is relative not absolute.
This is not a question about Operating System Development.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 6:38 am
by computertrick
iansjack wrote:And, when reading it, bear in mind that the jump is relative not absolute.
This is not a question about Operating System Development.
It is related to operating system development because its on about the processor.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 7:16 am
by Prochamber
computertrick wrote:I have looked at the opcodes of a short jump to 0x00 with org set to 0x7c00 and the opcodes I get are
I can understand if it said
But where the hell does the FD and 83 come from? Can anyone explain this and prehap's suggest a good reference for opcodes of 8086 please? I have looked around and I am having trouble with understanding short jumps.
This is
not jmp short 0x00 this is
jmp word 0x0000. You cannot jump to the address 0x0000 with a short jump because a short jump must be within -128 to +127.
Let's analyze this command:
E9 FD 83
The first byte E9 or 1110 1001 means 'jmp near'
You can look this up 16-bit encodings in Appendix D of
The Art of Assembly.
Chapter 6 is also a good reference for instructions just remember the examples code with be for MASM not NASM.
The next two bytes are the offset. This is relative not absolute. There are in 'little endian', i.e. least significant first, so they actually mean 0x83FD. The base offset is 0x7C00 and a near jump takes three bytes, therefore a base of 0x7C03. If you add 0x83FD you wrap right around back to zero.
If you are using NASM as your compiler you can use the 'ndisasm' command to disassemble your programs. Set the ORG point with '-o 0x7C00'.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 8:54 am
by computertrick
Prochamber wrote:computertrick wrote:I have looked at the opcodes of a short jump to 0x00 with org set to 0x7c00 and the opcodes I get are
I can understand if it said
But where the hell does the FD and 83 come from? Can anyone explain this and prehap's suggest a good reference for opcodes of 8086 please? I have looked around and I am having trouble with understanding short jumps.
This is
not jmp short 0x00 this is
jmp word 0x0000. You cannot jump to the address 0x0000 with a short jump because a short jump must be within -128 to +127.
Let's analyze this command:
E9 FD 83
The first byte E9 or 1110 1001 means 'jmp near'
You can look this up 16-bit encodings in Appendix D of
The Art of Assembly.
Chapter 6 is also a good reference for instructions just remember the examples code with be for MASM not NASM.
The next two bytes are the offset. This is relative not absolute. There are in 'little endian', i.e. least significant first, so they actually mean 0x83FD. The base offset is 0x7C00 and a near jump takes three bytes, therefore a base of 0x7C03. If you add 0x83FD you wrap right around back to zero.
If you are using NASM as your compiler you can use the 'ndisasm' command to disassemble your programs. Set the ORG point with '-o 0x7C00'.
Your right sorry I meant a near jump don't know why I put short jump. I see what you mean now.
Cheers
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 8:55 am
by Gigasoft
computertrick wrote:iansjack wrote:And, when reading it, bear in mind that the jump is relative not absolute.
This is not a question about Operating System Development.
It is related to operating system development because its on about the processor.
All computer programs, operating systems or not, run on a processor. If you are struggling to understand how to program the computer system you are using when such information is readily available from the manufacturer, I'd suggest putting off your operating system development for a while.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 9:07 am
by computertrick
Gigasoft wrote:computertrick wrote:iansjack wrote:And, when reading it, bear in mind that the jump is relative not absolute.
This is not a question about Operating System Development.
It is related to operating system development because its on about the processor.
All computer programs, operating systems or not, run on a processor. If you are struggling to understand how to program the computer system you are using when such information is readily available from the manufacturer, I'd suggest putting off your operating system development for a while.
No point putting it off for a while that's giving up... Where would people get if they just gave up on things.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 9:11 am
by Griwes
No point carrying on when you lack the basic knowledge and ability to read manuals.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 9:23 am
by AbstractYouShudNow
Why the hell do you need this for OSDev ?
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 9:32 am
by computertrick
Griwes wrote:No point carrying on when you lack the basic knowledge and ability to read manuals.
Well that's uncalled for... Didn't realise when you ask a question on these forum's big heads respond this way.
Re: 8086 Opcodes
Posted: Fri Jun 28, 2013 9:54 am
by AJ
Hi,
I've locked the thread.
@op: The reason for the responses you got is that the getting started and rules post in the forum ask you to do some basic research and a very full explanation of what you were asking is contained in the Intel Software Developers Manuals. Having said all that, I do think that the replies you got were a bit harsh and I do agree that opcodes are very relevant to OS development. As for a full reference, try
http://ref.x86asm.net/
Cheers,
Adam