/src/nbl/include/io16.inc
https://code.google.com/p/nepheliad-os/ · Pascal · 103 lines · 99 code · 4 blank · 0 comment · 2 complexity · 31df2a65fdfda8ad4a168415f5d68064 MD5 · raw file
- ;=============================================================================;
- ; NEPHELIAD BOOT LOADER ;
- ;=============================================================================;
- ; File: include/io16.inc ;
- ; Created: 10/19/2011 ;
- ; Updated: 10/19/2011 ;
- ; Author(s): ;
- ; * Sean M. Kell <sean.michael.kell@gmail.com> ;
- ;-----------------------------------------------------------------------------;
- ; Provides functions for input / output in 16-bit real mode. ;
- ;-----------------------------------------------------------------------------;
- ; Change Log: ;
- ; Version 0.01: ;
- ; * 10/19/2011 - Initial creation. ;
- ; - Includes functions for writing a string, or character to the screen ;
- ; using BIOS interrupt 0x10, function 0x0E. ;
- ;-----------------------------------------------------------------------------;
- ; Copyright (c) 2011 Sean M. Kell ;
- ; ;
- ; All rights reserved. ;
- ;=============================================================================;
- CR equ 0x0D
- LF equ 0x0A
- ;=============================================================================;
- ; writechr() ;
- ;-----------------------------------------------------------------------------;
- ; al - the character to write ;
- ;-----------------------------------------------------------------------------;
- ; Writes a character to the screen. ;
- ;-----------------------------------------------------------------------------;
- writechr:
- pushfd
- pushad
- xor bx, bx
- mov ah, 0x0E
- int 0x10
- popad
- popfd
- ret
- writenl:
- pushfd
- pushad
- mov al, CR
- call writechr
- mov al, LF
- call writechr
- popad
- popfd
- ret
-
- ;=============================================================================;
- ; writestr() ;
- ;-----------------------------------------------------------------------------;
- ; si - points to the string to be written ;
- ;-----------------------------------------------------------------------------;
- ; Writes a string to the screen. ;
- ;=============================================================================;
- writestr:
- pushfd
- pushad
- .loop: lodsb
- cmp al, 0
- je .done
- call writechr
- jmp .loop
- .done: popad
- popfd
- ret
-
- writehex2:
- pushfd
- pushad
- rol eax, 24
- mov cx, 2
- jmp short writehex_common
- writehex4:
- pushfd
- pushad
- rol eax, 16
- mov cx, 4
- jmp short writehex_common
- writehex8:
- pushfd
- pushad
- mov cx, 8
- writehex_common:
- .loop: rol eax, 4
- push eax
- and al, 0x0F
- cmp al, 10
- jae .high
- .low: add al, '0'
- jmp short .ischar
- .high: add al, 'A'-10
- .ischar:
- call writechr
- pop eax
- loop .loop
- popad
- popfd
- ret