bootloader

Why isn't my root directory being loaded? (FAT12)

折月煮酒 提交于 2019-11-26 19:10:07
I am writing a stage 1 bootloader in assembly with which I am attempting to load the FAT12 filesystem into memory so that I can load my stage 2 bootloader. I have managed to load the FATs into memory, however I am struggling to load the root directory into memory. I am currently using this for reference and have produced the following: .load_root: ;es is 0x7c0 xor dx, dx ; blank dx for division mov si, fat_loaded ; inform user that FAT is loaded call print mov al, [FATcount] ; calculate how many sectors into the disk must be loaded mul word [SectorsPerFAT] add al, [ReservedSectors] div byte

int 13h 42h doesn't load anything in Bochs

空扰寡人 提交于 2019-11-26 16:57:31
问题 I changed my bootloader from CHS to LBA, so I replaced int 13h 02h with int 13h 42h . It works correctly in QEMU, however, I have troubles running it with Bochs and my laptop. I wrote bootloader to USB flash drive with dd if=main.bin of=/dev/sdb bs=512 . Laptop loads Intel UNDI and gives me the following error: No bootable device - insert boot disk and press any key . So I tried to debug it with Bochs and noticed that Bochs recognizes this binary file as bootable. However, nothing had been

How to load second stage boot loader from first stage?

瘦欲@ 提交于 2019-11-26 16:36:55
问题 I have written simple first stage bootloader which displays "Hello world" using interrupt to bios. Now as a next obvious step to write a second stage, but where code for that should exist and how to load it from first stage ? Here is a program for first stage [BITS 16] ;Tells the assembler that its a 16 bit code [ORG 0x7C00] ;Origin, tell the assembler that where the code will ;be in memory after it is been loaded MOV SI, HelloString ;Store string pointer to SI CALL PrintString ;Call print

Second stage of bootloader prints garbage using Int 0x10/ah=0x0e

时光毁灭记忆、已成空白 提交于 2019-11-26 14:49:14
问题 I am trying to learn assembly and to write a bootloader. The following code loads the contents of a floppy drive to memory and jumps to it (starts loading at address 0x1000). This code is supposed to print "X" on the screen, but for some reason it prints a space. Can somebody please tell me what is wrong? [bits 16] jmp reset reset: ;Resets floppy drive xor ax,ax ;0 = Reset floppy disk mov dl,0 ;Drive 0 is floppy int 0x13 jc reset ;If carry flag was set, try again mov ax,0x1000 ;When we read

BIOS int 10h printing garbage on QEMU

风格不统一 提交于 2019-11-26 14:47:27
问题 I have a problem while writing an x86 real mode assembly program that runs as a bootloader in QEMU . I'm trying to print text through BIOS interrupt 0x10. My code is: print: pusha .loop: mov AL, [SI] cmp AL, 0 je .end call printChar inc SI jmp .loop .end: popa ret printChar: pusha mov AH, 0x0E mov BH, 0 mov BL, 0x0F int 0x10 popa ret I'm using [ORG 0x7c00] as an origin point. I tested the printChar label and calling it with some letter in AL and it works fine. When I try to load a memory

Enable the boot loader to load the second sector of a USB

巧了我就是萌 提交于 2019-11-26 14:34:36
问题 I am learning the assembly language. I wrote a simple bootloader. After testing it out, it didn't work. Here is my code: [bits 16] [org 0x7c00] jmp start data: wolf_wel_msg db 'Welcome to Bootloader!!!',0x0D,0x0A,0 wolf_kernel_load db 'Loading kernel....',0x0D,0x0A,0 wolf_error_msg db 'Kernel.bin not found!',0x0D,0x0A,0 wolf_error_msg1 db 'Press any key to restart..',0 start: mov si, wolf_wel_msg call wolf_print mov si, wolf_kernel_load call wolf_print pushf stc mov ah,00 mov dl,00 int 13h

Legacy BIOS bootloader to bootstrap real-mode code in second stage

醉酒当歌 提交于 2019-11-26 12:46:52
问题 I am working on writing my own operating system. So far, my code exceeds 512 bytes, which is too large to fit in a simple boot sector. I understand that I now have to write a bootloader that reads arbitrary code that may or may not be greater than a single 512-byte sector. The bootloader would need to: Function as a boot record with disk signature 0xaa55. Read a second stage (the test code) start from LBA 1 (LBA 0 is boot sector) of arbitrary length starting at memory address 0x7E00. Transfer

Near call/jump tables don't always work in a bootloader

◇◆丶佛笑我妖孽 提交于 2019-11-26 11:19:20
问题 General Problem I\'ve been developing a simple bootloader and have stumbled on a problem on some environments where instructions like these don\'t work: mov si, call_tbl ; SI=Call table pointer call [call_tbl] ; Call print_char using near indirect absolute call ; via memory operand call [ds:call_tbl] ; Call print_char using near indirect absolute call ; via memory operand w/segment override call near [si] ; Call print_char using near indirect absolute call ; via register Each one of these

Custom bootloader booted via USB drive produces incorrect output on some computers

六月ゝ 毕业季﹏ 提交于 2019-11-26 10:56:59
I am fairly new to assembly, but I'm trying to dive into the world of low level computing. I'm trying to learn how to write assembly code that would run as bootloader code; so independent of any other OS like Linux or Windows. After reading this page and a few other lists of x86 instruction sets, I came up with some assembly code that is supposed to print 10 A's on the screen and then 1 B. BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded

Unexpected output when printing directly to text video memory

北慕城南 提交于 2019-11-26 10:00:22
问题 I am developing a kernel in C and created something to print on screen on video memory. I expected that the first byte in video memory would be the character to print and the second byte tells the color. But my program has something different but it works!! It is very unexpected and unusual. My kernel code - #define VIDEO_MEM 0xb8000 void write_string( int colour, const unsigned char *string ); void main() { unsigned char *vid = (unsigned char*) VIDEO_MEM; int i=0; for (i = 0; i < 2000; i++)