I want to update Data Segment selector to point to some other entry in GDT. But Since I am very new to assembly, I can not do it in my code. However I have updated the Code Segment Selector by using following assembly instruction:
ljmp $(GDT_TABLE_INDEX), $(1f) //This instruction simply points code segment to some other entry in GDT and move to next label.
Is there some similar or alternative instruction to update Data Segment Selector also ?
You can change the data segment selector using the mov
instruction. For example, if you want to set ds
to 0x1234
, use:
mov $1234, %ax
mov %ax, %ds
Note that there is no mov imm, sreg
instruction, so you first have to move the selector's number into a general purpose register. You might also find it convenient to pop
into a segment register:
push $1234
pop %ds