Renamed x64 to x86
This commit is contained in:
@ -4,7 +4,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/asm"
|
||||
"git.akyoto.dev/cli/q/src/ast"
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// CompileAssignDivision compiles an assign statement that has quotient and remainder on the left side and division on the right.
|
||||
@ -37,8 +37,8 @@ func (f *Function) CompileAssignDivision(node *ast.Assign) error {
|
||||
|
||||
divisor := right.Children[1]
|
||||
err = f.Execute(right.Token, dividendRegister, divisor)
|
||||
f.RegisterRegister(asm.MOVE, quotientVariable.Register, x64.RAX)
|
||||
f.RegisterRegister(asm.MOVE, remainderVariable.Register, x64.RDX)
|
||||
f.RegisterRegister(asm.MOVE, quotientVariable.Register, x86.RAX)
|
||||
f.RegisterRegister(asm.MOVE, remainderVariable.Register, x86.RDX)
|
||||
|
||||
if isTemporary {
|
||||
f.FreeRegister(dividendRegister)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/expression"
|
||||
"git.akyoto.dev/cli/q/src/types"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// CompileCall executes a function call.
|
||||
@ -50,7 +50,7 @@ func (f *Function) CompileCall(root *expression.Expression) (*Function, error) {
|
||||
|
||||
if pkg == "kernel32" || pkg == "user32" || pkg == "gdi32" || pkg == "comctl32" {
|
||||
parameters := root.Children[1:]
|
||||
registers := x64.WindowsInputRegisters[:len(parameters)]
|
||||
registers := x86.WindowsInputRegisters[:len(parameters)]
|
||||
|
||||
for i := len(parameters) - 1; i >= 0; i-- {
|
||||
_, err := f.ExpressionToRegister(parameters[i], registers[i])
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/cpu"
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/token"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// ExecuteRegisterNumber performs an operation on a register and a number.
|
||||
@ -25,16 +25,16 @@ func (f *Function) ExecuteRegisterNumber(operation token.Token, register cpu.Reg
|
||||
f.RegisterNumber(asm.MUL, register, number)
|
||||
|
||||
case token.Div, token.DivAssign:
|
||||
f.SaveRegister(x64.RAX)
|
||||
f.SaveRegister(x64.RDX)
|
||||
f.SaveRegister(x86.RAX)
|
||||
f.SaveRegister(x86.RDX)
|
||||
tmp := f.NewRegister()
|
||||
f.RegisterNumber(asm.MOVE, tmp, number)
|
||||
f.RegisterRegister(asm.DIV, register, tmp)
|
||||
f.FreeRegister(tmp)
|
||||
|
||||
case token.Mod, token.ModAssign:
|
||||
f.SaveRegister(x64.RAX)
|
||||
f.SaveRegister(x64.RDX)
|
||||
f.SaveRegister(x86.RAX)
|
||||
f.SaveRegister(x86.RDX)
|
||||
tmp := f.NewRegister()
|
||||
f.RegisterNumber(asm.MOVE, tmp, number)
|
||||
f.RegisterRegister(asm.MODULO, register, tmp)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/cpu"
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/token"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// ExecuteRegisterRegister performs an operation on two registers.
|
||||
@ -25,13 +25,13 @@ func (f *Function) ExecuteRegisterRegister(operation token.Token, register cpu.R
|
||||
f.RegisterRegister(asm.MUL, register, operand)
|
||||
|
||||
case token.Div, token.DivAssign:
|
||||
f.SaveRegister(x64.RAX)
|
||||
f.SaveRegister(x64.RDX)
|
||||
f.SaveRegister(x86.RAX)
|
||||
f.SaveRegister(x86.RDX)
|
||||
f.RegisterRegister(asm.DIV, register, operand)
|
||||
|
||||
case token.Mod, token.ModAssign:
|
||||
f.SaveRegister(x64.RAX)
|
||||
f.SaveRegister(x64.RDX)
|
||||
f.SaveRegister(x86.RAX)
|
||||
f.SaveRegister(x86.RDX)
|
||||
f.RegisterRegister(asm.MODULO, register, operand)
|
||||
|
||||
case token.And, token.AndAssign:
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/register"
|
||||
"git.akyoto.dev/cli/q/src/scope"
|
||||
"git.akyoto.dev/cli/q/src/token"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// NewFunction creates a new function.
|
||||
@ -26,12 +26,12 @@ func NewFunction(pkg string, name string, file *fs.File, body []token.Token) *Fu
|
||||
Scopes: []*scope.Scope{{}},
|
||||
},
|
||||
CPU: cpu.CPU{
|
||||
All: x64.AllRegisters,
|
||||
General: x64.GeneralRegisters,
|
||||
Input: x64.InputRegisters,
|
||||
Output: x64.OutputRegisters,
|
||||
SyscallInput: x64.SyscallInputRegisters,
|
||||
SyscallOutput: x64.SyscallOutputRegisters,
|
||||
All: x86.AllRegisters,
|
||||
General: x86.GeneralRegisters,
|
||||
Input: x86.InputRegisters,
|
||||
Output: x86.OutputRegisters,
|
||||
SyscallInput: x86.SyscallInputRegisters,
|
||||
SyscallOutput: x86.SyscallOutputRegisters,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/scope"
|
||||
"git.akyoto.dev/cli/q/src/token"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
"git.akyoto.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// ResolveTypes parses the input and output types.
|
||||
@ -27,7 +27,7 @@ func (f *Function) ResolveTypes() error {
|
||||
f.AddVariable(&scope.Variable{
|
||||
Name: param.Name,
|
||||
Type: param.Type,
|
||||
Register: x64.InputRegisters[i],
|
||||
Register: x86.InputRegisters[i],
|
||||
Alive: uses,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user