0 Nerd-Its - +

CS register

Comment a comment by Anonymous, published on 30 December 2006
Navigate to the top level to view all replies to the article PC Bootstrap Loader Programming Tutorial in ASM
other nerds have left 5 comments below

The article correctly mentions the importance of setting up segment registers, yet like most neglects to set up CS (which is 0×0000). This is one nasty latent bug that shows itself as soon as you try doing indirect jumps. So if you want to use something like threaded code in your first stage bootloader set CS by "jmp 0×07c0:foo" first.

Thread parent sort order:
Thread verbosity:
0 Nerd-Its - +
CS Register Setting by VnutZ :: NR10

The article correctly mentions the importance of setting up segment registers, yet like most neglects to set up CS (which is 0×0000). This is one nasty latent bug that shows itself as soon as you try doing indirect jumps. So if you want to use something like threaded code in your first stage bootloader set CS by "jmp 0×07c0:foo" first.

You’re right – it would have been "good practice" to set the CS register. However, the CS register is already correctly set by the BIOS. If it were not set … a computer would never boot up! CS (code segment) and IP (instruction pointer) are both set to point directly at 0000:7C00 which is where the BIOS loads the bootsector into.

As far as using threaded code – that shouldn’t be necessary during a first stage loader. There isn’t enough room inside of 512 bytes to do anything fancier than loading the next stage. Especially from a generic point of view. Any additional configurations (protected mode, memory models, etc.) should be handled within the binary image that the first stage loads and jumps to.

The Showcase

Nerd-Its   Nerd Trends   Last Ten  

  1. RE: The true solution in Scientology: We've had it with you
  2. RE: Actually... in Scientology: We've had it with you
  3. RE: Actually... in Scientology: We've had it with you
  4. RE: The true solution in Scientology: We've had it with you
  5. RE: The true solution in Scientology: We've had it with you
  6. RE: Actually... in Scientology: We've had it with you
  7. RE: Actually... in Scientology: We've had it with you
  8. RE: The true solution in Scientology: We've had it with you
  9. RE: Actually... in Scientology: We've had it with you
  10. RE: Discussing Book of Mormon anachronisms in God before Country in the Military

What is OmniNerd?

Omninerd_icon Welcome! OmniNerd's content is generated by nerds like you. Learn more.

Voting Booth

The Interstate Commerce Clause of the U.S. Constitution empowers Congress to regulate?

2 votes, 0 comments