Page 1 of 1

How do I know what hexadecimal value goes into ax for ltr?

Posted: Tue Aug 20, 2013 6:29 pm
by chrissacchi
How do I know what hexadecimal value goes into the AX for LTR (Load Task Register)? My TSS is the 7th entry for my data section of my GDT. Which value do I use?

bochs prints the one message that is important to look at:

Code: Select all

LTR: doesn't point to an available TSS descriptor!

Re: How do I know what hexadecimal value goes into ax for lt

Posted: Wed Aug 21, 2013 12:33 am
by feryno
Hi chrissacchi,
did you execute the LTR AX only once or more times (more times e.g. in case of multitasking)?
If bochs reports the error message for the first LTR AX then you have an error/mistake in your GDT/TSS or you put wrong value into AX, if the error message appears at the second LTR AX (with the same AX value and the first LTR AX passed OK) then you need to implement this:
When executing the LTR for the first time - the available task changes to busy task (1 bit in GDT changes from 0 to 1). If you want to do LTR for the second time then change busy task to available task before executing the LTR AX (just change 1 bit from 1 to 0 in GDT - refer to CPU manuals).

Re: How do I know what hexadecimal value goes into ax for lt

Posted: Wed Aug 21, 2013 7:46 am
by chrissacchi
I executed it only once, but I don't know which value to put in AX for the LTR instruction. Is there a specific way to find out?

Re: How do I know what hexadecimal value goes into ax for lt

Posted: Wed Aug 21, 2013 7:50 am
by AJ
Hi,

Just looking at the error output, is your GDT limit correct? You can find how to use LTR in the intel Software Developers Manuals.

Cheers,
Adam

Re: How do I know what hexadecimal value goes into ax for lt

Posted: Wed Aug 21, 2013 11:59 am
by egos
chrissacchi wrote:I executed it only once, but I don't know which value to put in AX for the LTR instruction. Is there a specific way to find out?
Do you know what a selector is? In simplest case it's an offset of descriptor in GDT.

Re: How do I know what hexadecimal value goes into ax for lt

Posted: Mon Aug 18, 2014 7:35 am
by Mohsen
you can tell the selector by multiplying your entry number which is 7 (remember to start counting from zero) by the size of each GDT entry which is 8 so your selector is 0x38.
If it works please tell me.