Macro Unsigned
Posted: Sat Jul 27, 2019 3:05 pm
Simple Unsigned Macro...
The compiler takes over the optimization
Little John´s code is shorter... Jump
The compiler takes over the optimization

Little John´s code is shorter... Jump

Code: Select all
;-TOP
; Unsigned - The compiler takes over the optimization
; by mk-soft, v1.01, 27.07.2019
; Integer and quad only for save result
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Macro Unsigned(Value)
((Bool(TypeOf(Value) = #PB_Byte) * $FF) |
(Bool(TypeOf(Value) = #PB_Ascii) * $FF) |
(Bool(TypeOf(Value) = #PB_Word) * $FFFF) |
(Bool(TypeOf(Value) = #PB_Unicode) * $FFFF) |
(Bool(TypeOf(Value) = #PB_Long) * $FFFFFFFF) |
(Bool(TypeOf(Value) = #PB_Integer) * $FFFFFFFF) |
(Bool(TypeOf(Value) = #PB_Quad) * $FFFFFFFFFFFFFFFF) & Value)
EndMacro
CompilerElse
Macro Unsigned(Value)
((Bool(TypeOf(Value) = #PB_Byte) * $FF) |
(Bool(TypeOf(Value) = #PB_Ascii) * $FF) |
(Bool(TypeOf(Value) = #PB_Word) * $FFFF) |
(Bool(TypeOf(Value) = #PB_Unicode) * $FFFF) |
(Bool(TypeOf(Value) = #PB_Long) * $FFFFFFFF) |
(Bool(TypeOf(Value) = #PB_Integer) * $FFFFFFFFFFFFFFFF) |
(Bool(TypeOf(Value) = #PB_Quad) * $FFFFFFFFFFFFFFFF) & Value)
EndMacro
CompilerEndIf
b.b = -2
s.s = Hex(Unsigned(b)) + " = " + Str(Unsigned(b))
Debug s
w.w = -2
s.s = Hex(Unsigned(w)) + " = " + Str(Unsigned(w))
Debug s
l.l = -2
s.s = Hex(Unsigned(l)) + " = " + Str(Unsigned(l))
Debug s