renamed instruciton tools to arm machine
This commit is contained in:
parent
f1a7993b47
commit
eca9e66f73
@ -11,7 +11,7 @@ module Asm
|
|||||||
|
|
||||||
class ArmAssembler
|
class ArmAssembler
|
||||||
|
|
||||||
InstructionTools::REGISTERS.each do |reg , number|
|
ArmMachine::REGISTERS.each do |reg , number|
|
||||||
define_method(reg) { Asm::Register.new(reg , number) }
|
define_method(reg) { Asm::Register.new(reg , number) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ module Asm
|
|||||||
define_method(inst.to_s+'s') do |*args|
|
define_method(inst.to_s+'s') do |*args|
|
||||||
instruction clazz , inst.to_s+'s' , *args
|
instruction clazz , inst.to_s+'s' , *args
|
||||||
end
|
end
|
||||||
InstructionTools::COND_CODES.keys.each do |cond_suffix|
|
ArmMachine::COND_CODES.keys.each do |cond_suffix|
|
||||||
suffix = cond_suffix.to_s
|
suffix = cond_suffix.to_s
|
||||||
define_method(inst.to_s + suffix) do |*args|
|
define_method(inst.to_s + suffix) do |*args|
|
||||||
instruction clazz , inst + suffix , *args
|
instruction clazz , inst + suffix , *args
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module Asm
|
module Asm
|
||||||
|
|
||||||
module InstructionTools
|
module ArmMachine
|
||||||
OPCODES = {
|
OPCODES = {
|
||||||
:adc => 0b0101, :add => 0b0100,
|
:adc => 0b0101, :add => 0b0100,
|
||||||
:and => 0b0000, :bic => 0b1110,
|
:and => 0b0000, :bic => 0b1110,
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "label"
|
require_relative "label"
|
||||||
require_relative "assembly_error"
|
require_relative "assembly_error"
|
||||||
require_relative "instruction_tools"
|
require_relative "arm_machine"
|
||||||
|
|
||||||
module Asm
|
module Asm
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ module Asm
|
|||||||
# Argurments are registers or labels or string/num Literals
|
# Argurments are registers or labels or string/num Literals
|
||||||
|
|
||||||
class Instruction < Code
|
class Instruction < Code
|
||||||
include InstructionTools
|
include ArmMachine
|
||||||
|
|
||||||
COND_POSTFIXES = Regexp.union( COND_CODES.keys.collect{|k|k.to_s} ).source
|
COND_POSTFIXES = Regexp.union( COND_CODES.keys.collect{|k|k.to_s} ).source
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ module Asm
|
|||||||
|
|
||||||
attr_reader :opcode, :args
|
attr_reader :opcode, :args
|
||||||
# Many arm instructions may be conditional, where the default condition is always (al)
|
# Many arm instructions may be conditional, where the default condition is always (al)
|
||||||
# InstructionTools::COND_CODES names them, and this attribute reflects it
|
# ArmMachine::COND_CODES names them, and this attribute reflects it
|
||||||
attr_reader :cond
|
attr_reader :cond
|
||||||
attr_reader :operand
|
attr_reader :operand
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ module Asm
|
|||||||
# Logic ,Maths, Move and compare instructions (last three below)
|
# Logic ,Maths, Move and compare instructions (last three below)
|
||||||
|
|
||||||
class LogicInstruction < Instruction
|
class LogicInstruction < Instruction
|
||||||
include Asm::InstructionTools
|
|
||||||
|
|
||||||
def initialize( opcode , args)
|
def initialize( opcode , args)
|
||||||
super(opcode , args)
|
super(opcode , args)
|
||||||
|
@ -4,7 +4,6 @@ module Asm
|
|||||||
# ADDRESSING MODE 2
|
# ADDRESSING MODE 2
|
||||||
# Implemented: immediate offset with offset=0
|
# Implemented: immediate offset with offset=0
|
||||||
class MemoryInstruction < Instruction
|
class MemoryInstruction < Instruction
|
||||||
include Asm::InstructionTools
|
|
||||||
|
|
||||||
def initialize(opcode , args)
|
def initialize(opcode , args)
|
||||||
super( opcode , args )
|
super( opcode , args )
|
||||||
|
@ -3,7 +3,6 @@ require "asm/instruction"
|
|||||||
module Asm
|
module Asm
|
||||||
# ADDRESSING MODE 4
|
# ADDRESSING MODE 4
|
||||||
class StackInstruction < Instruction
|
class StackInstruction < Instruction
|
||||||
include Asm::InstructionTools
|
|
||||||
|
|
||||||
def initialize(opcode , args)
|
def initialize(opcode , args)
|
||||||
super(opcode,args)
|
super(opcode,args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user