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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/13/07 16:11
Read: times


 
#139178 - Shall we continue this???
Responding to: ???'s previous message
It's amazing how hard it is to get a little patch of code like this correct. Now that (we think?) we have identified all the errors in Jan's program, let's see what a robust, well documented, reusable version of the same thing would look like.

Then, once we have a working version, it might be fun to see how small we can make it. That should definitely be a second project, however. As they say, "Make it work, then make it small."

As a starting point, here's a mini spec in the form of a function header for the input routine. What should be added/deleted/changed to make this subroutine really, really good?

-- Russ
;------------------------------------------------------------------------------
;				 ReceiveString
;------------------------------------------------------------------------------
; DESCRIPTION:  This subroutine is called from many places to receive a line of
;               input from a human user via a terminal connected to the onboard
;               UART.  Each line of input starts with the first character
;               entered after this subroutine is called, and ends with a
;               carriage return.
;
;               This subroutine accumulates the data in a buffer called
;               'RxBuffer', which is located in the upper 128 bytes of internal
;               data RAM (accessible only via indirect addressing).  The symbol
;               RX_BUFFER_SIZE gives the size of the buffer, in bytes.  Two
;               more symbols, NO_ERROR and BUFFER_OVERFLOW, define status codes
;               (more on these below).
;
;               On entry, this function does minor internal housekeeping to
;               prepare for a new line of input.  It then receives characters
;               one by one from the user.  It handles each received character
;               as follows:
;
;                 - Backspace (08h): If the buffer is not empty, removes the
;                   newest character from the buffer and echoes the
;                   three-character sequence 08h 20h 08h (backspace space
;                   backspace) to the terminal to erase the most recently typed
;                   character from the user's screen.  If the buffer is empty
;                   when the backspace character is received, echoes a single
;                   07h (beep) to the terminal.
;
;                 - Carriage Return (0Dh): Appends the character to the buffer
;                   to mark the end of the line and returns to the caller with
;                   the accumulator set to NO_ERROR.
;
;                 - Printable characters (20h through 7Eh, inclusive): Appends
;                   the character to the buffer.  If the buffer becomes full as
;                   a result, returns to the caller with the accumulator set to
;                   BUFFER_OVERFLOW.
;
;                 - All other characters: Does nothing.
;
;               As noted above, this function returns when it receives a
;               carriage return, or when the buffer gets full, whichever occurs
;               first.  On exit, all registers are restored to their state at
;               the time of the call except the accumulator, which contains a
;               status code as described above.
;
; REVISIONS:	13 May 07 - RAC - Initial specification
; -----------------------------------------------------------------------------



List of 44 messages in thread
TopicAuthorDate
Weekend Quiz - easy            01/01/70 00:00      
   Dumbbbbbb            01/01/70 00:00      
      I know of 3, and it is \"synthtetic\"...            01/01/70 00:00      
   Hi Jan!            01/01/70 00:00      
      2 out of 3            01/01/70 00:00      
   Comment lies!            01/01/70 00:00      
      that makes 4... embarrassing            01/01/70 00:00      
         #4            01/01/70 00:00      
            N-th            01/01/70 00:00      
               Similar            01/01/70 00:00      
         Thats the one I saw first too !            01/01/70 00:00      
   Another lyin\' comment            01/01/70 00:00      
      Bingo!            01/01/70 00:00      
   seems solved - so now for the equivalent in C?            01/01/70 00:00      
      Oops            01/01/70 00:00      
         Gee ... it was just an 'x' ...            01/01/70 00:00      
            Yup ...            01/01/70 00:00      
            "just" an x ?            01/01/70 00:00      
   writing SBUF without checking?            01/01/70 00:00      
      well...            01/01/70 00:00      
      the REAL mistake is using an HLL rather than ASM            01/01/70 00:00      
         Not so            01/01/70 00:00      
   Shall we continue this???            01/01/70 00:00      
      the spec itself is problematic            01/01/70 00:00      
         How would you fix the spec?            01/01/70 00:00      
            handle DEL (0x7f) and BS?            01/01/70 00:00      
               throwing in something to chew on... :-)            01/01/70 00:00      
               Are DEL and BS equivalent ???            01/01/70 00:00      
                  relax.            01/01/70 00:00      
      ReceiveString, rev.1            01/01/70 00:00      
         ReceiveString, rev. 2            01/01/70 00:00      
            there are many ways...            01/01/70 00:00      
               Comments on comments on ...            01/01/70 00:00      
                  (comments on)^3            01/01/70 00:00      
                  Caller-saves            01/01/70 00:00      
                     Caller-save vs. Callee-save            01/01/70 00:00      
                        Compiler trade-off            01/01/70 00:00      
      ReceiveString, rev. 3            01/01/70 00:00      
   Sunday Challenge (rev 4)            01/01/70 00:00      
      hard to beat...            01/01/70 00:00      
         Just one more byte ...            01/01/70 00:00      
            want to spare bytes?            01/01/70 00:00      
               CALL vs ACALL            01/01/70 00:00      
                  it depends            01/01/70 00:00      

Back to Subject List