Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 1.71 KB

File metadata and controls

73 lines (54 loc) · 1.71 KB

my rambles

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?

  1. because i want to learn more about assemblers and stuff because i think they are Cool.
  2. my code is a mess and an interpreter isn't really the most ideal way to do something like this.
  3. 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

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
        • no:
          • stop and report error to user
    • no:
      • stop and report error to user
  • 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