flat assembler
Message board for the users of flat assembler.
Index
> Main > near far jums calls |
Author |
|
MCD 14 Feb 2005, 10:46
That's a quiet nebie question, but I will try to answer it anyway.
Near addresses have only an offset value, whereas far addresses have a (always) 16bit segment value/selector too. Thus, there are 6 basic possibilites for the call instruction with direct values: Code: in RM: call 16bit_offset 1+2 bytes call 16bit_segment_value:16bit_offset 1+2+2 bytes in 16bit PM: call 16bit_offset 1+2 bytes call 16bit_segment_selector:16bit_offset 1+2+2 bytes in 32bit PM: call 32bit_offset 1+4 bytes call 16bit_segment_selector:32bit_offset 1+2+4 bytes Note that you can (try to) code calls with 32bit offsets in both RM and 16bit PM, but they won't usually work (CPU limited code <1Mb). You can also try to code calls with 16bit offsets in 32bit PM. I both of these cases, where you call an offset with another size, the machine instruction needs an additional prefix, e.g. the addr. size 67h. So, there are far calls in PM, but you usually don't use them in PM, since most 32bit PM OSes user code uses a rather flat memory approach and thus you don't need segment selectors. It's usually reserved for the Kernel and some drivers. |
|||
14 Feb 2005, 10:46 |
|
Madis731 14 Feb 2005, 11:05
I think you haven't done your homework
but the general rule is when the address that is being jumped to is ±127 bytes, then you can use near jump, otherwise you need more bytes to describe how far you'd like to jump. Totally different is absolute jump that doesn't add to(sub from) but replaces the address of the destination with (E)IP. calls and stack? What about them? |
|||
14 Feb 2005, 11:05 |
|
HarryTuttle 14 Feb 2005, 14:42
is it true that if I calls far procedure then CS is pushed on the stack after offset?
_________________ Microsoft: brings power of yesterday to computers of today. |
|||
14 Feb 2005, 14:42 |
|
MazeGen 17 Feb 2005, 16:58
That's not true, CS is always pushed before EIP. Note that in 32-bit protected mode is pushed CS padded with 16 high-order bits.
|
|||
17 Feb 2005, 16:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.