AT&T Assembly Far Jump to reload CS:IP

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
teodori
Member
Member
Posts: 103
Joined: Wed Nov 14, 2012 4:55 pm

AT&T Assembly Far Jump to reload CS:IP

Post 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
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: AT&T Assembly Far Jump to reload CS:IP

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
teodori
Member
Member
Posts: 103
Joined: Wed Nov 14, 2012 4:55 pm

Re: AT&T Assembly Far Jump to reload CS:IP

Post 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
.
.
.
.
...
Post Reply