i know some logic so posting it..it works fine
Design a 9's Complement Generator for a BCD Digit 9's complement
The 9's complement of a decimal number is found by subtracting each digit in the number from 9
Decimal Digit 9's complement
0 9
1 8
2 7
. .
. .
. .
9 0
the 9's complement of 28=99-28=71
the 9's complement of 562=999-562=437
Subtraction of a smaller decimal number from a larger one can be done by adding the 9's complement of the smaller number to the larger number and then adding the carry to the result (end around carry). When subtracting a larger number from a smaller one there is no carry and the result in the 9's complement form is negative:
Rules
Add 9's complement of B to A
If result>9, correct by adding 0110
If most significant carry is produced (i.e.=1), then the result is positive and the end around carry must be added
If the most significant carry is 0 (no carry) then the result is negative and you get the 9's complement of the result
For you example
36=0011 0110
9's complement of 27 is (99-27=72)-->0111 0010
add both ---> 1010 1000//(but 1010 is greater than 1001 therefore add with 0110 but 1000 is less than 9 so add with 000)
>> (1) 0000 1000
shift this carry to LSB
you will get 00001001 (9)