Talk:Far Call Trick

From OSDev Wiki
Jump to: navigation, search

I'm not sure why you start by making a far jump to a known location. Why not use this shorter code (not tested, but should AFAIK work - I did something similar in pmode once):

mov ax, 0              ; New IP
mov bx, 0x2000         ; New CS

push bx                ; Push new CS
push ax                ; Push new IP

retf                   ; Sneaky far jump

As a wiki article it would be nice to explain how the trick works. You should also mention the code is for real mode.

--Walling 12:05, 5 January 2009 (UTC)

Or what about

push cs
push word return_address
push word [segment_no]
push word 0

Or (most logical one)

mov word [segment_no-2], 0
call far [segment_no-2]

@Walling, your code works like a far jump - Combuster 16:17, 5 January 2009 (UTC)

Well that works too, thanks for the suggestions! --Troy Martin 02:43, 6 January 2009 (UTC)

Personal tools