Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
i8080-core half_carry_table and !sub_half_carry_table
Add Index: (((A & 0x88) >> 1) | ((VAL & 0x88) >> 2) | ((A+B) & 0x88) >> 3)) & 0x7
A VAL RES ADD Meaning
0 0 0 0 Both A&Val are <0x7,
0 0 1 0 Both A&Val are <0x7, carry from 2 to 3 (but no half-carry)
0 1 0 1 There was a carry from 2 to 3 which caused a carry out of 3 (ie: 0111 + 1111 = 1 000)
0 1 1 0 There was no carry from 2 to 3, so no carry out of 3
1 0 0 1 There was a carry from 2 to 3 which caused a carry out of 3 (ie: 1111 + 0111 = 1 0000)
1 0 1 0 There was no carry from 2 to 3, so n ocarry out of 3
1 1 0 1 There was a carry out of 3 (1000 + 1000 = 1 0000)
1 1 1 1 There was a carry into 3 and out of 3 (1100 + 1100 = 0 1000)
(((A & 0x88) >> 1) | ((VAL & 0x88) >> 2) | ((A+B) & 0x88) >> 3)) & 0x7
A VAL RES SUB Meaning
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment