You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB
ArmAsm

; See the end of this file for copyright and license terms.
;
; We use a custom ABI because BIOS interrupts use ax for their parameter:
;
; register | usage
; ---------|--------------------
; ax | BIOS parameter
; bx | arg1, return value
; cx | arg2
; dx | arg3
;
; Registers ax-dx are saved by the caller, all others by the callee.
;
; To save space, strings are terminated by setting bit 7 of their last
; character to 1 (because ascii only uses bits 0-6) rather than appending a
; full NUL terminator byte. This technique is stolen from FreeBSD.
;
[bits 16]
[org 0x7c00]
_start:
mov bp, 0x9000
mov sp, bp
mov bx, HELLO
call print
; TODO: switch to protected mode and call kernel here
jmp $
; args:
; - bx: pointer to string
print:
mov ah, 0x0e
_print_loop:
mov al, [bx]
mov cl, al
and al, 0x7f
int 0x10
inc bx
and cl, 0x80
je _print_loop
ret
HELLO: db "hi i'm gay uwu", 0x0d, 0x8a ; '\r', '\n'|0x80
; padding to 512 bytes (-2 for magic)
times 510 - ($-$$) db 0
; mbr magic
dw 0xaa55
; This file is part of GayBSD.
; Copyright (c) 2021 fef <owo@fef.moe>.
;
; GayBSD is nonviolent software: you may only use, redistribute, and/or
; modify it under the terms of the Cooperative Nonviolent Public License
; (CNPL) as found in the LICENSE file in the source code root directory
; or at <https://git.pixie.town/thufie/cnpl-builder>; either version 7
; of the license, or (at your option) any later version.
;
; GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
; permitted by applicable law. See the CNPL for details.