view lib/alib/bin_rom.a @ 2772:0a3f4d8ea6d5

Found ENDC in wrong location in dwread.asm and dwwrite.asm. Corrected. Moved the native 6309 code in dwread.asm and dwwrite.asm into the H6309 labeled area and changed IFEQ H6309 to IFNE H6309. Also moved the 57600bps 6809 code to the default location. This change had been done in the old dwread.asm and dwwrite.asm files to make it easier to follow. Though these two files were overwritten from the HDBDOS project dwread.asm and dwwrite.asm files. So this conversion needed to be done again so it made the source easier to follow.
author drencor-xeen
date Wed, 23 Jan 2013 12:36:55 -0600
parents 7d70b7e1cb21
children aaba193af04f
line wrap: on
line source

***************************************

* Subroutine to convert binary number to roman numerals

* OTHER MODULES NEEDED: none

* ENTRY: D=number to convert
*        X=start of buffer (20 bytes)


* EXIT:  all registers preserved

* Note: the buffer should be set to 20 bytes. This permits the
* longest possible number to be converted without a buffer overflow.
* This routine trunates any numbers >8191 to ensure that no number
* is longer than 19 characters (plus null terminator).
* The number 7888 converts to a 19 character string. To permit larger
* number conversions one could delete the anda #%00011111 statement. 

* This routine has been converted from the BASIC09 sample in
* the Basic09 Reference Manual (Microware) page a-3.

 nam Binary to Roman numberal conversion
 ttl Assembler Library Module


 psect BINROM,0,0,0,0,0


BIN_ROM:
 pshs d,x,y,u
 
 leau nums,pcr number conversion table
 clr ,-s  counter on stack
 lda 1,s restore value
 anda #%00011111 ensure no value>8191 permitted

roman1
 cmpd ,u 
 blo roman2
 leay chars,pcr
 bsr addchar
 subd ,u
 bra roman1

roman2
 pshs d
 ldd ,u
 subd 2,u
 cmpd ,s
 puls d
 bhi roman3

 leay subs,pcr
 bsr addchar
 leay chars,pcr
 bsr addchar
 subd ,u
 addd 2,u

roman3
 leau 4,u  next pair of values
 pshs d
 inc 2,s counter
 lda 2,s
 cmpa #7 done?
 puls d
 bne roman1  no, do more

 puls a
 clr ,x null terminator

 puls d,x,y,u,pc

addchar
 pshs d
 lda 4,s  get loop count
 lda a,y  get char
 sta ,x+
 puls d,pc

nums fdb 1000,100
     fdb 500,100
     fdb 100,10
     fdb 50,10
     fdb 10,1
     fdb 5,1
     fdb 1,0

chars fcc /MDCLXVI/
subs  fcc /CCXXII/

 endsect