X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=misc%2Ftest_vm%2Fsrc%2Fgeekos%2Futil.asm;fp=misc%2Ftest_vm%2Fsrc%2Fgeekos%2Futil.asm;h=dd07dfd0b5f9827bc8614c19a2669e42a2b88c44;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/misc/test_vm/src/geekos/util.asm b/misc/test_vm/src/geekos/util.asm new file mode 100644 index 0000000..dd07dfd --- /dev/null +++ b/misc/test_vm/src/geekos/util.asm @@ -0,0 +1,53 @@ +; This code is adapted from Kernel Toolkit 0.2 +; and Linux version 2.2.x, so the following copyrights apply: + +; Copyright (C) 1991, 1992 Linus Torvalds +; modified by Drew Eckhardt +; modified by Bruce Evans (bde) +; adapted for Kernel Toolkit by Luigi Sgro + +%ifndef UTIL_ASM +%define UTIL_ASM +%include "defs.asm" +%include "symbol.asm" + +[BITS 16] + +; The following were copied from ktk-0.2 bootsect.asm, and were presumably +; from the Linux bootsect code. I changed them a little so they +; don't clobber the caller's registers. + +EXPORT PrintHex + +[SECTION .text] +; Print the word contained in the dx register to the screen. +align 8 +PrintHex: + pusha + mov cx, 4 ; 4 hex digits +.PrintDigit: + rol dx, 4 ; rotate so that lowest 4 bits are used + mov ax, 0E0Fh ; ah = request, al = mask for nybble + and al, dl + add al, 90h ; convert al to ascii hex (four instructions) + daa ; I've spent 1 hour to understand how it works.. + adc al, 40h + daa + int 10h + loop .PrintDigit + popa + ret + +; Print a newline. +align 8 +PrintNL: ; print CR and NL + push ax + mov ax, 0E0Dh ; CR + int 10h + mov al, 0Ah ; LF + int 10h + pop ax + ret + + +%endif