basically going to cmd+a delete everything
instead of being treated like an interpreter, im going to actually assemble the source code into object programs.
Why am i doing this?
- because i want to learn more about assemblers and stuff because i think they are Cool.
- my code is a mess and an interpreter isn't really the most ideal way to do something like this.
- i want to learn more about assemblers
how it will be implemented next
there will be an additional DAT instruction (DAT #n/Bn/&n), for use with labels for defining data.
example:
LDA letterA
OUT // will output "A"
letterA: DAT #65
will be a two-pass assembler
on the first pass i:
- go through each line of code
- is it a label definition?
- yes:
- store label name and line in a table (address symbol table)
- no:
- is it END instruction?
- yes:
- go to second pass
- no:
- go to next line
- yes:
- is it END instruction?
- yes:
on the second pass:
- go through each line
- is instruction valid?
- yes:
- is operator valid? (some instructions dont take one or require an address etc)
- yes:
- is the operator a label?
- yes:
- using the symbol table, replace with label line and save to output
- no:
- save to output
- yes:
- is the operator a label?
- no:
- stop and report error to user
- yes:
- is operator valid? (some instructions dont take one or require an address etc)
- no:
- stop and report error to user
- yes:
- output the assembled program to the binary format
type Instruction struct {
Operand int // will be later decoded back into instructions that are useful
Operator int // Numbr .
}- output binary to file
assembly done!! yayy
running the code:
- basically how i am now, read in file according to the spec i set for the binary file
- run it lol