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

Back to Subject List

Thread Closed: Thread will re-open when original poster replies

???
04/01/08 08:11
Read: times


 
#152816 - Here we go again ... yes but we are helpless ;-)
Responding to: ???'s previous message
Yahya A. Shokr said:
hi.... i miss u all and ur usefull replys..i'm gone do a great project using the AT89c52 and as a part of it i will mack a digital thrmometer LM35>>> any way i need a subrouten by assimble to convert the hex numbers into decimal numbers to display it on a 7-segmant display.... i'll ur replys >>> :) bye


bin to BCD convert: Try this


B  DATA  0F0H
ACC   DATA  0E0H
NAME  BCD

?PR?bin2bcd?BCD      SEGMENT CODE
EXTRN DATA (U_b)
PUBLIC   bin2bcd

   RSEG  ?PR?bin2bcd?BCD
   USING 0

bin2bcd:

   MOV   A,U_b
   JNB   ACC.7,POSITIVE
   
   CLR   C                    ; negative argument 
   CLR   A
   SUBB  A,U_b+3
   MOV   U_b+3,A
   CLR   A
   SUBB  A,U_b+2
   MOV   U_b+2,A
   CLR   A
   SUBB  A,U_b+1
   MOV   U_b+1,A
   CLR   A
   SUBB  A,U_b
   JNZ   ERROR             ; should be ZERO
   
   MOV   R3,#5             ;"Digit" Counter
   MOV   R1,#U_b           ;"Digit" Pointer
   MOV   R2,#5             ;"Nibble" Counter
   MOV   R0,#U_b           ;"Nibble" Pointer


   MOV   U_b+5,#0FH        ; 0x0F as '-' Character 
                           ; (will be converted for 
                           ;  7-seg. LCD)

   MOV   A,U_b+1           ; LSB2 LN -> 0
   MOV   U_b,A
   ANL   U_b,#0FH   

   ANL   A, #0F0H          ; should be ZERO
   JNZ   ERROR

   MOV   A,U_b+3           ; LSB0 LN -> 4
   MOV   U_b+4,A
   ANL   U_b+4,#0FH
   SWAP  A
   MOV   U_b+3,A           ; LSB0 HN -> 3
   ANL   U_b+3,#0FH

   MOV   A,U_b+2           ; LSB1 LN -> 2
   ANL   U_b+2,#0FH
   SWAP  A
   MOV   U_b+1,A           ; LSB1 HN -> 1
   ANL   U_b+1,#0FH

   CLR   A
   SJMP  LOOP_DIV    ; everything is in place now
   
POSITIVE:

   MOV   A,U_b+1
   ANL   A, #0F0H          ; should be ZERO
   JNZ   ERROR

   MOV   A,U_b+3           ; LSB0 LN -> 5
   MOV   U_b+5,A
   ANL   U_b+5,#0FH
   SWAP  A
   MOV   U_b+4,A           ; LSB0 HN -> 4
   ANL   U_b+4,#0FH

   MOV   A,U_b+2           ; LSB1 LN -> 3
   MOV   U_b+3,A
   ANL   U_b+3,#0FH
   SWAP  A
   MOV   U_b+2,A           ; LSB1 HN -> 2
   ANL   U_b+2,#0FH

   ANL   U_b+1,#0FH        ; LSB2 LN -> 1

   MOV   R3,#6             ;"Digit" Counter
   MOV   R1,#U_b           ;"Digit" Pointer
   MOV   R2,#5             ;"Nibble" Counter
   MOV   R0,#U_b+1         ;"Nibble" Pointer

   CLR   A
   SJMP  LOOP_DIV    ; everything is in place now

LOOP_DIGIT:     

   MOV   AR0,AR1
   MOV   AR2,AR3
   CLR   A

LOOP_DIV:
   XCHD  A,@R0
   MOV   B,#10       ; DIVISOR
   DIV   AB
   XCHD  A,@R0
   MOV   A,B
   SWAP  A           ; Remainder in AKKU HIGH NIBBLE
   INC   R0
   DJNZ  R2,LOOP_DIV

   MOV   A,@R1        ; should be ZERO
   JNZ   ERROR
   MOV   @R1,B
   INC   R1
   DJNZ  R3,LOOP_DIGIT

END1:
   RET

ERROR:
   MOV A,#0FH         ; 0x0F as '-' Character 
   MOV U_b,A
   MOV U_b+1,A
   MOV U_b+2,A
   MOV U_b+3,A
   MOV U_b+4,A
   MOV U_b+5,A

END2:   
   RET

   END    



Then go here http://www.doctronics.co.uk/4511.htm


Best/
Ap

List of 10 messages in thread
TopicAuthorDate
hi everybody i need ur help            01/01/70 00:00      
   hex numbers into decimal            01/01/70 00:00      
   Why wear the old hat ??            01/01/70 00:00      
      yes DS1820 is one such            01/01/70 00:00      
         Not I2C, but...            01/01/70 00:00      
      Mind you,            01/01/70 00:00      
      Here we go again ...            01/01/70 00:00      
   Here we go again ... yes but we are helpless ;-)            01/01/70 00:00      
      More old hat - Why go there?            01/01/70 00:00      
      the reason this happens again and again ...            01/01/70 00:00      

Back to Subject List