6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 8:48 am

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed Aug 13, 2014 7:37 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
BigDumbDinosaur wrote:
Looks as though you got a good view of the Lights. At least you didn't break a leg! :lol:

Yes, mission accomplished on both counts!


Top
 Profile  
Reply with quote  
 Post subject: Re: Byte splitting
PostPosted: Tue Aug 26, 2014 8:06 am 
Offline
User avatar

Joined: Tue Aug 14, 2012 12:47 pm
Posts: 18
Location: Austria - Vienna
barrym95838 wrote:
[..]
BTW, here's how Woz did it, 38 years ago, before the 6502 even had an ROR instruction: (Look ma! No CLC!)
Code:
;-------------------------------------------------------------------------
;  Subroutine to print a byte in A in hex form (destructive)
;-------------------------------------------------------------------------

PRBYTE          PHA                     Save A for LSD
                LSR
                LSR
                LSR                     MSD to LSD position
                LSR
                JSR     PRHEX           Output hex digit
                PLA                     Restore A

; Fall through to print hex routine

;-------------------------------------------------------------------------
;  Subroutine to print a hexadecimal digit
;-------------------------------------------------------------------------

PRHEX           AND     #%0000.1111     Mask LSD for hex print
                ORA     #"0"            Add "0"
                CMP     #"9"+1          Is it a decimal digit?
                BCC     ECHO            Yes! output it
                ADC     #6              Add offset for letter A-F

[..]


Even though the Acorn implementation uses ADC it doesn't need CLC, too. And, they have the same cycle count.
Just for completeness: if register X is free for use one can take TAX, TXA instead of PHA, PLA saving 3 cycles. Yes I know, not really fewer operations, but anyway, fewer cycles ... :wink:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: