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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/17/07 14:45
Modified:
  05/17/07 14:46

Read: times


 
#139439 - ReceiveString, rev. 3
Responding to: ???'s previous message
I must have too much time on my hands. I rearranged this thing yet again to remove a nasty, unstructured jump. That made it bigger by about eight bytes. I can't decide if it's better now, or worse, or just different. I guess it depends on how important those eight bytes are.

-- Russ
ReceiveString:
	mov	r0,#RxBuffer        	; Initialize receiver pointer

GetNextChar:				; Come here to get each new character
	call	RxChar			; Go get a character
	jb      acc.7,GetNextChar	; It's unprintable (>= 80h) - ignore it

	cjne    a,#20h,$+3		; Is it a control character (<20h)?
	jc      ControlChars		;  Yes - process separately
	cjne    r0,#BUFFER_END,SaveChar	;  No - go store if no overflow

	mov     a,#BEEP_CHR		; Buffer overflow if we get here
	call	TxChar			; Make the terminal beep
	sjmp	GetNextChar		; Go get next character

SaveChar:				; Printable character if we get here
	mov     @r0,a			; Put character in buffer	
	inc     r0			; Advance buffer pointer
	call	TxChar			; Echo character to terminal
	sjmp	GetNextChar		; Go get next character

ControlChars:				; Control character if we get here
	cjne    a,#BS_CHR,NotBackSpace	; Not backspace - press on
	cjne    r0,#RxBuffer,EatChar	; Is backspace - go eat if no underflow 
	
	mov     a,#BEEP_CHR		; Buffer underflow if we get here
	call	TxChar			; Make the terminal beep
	sjmp	GetNextChar		; Go get next character

EatChar:				; Process backspace here
	mov	a,#BS_CHR		; Send BS-SPACE-BS to terminal to erase
	call	TxChar			;  the most recently typed character
	mov	a,#SPACE_CHR
	call	TxChar
	mov	a,#BS_CHR
	call	TxChar
	dec     r0			; Remove the character from the buffer
	sjmp    GetNextChar		; Go get next character

NotBackSpace:				; Control char, but not backspace
	cjne    a,#CR_CHR,GetNextChar	; If not CR, go get next character

	mov     @r0,#0			; Got CR - terminate the string
	ret				; Done



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