2016-12-20 1 views
0

je suis en train de construire un noyau 16 bits dans l'assemblage gnu gcc alors que mon bootloader est écrit en assembleur pur, mais j'ai du mal à imprimer des chaînes tout seul caractère sont d'accord:noyau d'assemblage gnu gcc en mode réel

Voici mon bootloader.asm:

org 0x7c00 
bits 16 



    section .text 
mov ax,0x1000 
mov ss,ax 
mov sp,0x000 
mov esp,0xfffe 



xor ax,ax 
mov es,ax 
mov ds,ax 


mov [bootdrive],dl 


mov bh,0 
mov bp,zeichen 

mov ah,13h 
mov bl,06h 
mov al,1 
mov cx,6 
mov dh,010h 
mov dl,01h 

int 10h 

load: 
mov dl,[bootdrive] 
xor ah,ah 
int 13h 
jc load 

load2: 
mov ax,0x1000 
mov es,ax 
xor bx,bx 

mov ah,2 
mov al,1 
mov cx,2 
xor dh,dh 

mov dl,[bootdrive] 
int 13h 
jc load2 


mov ax,0 
mov es,ax 

mov bh,0 
mov bp,zeichen3 

mov ah,13h 
mov bl,06h 
mov al,1 
mov cx,13 
mov dh,010h 
mov dl,01h 

int 10h 

mov ax,0x1000 
mov es,ax 
mov ds,ax 
jmp 0x1000:0x000 

zeichen db 'hello2' 
zeichen3 db 'soweit so gut' 
bootdrive db 0 
times 510 - ($-$$) hlt 
dw 0xaa55 

et voici mon kernel.c:

asm("jmp main"); 


void print() 
{ 
    for(int i=0;i<5;i++) 
    { 
    asm("mov $0x0e,%ah"); 
    asm("mov $0x00,%bh"); 
    asm("mov %0,%%al":: "" ('g')); 
    asm("int $0x10"); 
    } 
} 
void main() 
{ 

    asm("mov $0x1000,%eax;" 
     "mov %eax,%es;" 
     "mov %eax,%ds"); 
    const char string[]="hall0"; 
    print(); 
    for(int i=0;i<5;i++) 
    { 
     asm("mov $0x0e,%ah"); 
     asm("mov $0x00,%bh"); 
     asm("mov %0,%%al":: "" (string[i])); 
     asm("int $0x10"); 
    } 

    asm(".rept 512;" 
     " hlt ;" 
     ".endr"); 
} 

les commandes i utilise sont: nasm -f bin -o bootloader.bin bootloader.asm et gcc kernel.c -c -o kernel.o -m16 -nostdlib -ffreestanding&&ld -melf_i386 kernel.o -o kernel.elf&&objcopy -O binary kernel.elf kernel.o&&cat bootloader.bin kernel.elf>myOS.bin&&qemu-system-i386 myOS.bin sur ma Linux Mint Cinnamon version 18. Il imprime 10 g après "soweit so gut" ce sont les 5 g qu'il devrait imprimer plus le nombre de caractères de "hall0" mais je ne pas imprimer "hall0". Donc, je dois avoir fait quelque chose de mal dans le bootloader.asm pour l'utilisation de l'assembleur gcc gnu, peut-être mis en place la pile faux ou quelque chose. Peut-être que quelqu'un peut m'aider à faire quoi?

+0

Les commentaires ne sont pas pour une discussion prolongée; cette conversation a été [déplacée pour discuter] (http://chat.stackoverflow.com/rooms/131026/discussion-on-question-by-albert-gcc-gnu-assembly-kernel-in-real-mode). –

Répondre

-1

Vous devez compiler 'kernel.asm' dans un fichier bin et ensuite faire la commande cat