I read this article: http://static.patater.com/gbaguy/day3pc.htm
It includes the sentence
DON’T EVER CHANGE CS!!
But what exactly would happen if you did modify the CS segment register? Why is it so dangerous?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
csis the code segment.cs:ip, which meanscstogether withip(instruction pointer) points to the location of the next instruction. So any change tocsoripor to both changes the address from where the next instruction will be fetched and executed.Usually you change
cswith ajmp(long jump),call(long call),retf,int3,intoriret. In 8088 and 8086pop csis also available (opcode 0x0F).pop cswon’t work in 186+, in which the opcode 0x0F is reserved for multibyte instructions. http://en.wikipedia.org/wiki/X86_instruction_listingsThere is nothing inherently dangerous in long jump or long call. You just have to know where you jump or call and in protected mode you need to have sufficient priviledges to do it. In 16-bit real mode (eg. DOS) you can jump and call what ever address you wish, eg.
jmp 0xF000:0xFFF0setscsto0xF000andipto0xFFF0, which is the start address of BIOS code, and thus reboots the computer. Different memory addresses have different code and thus cause different kinds of results, in theory everything possible can happen (if you jump into BIOS code used for formatting hard-drive, with valid register and/or stack values, then the hard drive will be formatted ‘as requested’). In practicejmp‘s andcall‘s to most addresses probably result in invalid opcode or some other exception (divide by zero, divide overflow, etc.) quite soon.