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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/01/03 13:55
Read: times


 
#55887 - RE: SUBB
Responding to: ???'s previous message
Is this the right code? It does not do anything but subtract 2 from 2, and jumpos to Label_2 always.

Basically there is no "sub" instruction in the MCS-51 instruction set, so you have to make sure the carry isnt set, to avoid inadvertant accounting of borrow value. the instruction following subb will jump to Label_1 if carry is set, that means the second number is greater than the first (here both are 2), or if the result is 0 or positive, it will jump to Label_2

MOV A, #2
CLR c
SUBB A, #2
JC, Label_1
SJMP Label_2

btw, no comma is needed after JC.

girish

List of 6 messages in thread
TopicAuthorDate
SUBB            01/01/70 00:00      
   RE: SUBB            01/01/70 00:00      
   RE: SUBB            01/01/70 00:00      
   Read all about it!            01/01/70 00:00      
   RE: SUBB            01/01/70 00:00      
      RE: SUBB            01/01/70 00:00      

Back to Subject List