Hello, i am debugging my code on bochs. at a point as you can see cs:ip is 0x0000:0x7eef and the next instruction is supposed to be at 0x0000:0x7ef2. but when i execute "s 1" command( which executes only one instruction), it executes "push ax" at address f000:e9df. do you have any idea why i get such a behaviour?
picture : http://i.imgur.com/H4vhB1g.jpg
Bochs wrong instruction executed
Re: Bochs wrong instruction executed
I can't really read your screen shot, but I'm guessing you have triggered an exception and are seeing the first instruction of the exception handler.
-
- Member
- Posts: 5587
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Bochs wrong instruction executed
It looks like Bochs is telling you exactly what's wrong.
Code: Select all
00014176438e[CPU0 ] write_virtual_word_32(): segment limit violation
Re: Bochs wrong instruction executed
I am in real mode, do you have any idea about the triggered exception by executing the following commands?
(disassembly has generated by OBJDUMP command)
Code: Select all
7eef: 67 89 02 mov WORD PTR [edx],ax
7ef2: 66 a1 1c 00 mov eax,ds:0x1c
Last edited by atilali on Sat May 27, 2017 7:51 am, edited 2 times in total.
Re: Bochs wrong instruction executed
Hi,
Cheers,
Brendan
In real mode the segment limits are all 64 KiB, so if EDX contains a value that is larger than 0x0000FFFC (which is "0x00010000 - 4") when you execute "mov WORD PTR [edx],ax" you get a General Protection Fault (exception) because of a segment limit violation.atilali wrote:I am in real mode, do you have any idea about the triggered exception by executing the following commands?Code: Select all
7eef: 67 89 02 mov WORD PTR [edx],ax 7ef2: 66 a1 1c 00 mov eax,ds:0x1c
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Bochs wrong instruction executed
Thank you Brendan!
EDX had the value of 0xb8000. Is it allowed to use EDX register for addressing like that(MOV WORD PTR [edx],ax) in real mode? I didn't know that i am unable to address beyond 0xFFFC even though it's allowed to use edx(if it is allowed). i will use segment:offset addresing to fix the problem.
EDX had the value of 0xb8000. Is it allowed to use EDX register for addressing like that(MOV WORD PTR [edx],ax) in real mode? I didn't know that i am unable to address beyond 0xFFFC even though it's allowed to use edx(if it is allowed). i will use segment:offset addresing to fix the problem.
Re: Bochs wrong instruction executed
Hi,
In 32-bit code it's the opposite - the default is "32 bit", but the same prefixes can be used to override that if you want to use 16-bit registers/addresses/instructions. For 64-bit code things get a little strange - the default is typically "32-bit", and prefixes can be used to get 16-bit or 64-bit.
Fortunately the assembler will handle the size override prefixes for you (you can just do whatever you like and let the assembler figure them out.
Cheers,
Brendan
Yes. In real mode (and in 16-bit code in general - e.g. including 16-bit protected mode code) the default is "16 bit", but that default can be overridden with instruction prefixes and nothing prevents you from using 32-bit registers/addresses/instructions (with appropriate size override prefixes) if the CPU supports it (80386 or later).atilali wrote:Is it allowed to use EDX register for addressing like that(MOV WORD PTR [edx],ax) in real mode?
In 32-bit code it's the opposite - the default is "32 bit", but the same prefixes can be used to override that if you want to use 16-bit registers/addresses/instructions. For 64-bit code things get a little strange - the default is typically "32-bit", and prefixes can be used to get 16-bit or 64-bit.
Fortunately the assembler will handle the size override prefixes for you (you can just do whatever you like and let the assembler figure them out.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.