Handbook
Glossary
%load-immediate ( reg val -- )
Vocabulary
cpu
.
architecture
Inputs
reg
a register symbol
val
a value
Outputs
None
Word description
Emits code for loading an immediate value into a register. On
x86
, if val is 0, then an
XOR
instruction is emitted instead of
MOV
because the former is shorter.
See also
##load-tagged
Definition
USING:
system
;
IN:
cpu.architecture
HOOK:
%load-immediate
cpu
( reg val -- )
Methods
USING:
assocs
cpu.architecture
cpu.arm.64.assembler
kernel
math
sequences
system
;
M:
arm.64
%load-immediate
[
XZR
MOVr
]
[
{
0 1 2 3
}
[
tuck
-16
*
shift
65535
bitand
]
with
map>alist
[
0
=
]
reject-values
unclip
overd
first2
rot
MOVZ
[
first2
rot
MOVK
]
with
each
]
if-zero
;
USING:
cpu.architecture
cpu.x86.assembler
cpu.x86.assembler.operands
kernel
kernel.private
math
system
;
M:
x86
%load-immediate
{
fixnum
}
declare
[
32-bit-version-of
dup
XOR
]
[
MOV
]
if-zero
;