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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Sergey Meerovich
06/10/09 03:53
Read: 232 times


 
#165967 - conver ASCII to bin and viceversa and interface
Responding to: Richard Erlacher's previous message
I enter a part of code that translate ASCII to binary :

I must use 8251 because it build in in my kit:
I have now problem that HyperTerminal can"t run when I run my compiler kit
and so I can't see the result,
about speed I send data in 4800 baudrate so it's not so fast
ASC2BIN: ;Convert from ASCII to Binary
MOV A,R2 ;Inputs: R2,R3
LCALL BIN ;Output: A
SWAP A ;R2 - M.S.D R3 - L.S.D
MOV R2,A
MOV A,R3
LCALL BIN
ADD A,R2
RET
;
BIN: CLR C
SUBB A,#3AH
JNC BIN2
ADD A,#0AH
RET
BIN2: ADD A,#3
RET

BIN2ASC:
MOV R4,A ;Convert from Binary to ASCII
SWAP A ;Input: A
LCALL ASC ;Outputs: R2,R3
MOV R2,A ;R2 - M.S.D R3 - L.S.D
MOV A,R4
LCALL ASC
MOV R3,A
RET
;
ASC: ANL A,#0FH
CLR C
SUBB A,#0AH
JNC ASC2
ADD A,#3AH
RET
ASC2: ADD A,#41H
RET

List of 12 messages in thread
TopicAuthorDate
transmit/recieve character by using 8051 and USART      Sergey Meerovich      06/09/09 15:27      
   Be sure your 8251 is fast enough      Richard Erlacher      06/09/09 18:42      
      conver ASCII to bin and viceversa and interface      Sergey Meerovich      06/10/09 03:53      
         translate ASCII to binary ? [edited]      Andy Neil      06/10/09 04:38      
            65 base 10 = 41 base 16      Per Westermark      06/10/09 04:43      
               Corrected!      Andy Neil      06/10/09 05:55      
         binary to hex      Per Westermark      06/10/09 04:40      
            Text representation of numbers      Andy Neil      06/10/09 05:48      
               connection with HyperLink      Sergey Meerovich      06/15/09 09:02      
                  unplug and plug      Erik Malund      06/15/09 09:05      
   Question about Polling method for send recieve data      Sergey Meerovich      06/16/09 01:02      
      yes, and no      Erik Malund      06/16/09 08:31      

Back to Subject List