Added file scanner
This commit is contained in:
@ -12,20 +12,17 @@ import (
|
||||
// Assembler contains a list of instructions.
|
||||
type Assembler struct {
|
||||
Instructions []Instruction
|
||||
// labels map[string]Index
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// New creates a new assembler.
|
||||
func New() *Assembler {
|
||||
return &Assembler{
|
||||
Instructions: make([]Instruction, 0, 8),
|
||||
// labels: map[string]Index{},
|
||||
}
|
||||
}
|
||||
|
||||
// Finalize generates the final machine code.
|
||||
func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
func (a *Assembler) Finalize(verbose bool) ([]byte, []byte) {
|
||||
code := make([]byte, 0, len(a.Instructions)*8)
|
||||
data := make(Data, 0, 16)
|
||||
pointers := []Pointer{}
|
||||
@ -46,8 +43,10 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
case SYSCALL:
|
||||
code = x64.Syscall(code)
|
||||
}
|
||||
}
|
||||
|
||||
if a.Verbose {
|
||||
if verbose {
|
||||
for _, x := range a.Instructions {
|
||||
log.Info.Println(x.String())
|
||||
}
|
||||
}
|
||||
@ -63,11 +62,6 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
return code, data
|
||||
}
|
||||
|
||||
// AddLabel creates a new label at the current position.
|
||||
// func (a *Assembler) AddLabel(name string) {
|
||||
// a.labels[name] = Index(len(a.instructions))
|
||||
// }
|
||||
|
||||
// MoveRegisterData moves a data section address into the given register.
|
||||
func (a *Assembler) MoveRegisterData(reg register.ID, data []byte) {
|
||||
a.Instructions = append(a.Instructions, Instruction{
|
||||
|
Reference in New Issue
Block a user