TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: ALL
from: BARRY BLOCK
date: 1997-06-27 19:59:00
subject: spell number in english

Recently in the Pascal_Lessons echo (I lurk there), a prog(s) by Mike 
opeland
was reposted. It took an inputted number and displayed it in english.
I wrote and posted a 4DOS version in the 4dos echo.
Trying to do an assembly version is causing me problems :-)
What form should I put the number in? bcd? packed? I have never done this.
I never have worked with a number between 1 and 1 billion in assembly.
Anyone want to post their version?
Here is the algorithm I put together from the TP7 version, with some 
additions.
-------------
program outline - input a number and spell it to standard output in english.
check commandline for integer between 1 and 1 billion
  no? wrong data? then ask for data
  no input? wrong input? then quit
  store number in some form. bcd? unpacked? ---this was real easy in 4dos :-)
show crlf
{ let i=input number to spell }
j=i div 1,000,000       i=i mod 1,000,000
if j > 0  ( n=j ^ call huns ^ show 'million, ' )
j=I div 1000            i=i mod 1000
if j > 0  ( n=j ^ call huns ^ show 'thousand, ' ^ if column > 68 crlf )
                                                {start newline if necessary}
n=i               call huns
show crlf
quit
-------------
Proc huns:
p=n div 100             n=n mod 100
if p > 0  show C_ones[p]' hundred '
p=n div 10              n=n mod 10
if p > 1 show C_tens[p]' '
if p = 1 show show C_teen[n]' '
if p 1 and n > 0 show C_ones[n]' '
return
-------------
Proc show:
pick out correct word in array and send it to standard output
return
-------------
arrays
C_ones db one, two, ..., nine
C_teen db ten, eleven, ..., nineteen
C_tens db twenty, thirty, ..., ninety
--------------
---------------
* Origin: EBO-BBS A'dam +31-20-6002828 (2:280/901.42)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.