Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/20/07 15:51
Read: times


 
#144829 - I didn't really want to use 805x instructions
Responding to: ???'s previous message
Some sort of low-level pseudo-code would have been a better vehicle, I think, but what I was getting at is the basic concept. It's really very much a "computed go-to" though the computation is done entirely within the table-lookup.

Back in the days of microprocessors, I used a 65C02 to do this in terminals and link encryptors. From there, I loaded an index (probably X) with the port content and used a JMP @TABLE,X which is somewhat more convenient than using the accumulator, since you could then pass a parameter, if necessary, in A without disturbing anything. Since the only thing unique to each vector in the table was the offset, and since that was the product of the state input, it really wouldn't matter.

Producing an actual working example would require more effort than I'm willing to put into this discussison. After all, taking ASCII characters in a video terminal environment as an example, it would require construction of the 256-byte table, each word of which would then have to contain an address specific to the character used as the offset, namely [A], into it. I don't believe I have the old 6502 code I used back in the '80's any longer, though that would probably work. Using that example would, however, require detailed explanation of what each non-displayed character meant and how it was processed.

Consider, though, that each table entry corresponding to a displayable character would point to a single routine, the result of which would be to write [A] to the display memory, which would then be transferred, in hardware, through a character generator, to the pixel-wise display logic. Characters that required other specific action, e.g, control-S or control-Q, would require their own unique processing code. Further, the table would probably be pretty large, as there were, in my 6502 terminal case, IIRC, several layers of the dispatch table, as various processing contexts demanded. The input, after all, came from a keyboard encoder.

The basic concept, however, remains very simple, in that it loads an offset into an index, then jumps via a table indexed by the 7-bit left-justified (LSB=0) input byte. It's difficult to imagine anything simpler. Each subsequent routine must end in an absolute jump to the primary dispatch loop, hence the process results in no net stack usage. There's many a slip 'twixt cup and lip, though, in that it's quite conceivable that the routines to which the table dispatches control could, indeed use some stack. However, since the table is, in each case, one page (256 bytes) in size, direction to another page, as required by context, is easily handled by modifying the upper byte of the pointer to the table base.

The tables can become large and manifold, but the underlying concept is very simple. The code is very simple, too. The table(s) must be constructed in the coding process, and those can become large, but the code itself is straightforward and fast, and, of course, easy to debug.

RE


List of 62 messages in thread
TopicAuthorDate
weekend survey            01/01/70 00:00      
   1. programming through the whole night            01/01/70 00:00      
   two things at once            01/01/70 00:00      
      not entirely correct            01/01/70 00:00      
   I'm afraid, but...            01/01/70 00:00      
      stealing codes?            01/01/70 00:00      
         A lesson learned by many            01/01/70 00:00      
         They are way faster...            01/01/70 00:00      
            sounds like a bitter experience            01/01/70 00:00      
   3)Math            01/01/70 00:00      
      0) Math            01/01/70 00:00      
   I have to agree with Erik            01/01/70 00:00      
   For hardware design(VHDL)            01/01/70 00:00      
      then, throw out the crap            01/01/70 00:00      
   Math, experience, tools and code libraries            01/01/70 00:00      
   Why?            01/01/70 00:00      
      tradeoffs            01/01/70 00:00      
         Well said, but not what I asked            01/01/70 00:00      
            different question            01/01/70 00:00      
               technique v tool            01/01/70 00:00      
      two reasons            01/01/70 00:00      
         valuation            01/01/70 00:00      
            that's a given, but            01/01/70 00:00      
            Lookup tables are good for lots of stuff            01/01/70 00:00      
   Good topic!            01/01/70 00:00      
      common tool, but            01/01/70 00:00      
         Function Pointers on the 8051            01/01/70 00:00      
            table-driven whatever and function pointers            01/01/70 00:00      
               reduce a task to its basic elements            01/01/70 00:00      
                  Good idea, bad example            01/01/70 00:00      
                     I didn't really want to use 805x instructions            01/01/70 00:00      
                        I can\'t find my old, (t)rusty 65C02 cheatsheet...            01/01/70 00:00      
                           Only the Rockwell version had it            01/01/70 00:00      
                              Oh, mea culpa...            01/01/70 00:00      
                        A very simple example would be helpful            01/01/70 00:00      
                           let\\\'s start at your end            01/01/70 00:00      
                              Here's what's confusing            01/01/70 00:00      
                                 FAQ?            01/01/70 00:00      
                                 Yes, you're quite right ... ... Mea culpa            01/01/70 00:00      
                  inconsistent instruction set            01/01/70 00:00      
                     I ask you, seriously, to inform us            01/01/70 00:00      
                        a few things            01/01/70 00:00      
                           so much \'fun\' with ajmp            01/01/70 00:00      
                              I give up            01/01/70 00:00      
                                 the answer            01/01/70 00:00      
                           My intuition            01/01/70 00:00      
                              mhm            01/01/70 00:00      
      to russ            01/01/70 00:00      
         to erik            01/01/70 00:00      
            to Russ            01/01/70 00:00      
               to Erik            01/01/70 00:00      
               To Erik            01/01/70 00:00      
                  WOW, a companion CD            01/01/70 00:00      
   the bad ideas            01/01/70 00:00      
      Anachronism?            01/01/70 00:00      
         he's certainly not a HW guy...            01/01/70 00:00      
      Hardware protection slated            01/01/70 00:00      
         this is an academic view...            01/01/70 00:00      
            Proving correctness            01/01/70 00:00      
   Why state machine / lookup tables?            01/01/70 00:00      
      Not to disagree ... but ...            01/01/70 00:00      
         A good reference            01/01/70 00:00      

Back to Subject List