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.


moved host OS interfaces to a separate directory palacios/src/interfaces and palacios...
[palacios.git] / geekos / src / geekos / util.asm
1 ; This code is adapted from Kernel Toolkit 0.2
2 ; and Linux version 2.2.x, so the following copyrights apply:
3
4 ; Copyright (C) 1991, 1992 Linus Torvalds
5 ; modified by Drew Eckhardt
6 ; modified by Bruce Evans (bde)
7 ; adapted for Kernel Toolkit by Luigi Sgro
8
9 %ifndef UTIL_ASM
10 %define UTIL_ASM
11 %include "defs.asm"
12 %include "symbol.asm"
13         
14 [BITS 32]
15         
16 ; The following were copied from ktk-0.2 bootsect.asm, and were presumably
17 ; from the Linux bootsect code.  I changed them a little so they
18 ; don't clobber the caller's registers.
19
20 EXPORT PrintHex
21
22 [SECTION .text]
23 ; Print the word contained in the dx register to the screen.
24 align 8
25 PrintHex:
26         pusha
27         mov   cx, 4             ; 4 hex digits
28 .PrintDigit:
29         rol   dx, 4             ; rotate so that lowest 4 bits are used
30         mov   ax, 0E0Fh         ; ah = request, al = mask for nybble
31         and   al, dl
32         add   al, 90h           ; convert al to ascii hex (four instructions)
33         daa                     ; I've spent 1 hour to understand how it works..
34         adc   al, 40h
35         daa
36         int   10h
37         loop  .PrintDigit
38         popa
39         ret
40
41 ; Print a newline.
42 align 8
43 PrintNL:                        ; print CR and NL
44         push    ax
45         mov     ax, 0E0Dh       ; CR
46         int     10h
47         mov     al, 0Ah         ; LF
48         int     10h
49         pop     ax
50         ret
51
52 %endif