From 2d83473d74f79f7cd3c4241543910eb1125020cc Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Jul 2018 11:53:18 +0300 Subject: [PATCH] add assembler getting the layers better --- lib/risc.rb | 1 + lib/risc/assembler.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/risc/assembler.rb diff --git a/lib/risc.rb b/lib/risc.rb index e4583c56..cacfb537 100644 --- a/lib/risc.rb +++ b/lib/risc.rb @@ -26,6 +26,7 @@ require "parfait" require_relative "risc/parfait_adapter" require_relative "risc/machine" require_relative "risc/method_compiler" +require_relative "risc/assembler" class Fixnum def fits_u8? diff --git a/lib/risc/assembler.rb b/lib/risc/assembler.rb new file mode 100644 index 00000000..4c7d0f93 --- /dev/null +++ b/lib/risc/assembler.rb @@ -0,0 +1,11 @@ +module Risc + class Assembler + attr_reader :method , :instructions + def initialize( method , instructions) + @method = method + @instructions = instructions + total = instructions.total_byte_length / 4 + 1 + method.binary.extend_to( total ) + end + end +end