Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.cbm » roman numeral challenge
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
roman numeral challenge [message #80436] Mon, 03 June 2013 23:33
e-smith is currently offline  e-smith
Messages: 10
Registered: May 2013
Karma: 0
Junior Member
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!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: F-15 Strike Eagle!
Next Topic: Re: How good is speech synth. on C64?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Sep 22 12:36:48 EDT 2024

Total time taken to generate the page: 0.01262 seconds