hdt: 0.5.2-pre3 release
[hdt-cyring.git] / core / writehex.inc
blobe2bf86b48ca4dad02fba1e887991e254ea578baf
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
4 ;;
5 ;;   This program is free software; you can redistribute it and/or modify
6 ;;   it under the terms of the GNU General Public License as published by
7 ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;;   Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;;   (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
14 ;; writehex.inc
16 ;; Write hexadecimal numbers to the console
20 ; writehex[248]: Write a hex number in (AL, AX, EAX) to the console
22 writehex2:
23                 pushfd
24                 pushad
25                 rol eax,24
26                 mov cx,2
27                 jmp short writehex_common
28 writehex4:
29                 pushfd
30                 pushad
31                 rol eax,16
32                 mov cx,4
33                 jmp short writehex_common
34 writehex8:
35                 pushfd
36                 pushad
37                 mov cx,8
38 writehex_common:
39 .loop:          rol eax,4
40                 push eax
41                 and al,0Fh
42                 cmp al,10
43                 jae .high
44 .low:           add al,'0'
45                 jmp short .ischar
46 .high:          add al,'A'-10
47 .ischar:        call writechr
48                 pop eax
49                 loop .loop
50                 popad
51                 popfd
52                 ret