2016-09-26 6 views
3

현재, 처음부터 아주 작은 OS를 작성하려고합니다. 불행히도, 첫 번째 단계에서 나는 미친 듯이 움직이는 문제에 직면했다. 내 부트 로더로 다음 코드를 작성합니다. 다음 단계에서Bochs가 img 파일을로드하고로드 할 수 없습니다.

.code16     #generate 16-bit code 
.text      #executable code location 
    .globl _start; 
_start:     #code entry point 
    . = _start + 510  #mov to 510th byte from 0 pos 
    .byte 0x55   #append boot signature 
    .byte 0xaa   #append boot signature 

, 나는 다음 명령을 사용하여 컴파일 :

그런 다음
as bootloader.s -o bootloader.o 
ld –Ttext 0x7c00 --oformat=binary bootloader.o –o bootloader.bin 

나는 다음과 같은 명령이있는 IMG 파일 생성 : 마지막으로

dd if=/dev/zero of=boot.img bs=512 count=2880 
dd if=bootloader.bin of=boot.img 

를, 내가 Bochs와 명령을 실행할 때 터미널에서 보크스는 나에게 어두운 창문을 보여 주었고 아무 것도 나타나지 않았다. 뭐가 잘못 되었 니?

또한 다음 코드를 부트 로더로 시도했지만 그 결과는 이전과 같습니다.

.code16     #generate 16-bit code 
.text     #executable code location 
    .globl _start; 

_start:     #code entry point 

    #print letter 'H' onto the screen 
    movb $'H' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'e' onto the screen 
    movb $'e' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'l' onto the screen 
    movb $'l' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'l' onto the screen 
    movb $'l' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'o' onto the screen 
    movb $'o' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter ',' onto the screen 
    movb $',' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print space onto the screen 
    movb $' ' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'W' onto the screen 
    movb $'W' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'o' onto the screen 
    movb $'o' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'r' onto the screen 
    movb $'r' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'l' onto the screen 
    movb $'l' , %al 
    movb $0x0e, %ah 
    int $0x10 

    #print letter 'd' onto the screen 
    movb $'d' , %al 
    movb $0x0e, %ah 
    int $0x10 

    . = _start + 510  #mov to 510th byte from 0 pos 
    .byte 0x55   #append boot signature 
    .byte 0xaa   #append boot signature 
+1

무한 루프에 들어가려면 코드 끝에 "jmp."와 같은 것을해야합니다. 그렇지 않으면 마지막으로'int $ 0x10'에 메모리에있을 수있는 것을 실행하게됩니다. –

+0

바람직하게는 ' 'jmp .' 대신'endloop : hlt''jmp endloop'을 써라. 어느 것이 든 코드 끝 부분에 놓을 수 있습니다. –

+0

다시는 아무것도 표시되지 않았습니다. bochs 그냥 어두운 화면이 표시됩니다. :( – Adonaim

답변

0

제대로 작동하려면 bochs 파일을 만들어야합니다. 또한 가상 머신을 사용할 수 있습니다. 나는 당신의 코드를 테스트하고 잘 동작한다.

+0

고마워, 고쳤다. – Adonaim