I came across this in the processor manual: "use segment prefix with any branch instruction is reserved". However I have seen code like JMP DWORD PTR DS:, which runs fine. I hope someone could clarify it for me. Thanks.
Posted on 2003-04-29 01:09:04 by C.Z.
DS is the standard segment. However if you want to access other segments you have to use prefixes.

From intel manual
? 2EH?CS segment override (use with any branch instruction is reserved).
? 36H?SS segment override prefix (use with any branch instruction is reserved).
? 3EH?DS segment override prefix (use with any branch instruction is reserved).
? 26H?ES segment override prefix (use with any branch instruction is reserved).
? 64H?FS segment override prefix (use with any branch instruction is reserved).
? 65H?GS segment override prefix (use with any branch instruction is reserved).

PS: the hexadecimal numbers being the prefix.
Posted on 2003-04-29 07:08:38 by roticv
hrm, would this (for instance) imply you should't jump to a code pointer stored on the stack?

Iirc, segment override (==segment prefix, right?) is used on P4 for branch hints on conditional branches... but what about direct jump/call?
Posted on 2003-04-29 07:54:19 by f0dder
Yes 2Eh and 3Eh are used as jump hints with jcc, however I do not think it applies to p4 only. (Not too sure anyway)
Posted on 2003-04-29 07:58:02 by roticv
for near conditional branches, the segment overrides should be no-op...
As for their hinting effect, might work on some later model athlons too? Can't remember though.
Posted on 2003-04-29 08:33:09 by f0dder
roticv: isn't SS the default segment for ?
fOdder: what's no-op???
Posted on 2003-04-29 08:56:23 by C.Z.
no-op = no operation. Instruction that does nothing. Examples:
xchg eax,eax / NOP - this is the most famous perhaps :).
Posted on 2003-04-29 08:59:28 by f0dder
My mistake you are correct.
Posted on 2003-04-29 09:00:07 by roticv
f0dder & roticv
I see, thanks.

So the questions is if unconditional JMPs and CALLs may use seg override.
Posted on 2003-04-29 09:25:25 by C.Z.
I guess that depends on what intel means by branch instruction. It makes sense for Jcc, since you're not dealing with memory operands.

For jmp/call, it wouldn't make sense to me. Somebody should look up the intel definition of branch.
Posted on 2003-04-29 09:28:01 by f0dder
How would anybody debug a mess like that??????
any assembly programmer who uses a calculated
jump should be shot!
Posted on 2003-04-30 20:37:57 by rob.rice
JMP and CALL are several instructions.

JMP/CALL displacement (relative jump/call)
JMP/CALL reg/mem (indirect jump/call)
JMP/CALL absolute-segment:offset (absolute jump/call)

Segment overrides make sense only for the indirect jumps and calls that fetch addresses from memory.

The conditional jumps are all relative jumps -- segment overrides, if it were allowed, would have been hazardous to use.
Posted on 2003-04-30 21:55:43 by tenkey
Prefixes...

CS override: 0x2E
DS override: 0x3E

These change meaning when used with Jcc:
hint, branch not taken: 0x2E
hint, branch taken: 0x3E
Posted on 2003-05-01 02:31:25 by f0dder