Do not put variables after code
Apparently the original assembler does not do this, and putting them inline with the code is needed for subroutines
This commit is contained in:
parent
86b642ba25
commit
d648660889
|
@ -81,6 +81,7 @@ func (machine *Machine) Execute (offset int16) (err error) {
|
|||
// Store the PC at address X and jump to X+1
|
||||
machine.memory[operand] = machine.counter
|
||||
machine.counter = operand
|
||||
println(operand)
|
||||
|
||||
case LOAD:
|
||||
// Load contents of address X into AC
|
||||
|
|
10
masm/main.go
10
masm/main.go
|
@ -65,8 +65,7 @@ func main () {
|
|||
origin := 0
|
||||
originSet := false
|
||||
|
||||
operations := []Statement { }
|
||||
symbols := []Statement { }
|
||||
statements := []Statement { }
|
||||
symbolTable := map[string] int { }
|
||||
|
||||
// parse
|
||||
|
@ -87,11 +86,7 @@ func main () {
|
|||
}
|
||||
|
||||
if statement.opcode != ORG {
|
||||
if statement.isOperation {
|
||||
operations = append(operations, statement)
|
||||
} else {
|
||||
symbols = append(symbols, statement)
|
||||
}
|
||||
statements = append(statements, statement)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -105,7 +100,6 @@ func main () {
|
|||
|
||||
// get symbol addresses
|
||||
placer := origin
|
||||
statements := append(operations, symbols...)
|
||||
for _, statement := range statements {
|
||||
if statement.label != "" {
|
||||
_, alreadyDefined := symbolTable[statement.label]
|
||||
|
|
Loading…
Reference in New Issue