X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fboot%2Fboot2.s;h=f27d940cb0f35ab631a162b0bd82a8a079acd168;hb=6b3e7a8a2f729acac518abc4b2546a528de362a6;hp=86ee611d309a754d3b773eb05e1f68e0d79b68c4;hpb=e552b31989dbb36f780428332be1b4958d26a37b;p=bootcensus diff --git a/src/boot/boot2.s b/src/boot/boot2.s index 86ee611..f27d940 100644 --- a/src/boot/boot2.s +++ b/src/boot/boot2.s @@ -1,13 +1,31 @@ +# pcboot - bootable PC demo/game kernel +# Copyright (C) 2018 John Tsiombikas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + # this is the second-stage boot loader .code16 .section .boot2,"a" - .extern print_num .extern ser_putchar mov $0x13, %ax int $0x10 + movb $10, %al + call ser_putchar + # copy palette mov $logo_pal, %si xor %cl, %cl @@ -16,8 +34,8 @@ mov $0x3c8, %dx movb %cl, %al outb %al, %dx - #DBG - call print_num + #### DBG + call ser_print_num mov $58, %al call ser_putchar mov $32, %al @@ -30,8 +48,8 @@ inc %si shr $2, %al outb %al, %dx - #DBG - call print_num + #### DBG + call ser_print_num mov $32, %al call ser_putchar xor %eax, %eax @@ -41,8 +59,8 @@ inc %si shr $2, %al outb %al, %dx - #DBG - call print_num + #### DBG + call ser_print_num mov $32, %al call ser_putchar xor %eax, %eax @@ -52,12 +70,10 @@ inc %si shr $2, %al outb %al, %dx - #DBG - call print_num + #### DBG + call ser_print_num mov $32, %al call ser_putchar - mov $13, %al - call ser_putchar mov $10, %al call ser_putchar xor %eax, %eax @@ -79,6 +95,46 @@ cli hlt + # expects string pointer in ds:si +ser_print_str: + pusha + +0: mov (%si), %al + cmp $0, %al + jz .Lend + call ser_putchar + inc %si + jmp 0b + +.Lend: popa + ret + + + # expects number in eax +ser_print_num: + # save registers + pusha + + movw $numbuf + 16, %si + movb $0, (%si) + mov $10, %ebx +.Lconvloop: + xor %edx, %edx + div %ebx + add $48, %dl + dec %si + mov %dl, (%si) + cmp $0, %eax + jnz .Lconvloop + + call ser_print_str + + # restore regs + popa + ret + +numbuf: .space 16 + logo_pal: .incbin "logo.pal"