create return address as own class to hold return addresses

to distinguish from integer, which does not need adjusting
This commit is contained in:
Torsten Ruger
2018-05-30 23:49:01 +03:00
parent e86ca5ae9d
commit e39e96f646
9 changed files with 60 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ module Risc
@booted = false
@risc_init = nil
@constants = []
@next_address = nil
end
attr_reader :constants , :cpu_init
attr_reader :booted , :translated
@@ -61,6 +62,17 @@ module Risc
@constants << const
end
# hand out a return address for use as constant the address is added
def get_address
10.times do # 10 for whole pages
@next_address = Parfait::ReturnAddress.new(0,@next_address)
add_constant( @next_address )
end unless @next_address
addr = @next_address
@next_address = @next_address.next_integer
addr
end
# To create binaries, objects (and labels) need to have a position
# (so objects can be loaded and branches know where to jump)
#