Questions tagged [immediate-operand]

94 questions
39
votes
3 answers

Why use LDR over MOV (or vice versa) in ARM assembly?

I'm looking through this tutorial: http://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/os/ok01.html The first line of assembly is: ldr r0,=0x20200000 the second is: mov r1,#1 I thought ldr was for loading values from memory into registers. But…
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
37
votes
1 answer

Difference between movq and movabsq in x86-64

I'm talking about data movement instructions in the x86-64 Intel architecture. I have read that the regular movq instruction can only have immediate source operands that can be represented as 32-bit two's complement numbers, while the movabsq…
IgNite
  • 652
  • 2
  • 6
  • 17
27
votes
1 answer

Invalid constant after fixup?

For some reason, when I try to compile this bit of code, the compiler says syscall.s:72:invalid constant (0x172) after fixup: .globl _mach_msg_trap$MACH _mach_msg_trap$MACH: stmfd sp!, {r4,r7} mov r7, #370 /* this is line 72 */ svc 0 …
Kristina
  • 15,859
  • 29
  • 111
  • 181
23
votes
3 answers

RISC-V: Immediate Encoding Variants

In the RISC-V Instruction Set Manual, User-Level ISA, I couldn't understand section 2.3 Immediate Encoding Variants page 11. There is four types of instruction formats R, I, S, and U, then there is a variants of S and U types which are SB and UJ…
18
votes
4 answers

RISC-V build 32-bit constants with LUI and ADDI

LUI (load upper immediate) is used to build 32-bit constants and uses the U-type format. LUI places the U-immediate value in the top 20 bits of the destination register rd, filling in the lowest 12 bits with zeros. I found this in manual, but if I…
Li Hanyuan
  • 506
  • 1
  • 4
  • 7
18
votes
7 answers

How can ARM's MOV instruction work with a large number as the second operand?

I just begin to study ARM assembly language, and am not clear about how to use MOV to transfer an immediate number into a register. From both the ARM reference manual and my textbook, it's said that range of immediate number following MOV…
13
votes
3 answers

Is it possible to multiply by an immediate with mul in x86 Assembly?

I am learning assembly for x86 using DosBox emulator. I am trying to perform multiplication. I do not get how it works. When I write the following code: mov al, 3 mul 2 I get an error. Although, in the reference I am using, it says in…
user2192774
  • 3,807
  • 17
  • 47
  • 62
11
votes
1 answer

Why would we use addiu instead of addi?

In MIPS assembly, what is the benefit of using addiu over addi? Isn't addiu unsigned (and will ruin our calculations?)
chickenman
  • 728
  • 2
  • 9
  • 29
9
votes
2 answers

why we can't move a 64-bit immediate value to memory?

First I am a little bit confused with the differences between movq and movabsq, my text book says: The regular movq instruction can only have immediate source operands that can be represented as 32-bit two’s-complement numbers. This value is then…
user9623401
9
votes
6 answers

MUL instruction doesn't support an immediate value

I've read a few tutorials and examples, but I cannot wrap my head around how the MUL instruction works. I've used ADD and SUB without problems. So apparently this instruction multiplies its operand by the value in a register. What register (eax,…
Tanner Babcock
  • 91
  • 1
  • 1
  • 3
8
votes
1 answer

What's the difference between the x86-64 AT&T instructions movq and movabsq?

After reading this stack overflow answer, and this document, I still don't understand the difference between movq and movabsq. My current understanding is that in movabsq, the first operand is a 64-bit immediate operand whereas movq sign-extends a…
MattHusz
  • 452
  • 4
  • 15
8
votes
3 answers

Range of immediate values in ARMv8 A64 assembly

My understanding is that immediate parameters in ARMv8 A64 assembly can be 12 bits long. If that is the case, why does this line of assembly code: AND X12, X10, 0xFEF Produce this error (when compiled with gcc) Error: immediate out of range at…
Zack
  • 6,232
  • 8
  • 38
  • 68
7
votes
0 answers

Why does SSE/AVX lack loading an immediate value?

As far as I know, there is no instruction in SSE/AVX for loading an immediate. One workaround is loading a value to a normal register and movd, but compilers seem to think this is more costly than loading from memory even for a single scalar…
xiver77
  • 2,162
  • 1
  • 2
  • 12
7
votes
1 answer

How to load an immediate number to a register in RV32I Base Instruction Set?

Recently, I am working on RV32I base instruction set, and I did not find any instruction looks like LD r1, imm. Thus, I am wondering how assembly programer load an immediate to a register in RV32I system? Thanks. To do so, programmer could use ADDI…
Betty
  • 161
  • 1
  • 2
  • 6
7
votes
3 answers

Loading 32 bit values to a register in arm assembly

I want to load 1 32 bit hexadecimal directly into a register using arm assembly. mov r1,#0x6c617669 This cannot be used because from this instruction we can only load 8 bit values. So I have load the 32 bit value directly from the memory. So how…
wageesha
  • 99
  • 1
  • 1
  • 6
1
2 3 4 5 6 7