From e3c3840bc6430659d355ca929ce46482d19ecbf6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 4 Oct 2014 12:51:08 +0300 Subject: [PATCH] a creative moment, making up instructions --- lib/register/instructions/function_return.rb | 13 +++++++++++++ lib/register/instructions/register_transfer.rb | 12 ++++++++++++ lib/register/instructions/save_return.rb | 13 +++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 lib/register/instructions/function_return.rb create mode 100644 lib/register/instructions/register_transfer.rb create mode 100644 lib/register/instructions/save_return.rb diff --git a/lib/register/instructions/function_return.rb b/lib/register/instructions/function_return.rb new file mode 100644 index 00000000..5a89e5bc --- /dev/null +++ b/lib/register/instructions/function_return.rb @@ -0,0 +1,13 @@ +module Register + + # return from a function call + #register and index specify where the return address is stored + + class FunctionReturn < Instruction + def initialize register , index + @register = register + @index = index + end + attr_reader :register , :index + end +end \ No newline at end of file diff --git a/lib/register/instructions/register_transfer.rb b/lib/register/instructions/register_transfer.rb new file mode 100644 index 00000000..e55386d2 --- /dev/null +++ b/lib/register/instructions/register_transfer.rb @@ -0,0 +1,12 @@ +module Register + + #transfer the constents of one register to another. possibly called move in some cpus + + class RegisterTransfer < Instruction + def initialize from , to + @from = from + @to = to + end + attr_reader :from, :to + end +end \ No newline at end of file diff --git a/lib/register/instructions/save_return.rb b/lib/register/instructions/save_return.rb new file mode 100644 index 00000000..494b97d1 --- /dev/null +++ b/lib/register/instructions/save_return.rb @@ -0,0 +1,13 @@ +module Register + + # save the return address of a call + # register and index specify where the return address is stored + + class SaveReturn < Instruction + def initialize register , index + @register = register + @index = index + end + attr_reader :register , :index + end +end \ No newline at end of file