Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / misc / test_vm / src / geekos / util.asm
diff --git a/misc/test_vm/src/geekos/util.asm b/misc/test_vm/src/geekos/util.asm
new file mode 100644 (file)
index 0000000..dd07dfd
--- /dev/null
@@ -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