A86: Re: Displaying numbers


[Prev][Next][Index][Thread]

A86: Re: Displaying numbers




;====================================================================
; DisplayHL:  (idea from SCaBBy/Mardell)    [Assembly Coder's Zenith]
;  Display HL as a 5-digit decimal number with no leading zeros
;  out: AF, HL, BC, DE, OP1 destroyed
;====================================================================
DisplayHL:
 ld c,'0'                 ; save ascii value for zero
 ld de,_OP1+5             ; point to end of the buffer
 xor a                    ; zero terminate string
 ld (de),a                ; set last byte to zero
DisplayHLl:
 call UNPACK_HL           ; next digit
 dec de                   ; next position
 add a,c                  ; convert to ascii
 ld (de),a                ; save digit
 ld a,h                   ; load upper byte
 or l                     ; check with lower byte for zero
 jr nz,DisplayHLl         ; loop
 ex de,hl                 ; point to buffer
 jp _vputs                ; print number and return

;===========================================
; DispAhex         [Assembly Coder's Zenith]
;  prints A in hexadecimal
; in: A = number to display
; modified: AF, B, HL, OP1
;===========================================
DispAhex:
 ld hl,_OP1
 ld (hl),a
 ld b,2
DispAhexl:
 xor a
 rld
 add a,48                  ; '0'
 cp 58                     ; '9' + 1
 jr c,DispAhexs
 add a,7                   ; 'A' - '9'
DispAhexs:
 call _putc
 djnz DispAhexl 
 ret

--
David Phillips <david@acz.org>
http://www.acz.org/

----- Original Message ----- 
From: Sphincter Boy <sphincter@columbus.crosswinds.net>
To: <assembly-86@lists.ticalc.org>
Sent: Friday, January 15, 1999 3:23 PM
Subject: A86: Displaying numbers


>
>This may sound stupid, but how do I display numbers? As a simple
>excercise, I tried to make a counting program. It was to count from 1 to
>100. Instead of numbers, I got characters. It did count, but the output
>was not numbers. I used 'call _putc' to display the output. I don't have
>the original source anymore, as the program has evolved into something
>completly different. Any ideas?
>
>--
>As he atempted to say, "Do you both love pork," In his mangled English,
>it came out, "Do you both have sex with pigs."
>
>
>