flat assembler
Message board for the users of flat assembler.
Index
> Main > Mixing assembly and C... Goto page Previous 1, 2 |
Author |
|
White-spirit 06 Apr 2008, 14:48
Thanks revolution .
I've added a prolog to my call_test function and it works ,at least, it doesn't reboot but the ( . ) is not printed on the screen :s Here's the code : Code: format ms coff public call_test call_test: push ebp mov ebp, esp sub esp, 4 push '.' call putchar add esp,4 leave ret |
|||
06 Apr 2008, 14:48 |
|
revolution 06 Apr 2008, 14:57
Why do you have "sub esp, 4", that is not needed
|
|||
06 Apr 2008, 14:57 |
|
White-spirit 06 Apr 2008, 15:34
Without the "sub esp, 4" the kernel reboot, and I've found it here : http://www.milw0rm.com/papers/52 .
|
|||
06 Apr 2008, 15:34 |
|
revolution 06 Apr 2008, 16:09
White-spirit wrote: Without the "sub esp, 4" the kernel reboot, and I've found it here : http://www.milw0rm.com/papers/52 . |
|||
06 Apr 2008, 16:09 |
|
White-spirit 06 Apr 2008, 16:14
Can I post here my boot sector ( in asm ) and my kernel's ( C ) source code and my GCC and binutils version ?
Thanks |
|||
06 Apr 2008, 16:14 |
|
revolution 06 Apr 2008, 16:19
White-spirit wrote: Can I post here my boot sector ( in asm ) and my kernel's ( C ) source code and my GCC and binutils version ? Have a search around here for other boot sectors people have posted previously. You might get some insight from reading how other approached the problem. |
|||
06 Apr 2008, 16:19 |
|
White-spirit 06 Apr 2008, 16:34
Okay thanks, here's my boot sector's code :
Code: use16 org 0x7C00 ;;;;;;;;; Loading the Kernel from floppy to 0x1000 ;;;;;;;;; xor ax, ax ; ax <== 0 mov es, ax ; es <== ax <== 0 mov bx, 0x1000 ; destination adress mov ah, 0x2 ; function 02h ( reading sectors ) mov al, 0xE ; 14 sectors xor ch, ch ; ch <== 0 ( cylinder 0 ) mov cl, 0x2 ; sector 2 xor dx,dx ; ( dh <== 0 , dl <== 0 ) int 0x13 ;;;;;;;;; Memory infos ;;;;;;;;; ; coming soon ; ;;;;;;;;; Entering Protected Mode ;;;;;;;;; cli ; disables interrupts xor ax,ax ; ax <== 0 mov ds,ax ; ds <== 0 lgdt [gdt_desc] mov eax,cr0 ; eax <== cr0 xor eax,eax inc eax ; eax <== 1 mov cr0,eax ; cr0 <== 1 ;;;;;;;;; Jumping to Kernel ;;;;;;;;; jmp dword 0x8:jmp_kernel use32 ; using 32 bits instructions jmp_kernel: mov ax,0x10 ; ax <== 10h mov ds,ax ; ds <== 10h mov ss,ax ; ss <== 10h mov es,ax ; es <== 10h mov fs,ax ; fs <== 10h mov gs,ax ; eg <== 10h mov esp, 0x90000 ; sets stack at 090000h finit ; initializing FPU registers jmp dword 0x8:0x1000 jmp $ ;;;;;;;;; Initializing GDT ;;;;;;;;; gdt: gdt_null: gdt_desc: dw gdt_end - gdt - 0x1 dd gdt dw 0x0 gdt_code: dw 0xFFFF dw 0x0 db 0x0 db 0x9A db 0xCF db 0x0 gdt_data: dw 0xFFFF dw 0x0 db 0x0 db 0x92 db 0xCF db 0x0 gdt_end: times 510-($-$$) db 0x90 ; Fills the file with Nop's dw 0xAA55 ; MBR signature |
|||
06 Apr 2008, 16:34 |
|
DJ Mauretto 06 Apr 2008, 19:23
Hello
Code: ;;;;;;;;; Initializing GDT ;;;;;;;;; align 16 gdt: gdt_null: dw 0x0 dw 0x0 dw 0x0 dw 0x0 gdt_code: dw 0xFFFF dw 0x0 db 0x0 db 0x9A db 0xCF db 0x0 gdt_data: dw 0xFFFF dw 0x0 db 0x0 db 0x92 db 0xCF db 0x0 gdt_end: gdt_desc: dw gdt_end - gdt - 0x1 dd gdt Code: ;;;;;;;;; Entering Protected Mode ;;;;;;;;; cli ; disables interrupts xor ax,ax ; ax <== 0 mov ds,ax ; ds <== 0 lgdt [gdt_desc] mov eax,cr0 ; eax <== cr0 or eax,1 ; eax <== 1 mov cr0,eax ; cr0 <== 1 |
|||
06 Apr 2008, 19:23 |
|
White-spirit 07 Apr 2008, 07:44
Thanks but it's still the same :s
|
|||
07 Apr 2008, 07:44 |
|
edfed 07 Apr 2008, 08:34
Code: mov ax, 100h ; ax <== 100h mov es, ax ; es <== ax <== 100h xor bx,bx ; sometimes, it bugs to put a non zero offset in BX. mov ah, 0x2 ; function 02h ( reading sectors ) mov al, 0xE ; 14 sectors xor ch, ch ; ch <== 0 ( cylinder 0 ) mov cl, 0x2 ; sector 2 xor dx,dx ; ( dh <== 0 , dl <== 0 ) int 0x13 are you sure the kernel is orged at 1000h ??? Mods: note you can move this thread in OS construction. |
|||
07 Apr 2008, 08:34 |
|
White-spirit 07 Apr 2008, 10:44
Otherwise the kernel would not have shown messages on the screen before restarting, right?
PS : I thought it was juste a problem with linking the MS COFF object using ld so I asked here . |
|||
07 Apr 2008, 10:44 |
|
White-spirit 07 Apr 2008, 12:46
Yeah, i used "format elf" instead of MS COFF and it works =')
|
|||
07 Apr 2008, 12:46 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.