2014-04-22 23:12:43 +02:00
|
|
|
module Asm
|
2014-04-23 11:38:38 +02:00
|
|
|
class StringLiteral
|
2014-04-22 23:12:43 +02:00
|
|
|
def initialize(str)
|
|
|
|
#align
|
|
|
|
length = str.length
|
|
|
|
# rounding up to the next 4 (always adding one for zero pad)
|
|
|
|
pad = ((length / 4 ) + 1 ) * 4 - length
|
|
|
|
raise "#{pad} #{self}" unless pad >= 1
|
|
|
|
@string = str + "\x00" * pad
|
|
|
|
end
|
|
|
|
|
|
|
|
def position
|
|
|
|
throw "Not set" unless @address
|
|
|
|
@address
|
|
|
|
end
|
|
|
|
def at address
|
|
|
|
@address = address
|
|
|
|
end
|
|
|
|
def length
|
|
|
|
@string.length
|
|
|
|
end
|
|
|
|
def assemble(io, as)
|
|
|
|
io << @string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|