Skip to main content
GameDev.net gamedev.net
🔒 Locked

far jmp?

Started by Witchcraven Oct 30, 2002 at 9:29 PM 3 replies 350+ views
Original Post
Witchcraven
Witchcraven
I have been studying assembly langauge, but I need to perform a far jump. problem is, I dont know what a far jump is. Can someone tell me?
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved
Fruny
Fruny
In real-mode 16bit asm, addresses can be local to a segment or include segment information. A jump involving an address with segment+offset information is a far jump.

It is irrelevant in 32bit flat mode.

Note: that''s what those ''FAR'' macros stand for in the windows API.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
BeerNutts
BeerNutts
quote:
It is irrelevant in 32bit flat mode.


Well, that''s generally true, but for other architecture''s far jump takes on another meaning (MIPS esp.)

You can jump two different ways:
j Address
or
jr Register

using the j address, the instruction can only be 32 bits, so the top 6 bits are the op-code, and the bottom 26 bits are the address to jump to (shifted left twice, since it must be on 4-byte boundary). This means, if a jump is occuring from an address over 28 bits away from the current PC, you can''t use j Address.

You can use jr Register to jump to the address stored in the register since it is 32-bits regadless.

This is what the #pragma far_call on/off is used for in C compilation code.

Just a lesson on other architectures.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)
Witchcraven
Witchcraven
thanks. I am on the x86, but its not in flat mode. I need to do the far jump from a 16 bit segment to a 32 bit(writing bootloader)
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved
Jan Wassenberg
Jan Wassenberg
A pmode far jump (needed to get into 32 bit mode) loads a segment selector into cs and jumps to the specified offset in this segment.
Code: jmp dword sel:ofs (opcode 0xea)
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.