Adding upstream version 4.00~pre61+dfsg.
[syslinux-debian/hramrach.git] / core / writedec.inc
blobbfac0997fef2fd848402bbf580e371b6e2704852
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 ;; writedec.inc
16 ;; Write decimal numbers to the console
19                 section .text16
21 ; writedec[bwl]: Write an unsigned decimal number in (AL, AX, EAX)
22 ;                to the console
24 writedecb:
25                 pushad
26                 movzx eax,al
27                 jmp short writedec_common
28 writedecw:
29                 pushad
30                 movzx eax,ax
31                 jmp short writedec_common
32 writedecl:
33                 pushad
34 writedec_common:
35                 pushfd
36                 mov ebx,10              ; Conversion base
37                 xor cx,cx               ; Number of digits
39 .cloop:
40                 div ebx
41                 inc cx
42                 push dx
43                 and eax,eax
44                 jnz .cloop
46 .dloop:
47                 pop ax
48                 add al,'0'
49                 call writechr
50                 loop .dloop
52                 popfd
53                 popad
54                 ret
56 writechr:
57                 ret