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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/02/07 18:44
Read: times


 
#134130 - Best way to check greater than/less than
Responding to: ???'s previous message
Complete neub on 8051 assembly here. But this is just the subject I was looking for but no one really answered. Specifically, I have a value in the accumulator, A, which takes on values 0, 2, 4, 6, 8, 10, 12 and 14. I need to take special action when 8 or larger. Expected to find a jgt instructions but per Keil manual, only supported for 252 arch not plain 8051.

Does this look reasonable?
(Sorry, need a clue on how to format a code snippet)
:
rl A ;A now 0, or 2, or 4 ....
push ACC ;effectively, push A
anl A,#08H ;check for A >=8
cjne A,#08H,USE0_3 ;A < 8, use IM0_3
pop ACC ;A >= 8, restore A
add A,#IM4_7+8 ;pointer into IM4_7
jmp OVR0_3 ;skip over 0-3 setup
USE0_3: pop ACC ;ch A < 8, restore A
add A,#IM0_3+8 ;get the pointer into IM0_3
OVR0_3: mov R0,A ;from here on, same for all A
:

This attempts to implement.
for (A=0; A<16; A+=2)
if ( A >= 8 )
do this;
else
do that;





List of 20 messages in thread
TopicAuthorDate
Best way to check greater than/less than            01/01/70 00:00      
   greater than or equal            01/01/70 00:00      
      do you mean '51 assembler?            01/01/70 00:00      
         Thanks!            01/01/70 00:00      
         reading and glancing at the CJNE            01/01/70 00:00      
   answer            01/01/70 00:00      
      i need to compare two numbers........            01/01/70 00:00      
         Strange question!            01/01/70 00:00      
      Eh?            01/01/70 00:00      
    Best way to check greater than/less than            01/01/70 00:00      
       Best way to check greater than/less than            01/01/70 00:00      
         why not just this            01/01/70 00:00      
            Ok, thanks. This looks better.            01/01/70 00:00      
               error/mistake            01/01/70 00:00      
                  I see            01/01/70 00:00      
                     exactly!            01/01/70 00:00      
                        sure            01/01/70 00:00      
                        neubular direct            01/01/70 00:00      
                           1) wonderful 2)why, it is valid            01/01/70 00:00      
      Newb            01/01/70 00:00      

Back to Subject List