
   [... UART already initialised...]
ReceiveString:
   mov    r0,#ReceiveBuffer   ;initialize receiver pointer
LoopReceive:
   jnb    ti,$                ;wait until character received
   clr    ti                  
   mov    a,SBUF              ;get the received character
   jb     acc.7,LoopReceive   ;if unprintable (>= 80h), ignore it
   cjne   a,#20h,$+3
   jc     ControlChars        ;if control char (<20h), separate processing
   mov    SBUF,a              ;printable character: echo it
   mov    @r0,a               ;put it into buffer
   inc    r0                  ;bump pointer
   sjmp   LoopReceive         ;and continue receiving
ControlChars:
   cjne   a,#08h,NotBackSpace
   dec    r0                  ;if BackSpace, eat last character from buffer
   cjne   r0,#ReceiveBuffer,LoopReceive  
   inc    r0                  ;if start of buffer, undo the backspace
   sjmp   LoopReceive
NotBackSpace:
   cjne   a,#13h,LoopReceive  ;if not Carriage Return, receive more characters
   [... continue with processing string]
