Page 1 of 1
AT&T Assembly Far Jump to reload CS:IP
Posted: Fri Nov 23, 2012 5:06 pm
by teodori
Hello,
is it possible to do a far like this:
Code: Select all
initseg:
.word 0x0050
initoff:
.word 0x0000
ljmp initseg, initoff # does not work
ljmp $0x0050, $0x0000 # works
Thank you
Re: AT&T Assembly Far Jump to reload CS:IP
Posted: Fri Nov 23, 2012 6:39 pm
by thepowersgang
I suggest you read the intel manuals, the type of jump you want is possible, but that is not the way to do it.
Re: AT&T Assembly Far Jump to reload CS:IP
Posted: Fri Nov 23, 2012 8:22 pm
by teodori
Hy found it
Code: Select all
BOOTDEV = 0x01ff
BOOTSEG = 0x07c0
INITSEG = 0x0050
.section .rodata
msg:
.asciz "booting..."
msgend:
msglen:
.word (msgend - msg)
errmsg:
.asciz "disk error!"
errmsgend:
errmsglen:
.word (errmsgend - errmsg)
.section .text
.globl Start
Start:
.code16
ReloadCsIp:
movw $BOOTSEG, %ax
movw %ax, %ds # Set Data Segment
movw %ax, %es # Set Extra Segment
movw %ax, %fs # Set Data2 Segment
movw %ax, %gs # Set Data3 Segment
movw %ax, %ss # Set Stack Segment
ljmp $BOOTSEG, $SaveDev
SaveDev:
movb %dl, BOOTDEV # Save Boot Device to Memory
.
.
.
.
...