Questions tagged [immediate-operand]
94 questions
7
votes
0 answers
In a MIPS assembly `addi` instruction, how is a hexadecimal immediate interpreted?
Is there is a standard or recommendation for how the addi instruction (and others) should be interpreted in assembly, when hexadecimal immediate values are used?
Example:
addi $t0, $zero, 0xffff
I was expecting this to mean the same as addi $t0,…

Miguel
- 658
- 1
- 6
- 19
7
votes
1 answer
Can I add 64bit constants to 64bit registers?
At my 64bit Intel machine following code works:
mov rdi, 1 << 40
add r10, rdi
and this quite equivalent looking one produces a warning and doesn't work:
add r10, 1 << 40
Should I just stick with number 1 or am I missing something? This behaviour…

user1864035
- 113
- 1
- 4
6
votes
3 answers
GCC seems to prefer small immediate values in comparisons. Is there a way to avoid that?
Firstly a trivial mathematical fact: given integers n and m, we have n < m if, and only if, n <= m - 1.
GCC seems to prefer immediate values of smaller absolute value. Hence, when m is known and other conditions are met, the compiler chooses among…

Cassio Neri
- 19,583
- 7
- 46
- 68
6
votes
2 answers
Why isn't # needed before numbers with DC.W (Define Constant), only instructions?
I have this line of code:
X DC.W 5
This means basically X = 5 But shouldn't be X DC.W #5 ?
When using MOVE I need always #
MOVE.B #1,VAR

dynamic
- 46,985
- 55
- 154
- 231
5
votes
2 answers
How does LUI/ORI on MIPS work to create a 32-bit constant value?
I have this risc v code :
lui S0, 0x1234
ori S1, S0, 0x5678
add S2, S1, S1
and the question asks me, "What does the register S2 hold?"
The question explains that lui and I quote:
"Load the lower half word of the immediate imm into the upper…

Razi Awad
- 53
- 1
- 3
5
votes
1 answer
Why doesn't MIPS have a Store Immediate instruction just like Load Immediate instruction?
MIPS has a Load Immediate (LI) pseudo instruction to load a 32-bit immediate value into a register. But it does not have Store Immediate (SI) instruction to store a 32-bit immediate value to Memory. Can someone explain me why?

sandywho
- 353
- 1
- 7
- 16
5
votes
2 answers
In MIPS, when to use a signed-extend, when to use a zero-extend?
I am designing a MIPS processor as my individual project, by now I met a very confused question. I just can not summarize when to use signed-extend and when to use zero-extend in MIPS.
I have searched lots of resources, mostly said:
1) ADDI, ADDIU…

Shuaiyu Jiang
- 239
- 1
- 3
- 15
5
votes
1 answer
Literals VS Immediate Operands
In the systems software course that I have this semester, we are being taught assemblers and other system software. While reading across the course I came across the topic of LITERALS.
There was a comparison between literals and immediate operands…

Crystal Meth
- 589
- 1
- 4
- 16
4
votes
1 answer
How to add an immediate byte to a long register with AT&T syntax on x86?
From what I understand reading the Intel manuals, it should be possible to write an instruction like add $0x7f, %ebx and it should be encoded as 83 /0 ib for a total of three bytes.
However, when I do this (whether I use add, addb, or addl) it…

user1084743
- 67
- 1
- 6
4
votes
0 answers
GNU assembler override size of immediate operand
I am trying to match a specific sequence of bytes with GNU assembler. Objdump disassembles these bytes as:
81 e2 66 00 00 00 and edx,0x66
However, GAS "helpfully" assembles this instruction more efficiently:
83 e2 66 and …

rtburns
- 41
- 2
4
votes
1 answer
Using the blend instructions in intel intrinsics (AVX)
I have a question regarding the AVX _mm256_blend_pd function.
I want to optimize my code where I use heavily the _mm256_blendv_pd function. This unfortunately has a pretty high latency and low throughput. This function takes as input three __m256d…

DevX10
- 483
- 2
- 6
- 16
4
votes
1 answer
Translate the following machine language code (0x2237FFF1) into MIPS assembly
I have translate this code so far and what I'm not understanding is how to figure out (calculate)the amount of 16-bit immediate address.
0x2237FFF1
To binary
0010 0010 0011 0111 1111 1111 1111 0001
Now I'm reading the opcode (001000) and know that…

Adam
- 856
- 2
- 9
- 18
4
votes
2 answers
Specifying 8bit immediate in x86-64 (GNU Assembler)
I'm trying to write some special routine in assembly, for x86-64 (even x86 example is fine). The problem: my immediates are only resolved at link time.
For example,
addq $Label2-Label1, %rax
will add the difference between the two labels/symbols to…

kktsuri
- 333
- 2
- 11
4
votes
1 answer
What's difference between number with $ or without $ symbol in at&t assembly syntax?
Let's say .data section has following item:
0x1234 00010203 04050607 08090a0b 0c0d0e0f
0x1238 10000000
And in code,
mov $0x1234, %eax
mov 0x1238, %ebx
I believe with $ symbol, it would be constant number, so %eax will have memory address, but what…

REALFREE
- 4,378
- 7
- 40
- 73
4
votes
1 answer
How to encode immediate value in arm?
Suppose there is an inst like this:
add ip, ip, #0x5000
the machine code is
05 CA 8C E2
and
E2 8C CA 05 = 11100010100011001100 1010 00000101
imm = rotate_right(101B, 1010B*2) = 0x5000
But if we know 0x5000, how can we get 101000000101?…

scvyao
- 143
- 1
- 12