Hello,
I am using the following code for reading the kernel of 128 sectors.
when i allocate stack to the kernel and pass control to it,its code is not executed.Could you plz help me what is wrong in the following code??
Thanks,
########################################################
.equ BOOT_SEGMENT,0x07c0
.equ DISPLAY_SEGMENT,0xb800
equ SECTOR_SIZE, 0x0200
.text # Code segment
.globl _start # The entry point must be global
.code16 # Real mode
_start:
jmp over
os_size:
.long 0x00000000
drive_number:
.byte 0x00
max_sector:
.byte 0x00
max_head:
.byte 0x00
over:
movw $NEW_BOOT_SEGMENT, %ax #The address where the bios loaded the bootloader
movw %ax, %ds
movb %dl, drive_number #Address of the boot device
movb $0x08, %ah #getting parameters of boot device
int $0x13
andb $0x3f, %cl
movb %cl, max_sector
movb %dh, max_head
movw os_size, %bp #loop counter
movw $0x0002, %cx
movb $0x00, %dh
movw $0x0000, %ax
movw %ax, %es
movw $0x0100, %bx
read_sectors:
cmpw $0x0000, %bp #termination check
jng after_load
decw %bp
movw $0x0201, %ax #reading 1 sector at a time
int $0x13
jc error #if cf=1
cmpb max_sector, %cl
jnl next_head
incb %cl
jmp after_next
next_head:
movb $0x01, %cl
cmpb max_head, %dh
jnl next_cylinder
incb %dh
jmp after_next
next_cylinder:
movb $0x00, %dh
incb %ch
after_next:
addw $SECTOR_SIZE, %bx
jnc read_sectors
after_load:
movw $0x0003, %ax
int $0x10
mov $0x0e.%ah #after loading kernel at es:bx display a flag character
mov $'O',%al
int $0x10
mov $0x9000,%bx #allocate stack to the kernel
mov %bx,%ss
mov $0xfffe,%sp
ljmp 0x01000 #long jump to the kernel location
error:
mov $0x0e.%ah
mov $'E',%al
int $0x10
forever:
# Loop forever
hlt
jmp forever
Bootloader code using at & t assembly syntax
-
- Posts: 8
- Joined: Sat Apr 10, 2010 1:59 am
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Bootloader code using at & t assembly syntax
The problem with your code is that you forgot
Code: Select all
tags
Also, this is AT&T syntax - how are you assembling/linking it and how did you put it on your bootable medium of choice? The defaults don't work.
-
- Posts: 8
- Joined: Sat Apr 10, 2010 1:59 am
Re: Bootloader code using at & t assembly syntax
Hello,
Thanks for your reply.I am using GNU assembler for compiling this code and I am writing bootloader and kernel code to an image file and then executing this image file using QEMU.could you plz tell where to put tags in the code.I have found these projects on the web site of princeton university and i am completing these projects for learning purpose.
Thanks,
Thanks for your reply.I am using GNU assembler for compiling this code and I am writing bootloader and kernel code to an image file and then executing this image file using QEMU.could you plz tell where to put tags in the code.I have found these projects on the web site of princeton university and i am completing these projects for learning purpose.
Thanks,
Re: Bootloader code using at & t assembly syntax
He was refering to the habit to enclose posted snippets of code with appropriate tags, so it looks...
...because otherwise any indentation gets lost, and proportional fonts can do "funny" things to source, too.
See also: BBCode on Wikipedia.
Code: Select all
// ...like this...
int main( void )
{
return 0;
}
See also: BBCode on Wikipedia.
Every good solution is obvious once you've found it.