int 0x13
을 사용하면 필요한 섹터 수를로드하고 새 코드를 배치 한 위치로 이동할 수 있습니다. 두 번째 단계에서는 할 일이 없지만 코드를로드 할 때마다 DS
을 유효하게 설정해야합니다. 내 작은 OS 아카이브에서
예 :
당신이
times
명령에서 NASM을 사용하고있는 것처럼 보이기 때문에 피연산자의 순서를 반대로하는 것이 좋습니다 그래서 가스 형식의
/* BIOS loads the sectors into es:bx */
pushw $STAGE1_WORKSEG
popw %es
movw $STAGE1_OFFSET, %bx
read_stage1:
/* Try to read in a few sectors */
movb $0x2, %cl /* Sector */
movb $0x0, %ch /* Cylinder */
movb $0x0, %dh /* Head */
movb $0x0, %dl /* Drive */
movb $0x2, %ah /* BIOS read function */
/* How many sectors to load */
movb $STAGE1_SIZE, %al
int $0x13
jnc read_stage1_done
/* Reset drive */
xorw %ax, %ax
int $0x13
jmp read_stage1
read_stage1_done:
/* Perform a long jump into stage1 */
ljmp $STAGE1_WORKSEG, $STAGE1_OFFSET
call halt
halt:
/*
* Function: halt
* Synopsis: Sends the processor into a permanent halted status
* Notes:
* The only way out of this is to manually reboot
*/
hlt /* Halt the processor */
jmp halt
. 변수 이름은 자명해야합니다.
취미 OS를 개발중인 경우 http://forum.osdev.org/
은 같은 일을하는 다른 사람들의 지원을 받기에 좋은 장소입니다. 그것은 stackoverflow보다 좀 더 전문화되어 있고 많은 운영체제는 꽤 수수 할 수 있습니다.