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