Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Insood
Created August 7, 2017 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Insood/f142493255127126fff052488ad5d3bd to your computer and use it in GitHub Desktop.
Save Insood/f142493255127126fff052488ad5d3bd to your computer and use it in GitHub Desktop.
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