Gast
#718485
Hallo 8051 Cracks, Meine Frage bezieht sich auf das Verhalten des 8051 nach einem ADD Befehl, im Besonderen interessiert mich wie die einzelnen Bits im PSW danach gesetzt werden: Ein Beispiel: Current Program Memory Content: 0x0a51 24 fa Das ist folgende Instruction: ADD A,#FA Also der Konstante Wert 0xFa wird dem Accumulator hinzuaddiert. Ausgangssituation: Accumulator: 0x09 PSW: 0x00 Jetzt wir die Instruction ausgeführt: ADD A,#FA Addition in Binary: 11111010 #data: 00001001 Accumulator ________+ 100000011 Result So wenn man das nun mit Keil's C51 Simulator simuliert dann sieht das Ergebnis so aus: PSW = 0xC0 = 11000000 => CY=1, AC=1, OV=0 Meiner Meinung nach sollte es aber so aussehen: PSW = 0x84 = 10000100 => CY=1, AC=0, OV=1 aus dem Datasheet und 8052.com kann man entnehmen: The Carry bit (C) is set if there is a carry-out of bit 7. In other words, if the unsigned summed value of the Accumulator, operand and (in the case of ADDC) the Carry flag exceeds 255 Carry is set. Otherwise, the Carry bit is cleared. The Auxillary Carry (AC) bit is set if there is a carry-out of bit 3. In other words, if the unsigned summed value of the low nibble of the Accumulator, operand and (in the case of ADDC) the Carry flag exceeds 15 the Auxillary Carry flag is set. Otherwise, the Auxillary Carry flag is cleared. The Overflow (OV) bit is set if there is a carry-out of bit 6 or out of bit 7, but not both. In other words, if the addition of the Accumulator, operand and (in the case of ADDC) the Carry flag treated as signed values results in a value that is out of the range of a signed byte (-128 through +127) the Overflow flag is set. Otherwise, the Overflow flag is cleared. Was sagen die 8051 Cracks dazu? Warum setzt der Keil Simulator das PSW auf 0xC0? Welche Auffassung ist den nun Richtig? vielen Dank im Voraus lg aus Wien, Thomas