I'm a newbee learning operating system online, in which bootsect.s is mentioned: https://kernel.googlesource.com/pub/scm/linux/kernel/git/nico/archive/+/v0.99-pl8/boot/bootsect.S But this piece of code is quite strange to me:
mov ax,#BOOTSEG
mov ds,ax
mov ax,#INITSEG
mov es,ax
mov cx,#256
sub si,si
sub di,di
cld
rep
movsw
jmpi go,INITSEG
The strange part is the last 3 lines. According to my understanding, rep movsw
has already move the code itself away, so when pc points to jumpi
and when the computer is about to execute the code pointed by pc, it should cause an error because the code jumpi go, INITSEG
has been moved away. So how come this code still works and jumpi go, INITSEG
can still be found and executed?