Add comments

master
kolaente 4 years ago
parent 390e7440f9
commit 34645bfe14
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 3
      parser/program_parser.go
  2. 22
      programs/storage.hal

@ -34,6 +34,9 @@ func ParseFile(filepath string) (hal.Program, error) {
func ParseProgram(input []string) (hal.Program, error) {
program := make(hal.Program)
for index, line := range input {
if len(line) == 0 || line[0] == '#' {
continue
}
args := strings.Split(line, " ")
if len(args) <= 1 {
continue

@ -1,16 +1,22 @@
0001 START
# Init counter
0002 LOADIND 1
0003 DIVNUM 2
0004 STOREIND <reg 1>
# Counter
0002 LOADNUM 0
0003 STORE 1
# counter++
0009 LOAD 1
# Max
0004 LOADNUM 65536
0005 STORE 2
# Loop
0006 LOAD 1
0007 DIVNUM 2
0008 STOREIND 1
0009 MULNUM 2
0010 ADDNUM 1
0011 STORE 1
# loop
0011 JUMP 0002
0012 SUB 2
0013 JUMPNEG 0006
1000 DUMPREG
1010 DUMPPROG

Loading…
Cancel
Save