Created
October 31, 2018 17:10
-
-
Save FrankBuss/e22e31d76edf273ee8e374a645af1f45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a NAND lookup table | |
#!/usr/bin/python3 | |
import sys | |
for i in xrange(256): | |
if i % 16 == 0: | |
sys.stdout.write(" .db ") | |
# PB1 input | |
a = i & 2 | |
# PB2 input | |
b = i & 4 | |
# calculate PB0 output: A NAND B | |
q = not (a and b) | |
# set all other bits to 1, for pullup | |
q = q | 0xfe | |
sys.stdout.write("0x" + format(int(q), '02x')) | |
sys.stdout.flush() | |
if i % 16 == 15: | |
sys.stdout.write("\n") | |
else: | |
sys.stdout.write(", ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment