MC14500B

From Esolang
Jump to navigation Jump to search

The MC14500B is a 1-bit microcontroller designed by Motorola featuring a minimal set of 16 instructions (4-bit each), one 1-bit register and a 1-bit data bus.

Conventionally, the register is initially set to 0. If the input signals run out, the signal stays at the last inputted bit.

Instruction set

Instruction code (in binary) Mnemonic Description
0000 NOPO No change in registers. Set Flag O to 1.
0001 LD Load result register. Data -> R
0010 LDC Load complement to register. NOT(Data) -> R
0011 AND Logical and. R AND Data -> R
0100 ANDC Complement and. NOT(R AND Data) -> R
0101 OR Logical or. R OR Data -> R
0110 ORC Complement or. NOT(R OR Data) -> R
0111 XNOR Exclusive nor. NOT(R XOR Data) -> R
1000 STO Store. R -> Data
1001 STOC Store complement. NOT(R) -> Data
1010 IEN Input enable. Input -> Register
1011 OEN Output enable. Register -> Output
1100 JMP Jump to the start of the program.
1101 RTN Skip the next instruction.
1110 SKZ Skip the next instruction if the register is 0.
1111 NOPF No change in registers. Set Flag F to 1.

"implementation"

# Truth-machine: ABEC

input_signal = [0]

curr = 0

Data = 0
Acc  = 0

code = "ABEC"

ptr = 0

while ptr < len(code):
	i = code[ptr]
	if i == "1":
		R = Data
	if i == "2":
		R = 1 - Data
	if i == "3":
		R = R & Data
	if i == "4":
		R = 1 - (R & Data)
	if i == "5":
		R = R | Data
	if i == "6":
		R = 1 - (R | Data)
	if i == "7":
		R = 1 - (R ^ Data)
	if i == "8":
		Data = R
	if i == "9":
		Data = 1 - R
	if i == "A":
		R = input_signal[curr % len(input_signal)]
		curr += 1
	if i == "B":
		print(R,end="")
	if i == "C":
		ptr = 0
		continue
	if i == "D":
		ptr += 1
	if i == "E":
		if R == 0:
			ptr += 1
	ptr += 1

External Links