Message-ID: <3128@utah-cs.UUCP>
Date: Fri, 30-Nov-84 19:40:35 EST
Article-I.D.: utah-cs.3128
Posted: Fri Nov 30 19:40:35 1984
Date-Received: Sun, 2-Dec-84 06:05:59 EST
Organization: Univ of Utah CS Dept
Lines: 82
Xref: sdcsvax net.micro.6809:37 net.micro.cbm:928
[Let's give the line-eater terminal indeigestion!]
Here is my entry to the roman numeral contest (for the 6809, 48 bytes total):
*******************************************************************************
VALTBL FCB 100,'C+$80
FCB 90,'X+$80,'C+$80
FCB 50,'L+$80
FCB 40,'X+$80,'L+$80
FCB 10,'X+$80
FCB 9,'I+$80,'X+$80
FCB 5,'V+$80
FCB 4,'I+$80,'V+$80
FCB 1,'I+$80
* The first byte after this table must have the MSB 0. In this case my
* first instruction of the routine satisfies this. If you don't like
* this type of trick, or want to put the code first, you'll have to add a
* zero byte.
* Enter with byte to be output as roman numerals in B register. Destroys
* A, B, X, Y, and CCR
ROMAN LEAX value) then after the characters are printed the same compare is
performed again
T (total clock cycles) = 15 + 24*M + 9*C + (22+p)*P
I have also coded a 6502 version of the same algorithm (which I will provide on
request), which is 60 bytes long, primarily due to the availability of only one
accumulator, and the need for a four instruction sequence to transfer the X
register to the Y register (PHA, TXA, TAY, PLA). If I remember correctly, the
65C02 has a TXY instruction which would save 6 bytes.
If anyone can provide a routine shorter than 48 bytes (code and data) for any
processor, I would very much like to see it.
--
---------------------------------------------------------------------------
Reality (for those who can't face computers): Eric L. Smith
UUCP/UseNet: ...decvax!utah-cs!e-smith ARPA: e-smith@utah-20
U.S.Snail: 230 S. 500 W. Suite 133, Salt Lake City, UT, 84101
AT&T and suchlike: (801) 581-8100 (work), (801) 582-3371 (home)
---------------------------------------------------------------------------
The opinions expressed herein do not necessarily represent those of the
University of Utah, my friends, enemies, computer, or even me. I make no
warranty, express or implied, as to the accuracy of this information of its
fitness for any particular purpose. I assume no liability for any damages,
actual or alleged, directly or indirectly resulting from the use of or
inability to use this information. So there!