Update utils

This commit is contained in:
Dominic Grimm 2022-06-25 19:32:03 +02:00
parent fb9fa4353c
commit e10f11fc1a
No known key found for this signature in database
GPG key ID: A6C051C716D2CE65
2 changed files with 5 additions and 5 deletions

View file

@ -181,7 +181,7 @@ module Hence
end
def resolve(_data : Assembler::Data) : Bytes
n = Utils.split_uint16(@number)
n = Utils.split_u16(@number)
Bytes[n[0], n[1]]
end
@ -227,7 +227,7 @@ module Hence
if @bytes.size == 1
@bytes[0].to_u16
else
Utils.merge_uint16(@bytes[0], @bytes[1])
Utils.merge_u8(@bytes[0], @bytes[1])
end
end
@ -253,7 +253,7 @@ module Hence
def resolve_as_number(_data : Assembler::Data) : UInt16
slice = resolve(_data)
Utils.merge_uint16(slice[0], slice[1])
Utils.merge_u8(slice[0], slice[1])
end
def to_s : String

View file

@ -2,14 +2,14 @@ module Hence
module Utils
extend self
macro split_uint16(x)
macro split_u16(x)
{
({{ x }} >> 8).to_u8,
({{ x }} & 0xff_u8).to_u8
}
end
macro merge_uint16(x, y)
macro merge_u8(x, y)
({{ x }}.to_u16 << 8) | {{ y }}
end
end