6.1: ARITHMETIC INSTRUCTIONS
1. Find the CY and AC flags for each of the following:
(a) MOV A, #3FH CY=0 No carry out from D7
ADD A, #45H AC=1 carry from D3 to D4 00111111
+01000101
10000100
(b) MOV A, #99H CY=0 No carry out from D7
ADD A, #58H AC=1 carry from D3 to D4 10011001
+01011000
11110001
(c) MOV A, #0FFH CY=1
SETB C AC=0
ADDC A, #00
SETB C-> CY=1 11111111
+CY 1
100000000
+00000000
100000000
(d) MOV A, #OFFH CY=1
ADD A, #1 AC=1 11111111
+ 1
100000000
(e) MOV A, #OFEH CY=1
SETB C AC=1
ADDC A, #01 11111110
+ 1 11111111
+ 1
100000000
(f) CLR C CY=1
MOV A, #0FFH AC=1
ADDC A, #01
ADDC A, #0 11111111
+00000001
100000000
+00000000
100000000 6. State the steps that the SUBB instruction will go through for each of the following:
1. Take the 2’s complement of the subtrahend
2. Add it to the minuend
3. Invert the carry (a) 23H-12H 23H -> 00100011 00100011 12H -> 00010010 – 2’s complement +11101110 100010001 Step 3: CY=1 -> CF=0 Positive number 11H (b) 43H-53H 43H -> 01000011 01000011 53H -> 01010011 – 2’s complement +10101101 11110000 Step 3: CY=0 -> CF=1 Negative number -F0H (c) 99-99 99 -> 10011001 10011001 99 -> 10011001 – 2’s complement +01100111 100000000 Step 3: CY=1 -> CF=0 Positive 0
6.2: SIGNED NUMBER CONCEPTS AND ARITHMETIC OPERATIONS 16. Show how the following are represented by the assembler: (a) -23 -> 11101001 (b) +12 -> 00001100
(c) -28 -> 11100100
(d) +6FH -> 01101111
(e) -128 -> 10000000
(f) +127 -> 01111111 19. Explain the difference between the CY and OV flags and where each one is used.
The CY is when there is a carry bit from D7. The OV is set when either there is a carry from D6 to D7 OR a carry out of D7. If both are carried then it is a CY and OV is 0 20. Explain when the OV flag is raised. The OV flag is only