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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/09/11 05:48
Read: times


 
#183270 - divide by 10
Responding to: ???'s previous message
thank you for the response. Why should the decimal value 100 be loaded into the B register? everywhere in my text book shows the value 10. here is the code from the book
RAM_ADDR    EQU 40H
ASCI_RSULT  EQU 50H
COUNT       EQU 3

;------------MAIN PROGRAM
        ORG 0
        ACALL BIN_DEC_CONVRT
        ACALL DEC_ASCI_CONVRT
        SJMP  $

;----------CONVERTING BIN (HEX) TO DEC (00-FF TO 000-255)
BIN_DEC_CONVRT:
MOV	R0, #RAM_ADDR
MOV	A, P1
MOV	B, #10
DIV	AB
MOV	@R0, B
INC	R0
MOV	B, #10
DIV	AB
MOV	@R0, B
INC	R0
MOV	@R0, A
RET
      	
      ;-------CONVERTING DEC DIGITS TO DISPLAYABLE ASCII DIGITS
       
      DEC_ASCI_CONVRT:
MOV	R0, #RAM_ADDR
MOV	R1, #ASCI_RSULT
MOV	R2, #3
BACK:	MOV	A, @R0
ORL	A, #30H
ACALL	SEND
MOV	@R1, A
INC	R0
INC	R1
DJNZ	R2, BACK
RET
 


I'm not saying that i don't believe you, just that I wish the instructor would have pointed out that mistake in the book instead of confusing everyone. originally in the above code the MOV A, P1 instruction was to move the value from the dip switches on the 8051. i had changed it to port 2 cause i wasnt really sure where to get the data to convert. the only other place i can think of is TL0.

List of 17 messages in thread
TopicAuthorDate
need help to display timer count on hyperterminal and LED'S            01/01/70 00:00      
   Attention to Details            01/01/70 00:00      
      divide by 10            01/01/70 00:00      
         Hundredth digit is quotient of division by 100            01/01/70 00:00      
            thanks            01/01/70 00:00      
               Debugged with pen and paper?            01/01/70 00:00      
                  Debugged            01/01/70 00:00      
                     Decimal or hexadecimal?            01/01/70 00:00      
                        decision            01/01/70 00:00      
                           So take up the challenge then            01/01/70 00:00      
                              agreed            01/01/70 00:00      
                        Actually BCD!!            01/01/70 00:00      
   Oh Details Details            01/01/70 00:00      
      update            01/01/70 00:00      
         Issues            01/01/70 00:00      
            better to check before sending            01/01/70 00:00      
               Even Better....            01/01/70 00:00      

Back to Subject List