Page 1 of 1

Weird Little bug in my code.

Posted: Sun Feb 07, 2021 9:51 pm
by Armature
Hey guys, so I've been writing my OS on and off for about two years now and I've recently run into this quirky little bug. I have the following code snippet:

Code: Select all

mov ax, 0x0E00
mov ds, ax
jmp 0x0E00:0x0000
Now, this works fine. The code executes, jumps to the memory location and starts executing. Yay, but the following code snippet:

Code: Select all

mov ax, 0x0E00  ;Same as before
mov ds, ax    ;Same as before
mov cs, ax    ; different 
jmp 0x0000 ;once again different
This code however doesn't work. Why? As far as I know the CS segment uses IP as an offset which is what jmp sets to 0x0000, so this should have the same effect as jmp 0x0E00:0x0000 right? When this code is run, nothing happens. I just get the blinking cursor mono screen. Which indicates the code doesn't work as the first segment prints new information to the screen. Anyone know what's happening?

Re: Weird Little bug in my code.

Posted: Sun Feb 07, 2021 10:15 pm
by Octocontrabass

Re: Weird Little bug in my code.

Posted: Sun Feb 07, 2021 10:25 pm
by Armature
ohhhhhhh. Okay I get it now.