x86 processors have variants of JMP
and CALL
where you specify a new value for CS
(the code segment register). This is known as a far JMP/CALL
, and the exact syntax differs between different assemblers. If we use NASM as an example, you'd write:
; Do an inter-segment jump to the label named foobar
jmp (seg foobar):foobar
; Do an inter-segment call to the subroutine named foobar
call (seg foobar):foobar
There might be assemblers that are smart enough to figure out to generate a far jump even if you just wrote jmp foobar
and foobar
is located in a different segment, though I can't name any examples since this isn't something I've tested.