Skip to content

Instantly share code, notes, and snippets.

func (mc *microcontroller) run() {
instruction := (*mc.memory)[mc.programCounter]
fmt.Printf("%X : %X\n", mc.programCounter, instruction)
switch instruction {
case 0x00:
mc.nop()
case 0xC3:
mc.jmp()
case 0x01, 0x11, 0x21, 0x31:
mc.lxi()
@Insood
Insood / gist:f142493255127126fff052488ad5d3bd
Created August 7, 2017 04:34
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)
class GameState:
def __init__(self):
self.handlers = {}
def default_handler(self,sw_number):
print( "Switch %s pushed!"%sw_number)
def on_switch(self,sw_number):
if sw_number in self.handlers:
self.handlers[sw_number]()
PS E:\Dropbox\8080\test> ruby .\server.rb
New connection
Current client count: 1
Client identified: 8080-golang .\test_roms\8080PRE.COM
New connection
Current client count: 2
Client identified: 8080-golang .\test_roms\8080EX1.COM
8080-golang .\test_roms\8080PRE.COM | 8080-golang .\test_roms\8080EX1.COM
ADDR OP B C D E H L A SZ-X-P-C SP | ADDR OP B C D E H L A SZ-X-P-C SP
0100 3E 00 00 00 00 00 00 00 00000010 0000 | 0100 C3 00 00 00 00 00 00 00 00000010 0000
ADDR : instruction B C D E H L A SZ-X-P-C PW SP
0100 : 3E 01 MVI 00 00 00 00 00 00 00 00000010 0000
0102 : FE 02 CPI 00 00 00 00 00 00 01 00000010 0000
0104 : CA 00 00 JZ 00 00 00 00 00 00 01 10000111 0000
0107 : FE 01 CPI 00 00 00 00 00 00 01 10000111 0000
0109 : C2 00 00 JNZ 00 00 00 00 00 00 01 01010110 0000
010C : C3 11 01 JMP 00 00 00 00 00 00 01 01010110 0000
0111 : CD 17 01 CALL 00 00 00 00 00 00 01 01010110 0000
0117 : E1 POP HL 00 00 00 00 00 00 01 01010110 FFFE
0118 : 7C MOV AH 00 00 00 00 01 14 01 01010110 0000
// Instruction - a struct which encapsulates a function pointer and also some information
// about the CPU instruction
type Instruction struct {
name string
dataSize int
function func(cpu *CPU)
cycles int
}
var instructions = []Instruction{
<changeSet author="liquibase-docs" id="createTable-example">
<createTable catalogName="cat"
remarks="A String"
schemaName="public"
tableName="person"
tablespace="A String">
<column name="address" type="varchar(255)"/>
</createTable>
</changeSet>
module IncludableOne
def initialize
super
puts "IncludableOne::initialize"
register_on_save :includable_one_saved
end
def includable_one_saved
puts "Saved One"
end
end
s = Struct.new(:a,:b,:c)
a = [1,2,3]
b = s.new(*a)
puts b.a
puts b.b
puts b.c
@Insood
Insood / ERPLookup
Last active October 26, 2018 22:10
class ERP
def self.flat_bom(part_number)
Rails.cache.fetch("erp_flat_bom_#{part_number}") do
parts = {}
bom = ERP.get_bom(part_number)
bom.items.each do |item|
[... recursively go down to get every part in this indented BOM...]
end
parts