Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

about PSW

Status
Not open for further replies.

bleach

New Member
i am having problem in understanding the following bit of PSW of microcontroller 8051:
first, AC (auxiliary carry flag) that it is set if a carry was generated out of bit 3 into bit 4. THIS BART i really don't understand, if we take for example 55H + AAH
second, flag0 how i know it's set or not
third, PSW D1(--) please tell me what is it cause i haven't seen any explanation about it.


BEST REGARD
 
1 + 1 in binary is 10 (zero and carry 1). The AC bit is set if a carry was generated out of bit 3 into bit 4 of the accumulator.

Flag 0 is a general purpose flag. You test it the same as any bit in bit-addressable memory, using the JB or JNB instruction.

Your last question doesn't make much sense but I think you're referring to D1H, or PSW.1
which is reserved and not used by the programmer..
 
Last edited:
thanks alot.
for the first question can you give me one example pleas so it will be more clear for me.
for the third question it is D1 yes

thanks a lot
 
The auxiliary carry is used in BCD arithmetic. I've never had to do that on an 8051 so I've never used it. You might also checkout the The Decimal Adjust Accumulator instruction.
DA A
which is helpful in doing BCD arithmetic. In 30 years of 8051 programming I've never had occasion to use that instruction either.
 
thanks alot.
for the first question can you give me one example pleas so it will be more clear for me.
for the third question it is D1 yes

thanks a lot

These are the 5 rules of binary addition
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10
1 + 1 + 1 =11


Start adding with the LSB's.
eg. 10 + 15
Code:
      1010       <- 10
      1111       <- 15
  
      11         <- carry
   + _____
     11001


Here a carry was generated out of bit 3 into bit 4, where bit 0 is the LSB.
This will always happen if the result of adding two nibbles is greater than 15.
 
comment

The auxiliary carry is used in BCD arithmetic. I've never had to do that on an 8051 so I've never used it. You might also checkout the The Decimal Adjust Accumulator instruction.

DA A

which is helpful in doing BCD arithmetic. In 30 years of 8051 programming I've never had occasion to use that instruction either.

you mean its not used in programming the µc, actually i am studying and i want to understand how it work, beside that i haven't started yet the programming part.

thanks:)
 
thanks and great

Here a carry was generated out of bit 3 into bit 4, where bit 0 is the LSB.
This will always happen if the result of adding two nibbles is greater than 15.

thanks alot every body
 
you mean its not used in programming the µc, actually i am studying and i want to understand how it work, beside that i haven't started yet the programming part.

thanks:)
If you don't need to do BCD arithmetic, then the AC(Auxiliary Carry) is useless and unused. If you do need to do BCD arithmetic then it could be useful.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top