From 1135c7065d9c6d600d99b2f28545535b9b1865de Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Sun, 30 Mar 2014 16:45:50 +0000 Subject: [PATCH] --- Makefile | 11 +++++++---- boot.asm | 118 ---------------------------------------------------------------------------------------------------------------------- boot.bin | Bin 512 -> 0 bytes boot_floppy.asm | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ boot_floppy.bin | Bin 0 -> 512 bytes 5 files changed, 125 insertions(+), 122 deletions(-) delete mode 100644 boot.asm delete mode 100644 boot.bin create mode 100644 boot_floppy.asm create mode 100644 boot_floppy.bin diff --git a/Makefile b/Makefile index 8a72960..fa2869c 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ -TARGETS = floppy.img boot.bin +TARGETS = boot_floppy.bin boot_usb.bin -boot.bin: boot.asm - nasm boot.asm -f bin -o boot.bin - dd if=boot.bin of=floppy.img bs=512 count=1 conv=notrunc +boot_floppy.bin: boot_floppy.asm floppy.img + nasm boot_floppy.asm -f bin -o boot_floppy.bin + dd if=boot_floppy.bin of=floppy.img bs=512 count=1 conv=notrunc + +boot_usb.bin: boot_usb.asm + nasm boot_usb.asm -f bin -o boot_usb.bin floppy.img: dd if=/dev/zero of=floppy.img bs=512 count=2880 diff --git a/boot.asm b/boot.asm deleted file mode 100644 index a3b4f86..0000000 --- a/boot.asm +++ /dev/null @@ -1,118 +0,0 @@ -;BLACK 0x0 -;BLUE 0x1 -;GREEN 0x2 -;CYAN 0x3 -;RED 0x4 -;MAGENTA 0x5 -;BROWN 0x6 -;GREY 0x7 -;DARK_GREY 0x8 -;LIGHT_BLUE 0x9 -;LIGHT_GREEN 0xA -;LIGHT_CYAN 0xB -;LIGHT_RED 0xC -;LIGHT_MAGENTA 0xD -;LIGHT_BROWN 0xE -;WHITE 0xF - -[BITS 16] -[org 0x7C00] - -JMP short Start - -str: db 'THE GAME ',0x00 - -clear_screen: - PUSH ax - MOV al, 03h ; Setting the graphical mode 80x25(text) - MOV ah, 00h ; Code of the function of changing video mode - INT 10h ; Call interruption - MOV cl, 0x06 - MOV ah, 0x01 - INT 10h - POP ax - RETN - -print_string: ; Expects null terminated message in si - PUSH ax - for_print_string_0: - MOV al,[si] - OR al,al - JZ end_for_print_string_0 - INC si - CALL print_char - JMP for_print_string_0 - end_for_print_string_0: - POP ax - RETN - -print_sector: - PUSH ebp - MOV ebp, esp - PUSH ax - PUSH bx - PUSH cx - PUSH dx - MOV al, [6 + ebp] ; num - MOV cl, [8 + ebp] ; offset - MOV ah, 2 - XOR ch, ch - XOR dx,dx - INT 0x13 - MOV di, 512 - XOR ah, ah - IMUL di, ax - XOR si, si - for_print_sector_0: - CMP si, di - JZ end_for_print_sector_0 - MOV al,[es:si] - OR al, al - JZ end_print_char_0 - CALL print_char - end_print_char_0: - INC si - JMP for_print_sector_0 - end_for_print_sector_0: - POP dx - POP cx - POP bx - POP ax - MOV esp, ebp - POP ebp - RETN - -print_char: - PUSH ax - PUSH bx - MOV ah,0x0E ; Specifies that we want to write a character to the screen - MOV bl,0x02 ; Specifies output text color. Not required, but useful to know - MOV bh,0x00 ; Page number. Leave this alone. - INT 0x10 ; Signal video interrupt to BIOS - POP bx - POP ax - RETN - -Start: -XOR ax, ax -MOV ds, ax -MOV ax, 0x1000 -MOV es, ax -XOR bx, bx -CALL clear_screen -PUSH 2 ; num -PUSH 2 ; offset -CALL print_sector ; (offset, num) -ADD esp, 4 -for_start_0: - MOV si,str - CALL print_string - ;JMP for_start_0 - JMP $ - - -TIMES 510 - ($ - $$) db 0 -DW 0xAA55 - - - diff --git a/boot.bin b/boot.bin deleted file mode 100644 index 4444e84..0000000 Binary files a/boot.bin and /dev/null differ diff --git a/boot_floppy.asm b/boot_floppy.asm new file mode 100644 index 0000000..a3b4f86 --- /dev/null +++ b/boot_floppy.asm @@ -0,0 +1,118 @@ +;BLACK 0x0 +;BLUE 0x1 +;GREEN 0x2 +;CYAN 0x3 +;RED 0x4 +;MAGENTA 0x5 +;BROWN 0x6 +;GREY 0x7 +;DARK_GREY 0x8 +;LIGHT_BLUE 0x9 +;LIGHT_GREEN 0xA +;LIGHT_CYAN 0xB +;LIGHT_RED 0xC +;LIGHT_MAGENTA 0xD +;LIGHT_BROWN 0xE +;WHITE 0xF + +[BITS 16] +[org 0x7C00] + +JMP short Start + +str: db 'THE GAME ',0x00 + +clear_screen: + PUSH ax + MOV al, 03h ; Setting the graphical mode 80x25(text) + MOV ah, 00h ; Code of the function of changing video mode + INT 10h ; Call interruption + MOV cl, 0x06 + MOV ah, 0x01 + INT 10h + POP ax + RETN + +print_string: ; Expects null terminated message in si + PUSH ax + for_print_string_0: + MOV al,[si] + OR al,al + JZ end_for_print_string_0 + INC si + CALL print_char + JMP for_print_string_0 + end_for_print_string_0: + POP ax + RETN + +print_sector: + PUSH ebp + MOV ebp, esp + PUSH ax + PUSH bx + PUSH cx + PUSH dx + MOV al, [6 + ebp] ; num + MOV cl, [8 + ebp] ; offset + MOV ah, 2 + XOR ch, ch + XOR dx,dx + INT 0x13 + MOV di, 512 + XOR ah, ah + IMUL di, ax + XOR si, si + for_print_sector_0: + CMP si, di + JZ end_for_print_sector_0 + MOV al,[es:si] + OR al, al + JZ end_print_char_0 + CALL print_char + end_print_char_0: + INC si + JMP for_print_sector_0 + end_for_print_sector_0: + POP dx + POP cx + POP bx + POP ax + MOV esp, ebp + POP ebp + RETN + +print_char: + PUSH ax + PUSH bx + MOV ah,0x0E ; Specifies that we want to write a character to the screen + MOV bl,0x02 ; Specifies output text color. Not required, but useful to know + MOV bh,0x00 ; Page number. Leave this alone. + INT 0x10 ; Signal video interrupt to BIOS + POP bx + POP ax + RETN + +Start: +XOR ax, ax +MOV ds, ax +MOV ax, 0x1000 +MOV es, ax +XOR bx, bx +CALL clear_screen +PUSH 2 ; num +PUSH 2 ; offset +CALL print_sector ; (offset, num) +ADD esp, 4 +for_start_0: + MOV si,str + CALL print_string + ;JMP for_start_0 + JMP $ + + +TIMES 510 - ($ - $$) db 0 +DW 0xAA55 + + + diff --git a/boot_floppy.bin b/boot_floppy.bin new file mode 100644 index 0000000..4444e84 Binary files /dev/null and b/boot_floppy.bin differ -- libgit2 0.22.2