I’m trying to create a 24-bit datatype for a SIC/XE assembly simulator. So far I have this code:
import Core.Intrinsics # defining a primitive 24-bit integer type for integer registers primitive type SICInt 24 end # other signed types -> SICInt SICInt(x::Int) = Core.Intrinsics.trunc_int(SICInt, x) # SICInt -> other signed types Int32(x::SICInt) = Core.Intrinsics.sext_int(Int32, x) Int64(x::SICInt) = Core.Intrinsics.sext_int(Int64, x) Int(x::SICInt) = Core.Intrinsics.sext_int(Int, x) # printing help Base.show(io::IO, x::SICInt) = print(io, Int(x)) # Math operations # TODO # machine data structure mutable struct Machine # registers A::SICInt B::SICInt X::SICInt L::SICInt S::SICInt T::SICInt F::Float64 # TODO end
saved in a file called
Weird behaviour happens when I try to load the code into REPL:
see: 2 became of type Core.Int64 instead of Int64.
Strangely, this doesn’t happen if I call
typeof(2) before the include statement:
Does anyone have any idea what could be going wrong here or how could I fix this?
Thank you very much.