Questions tagged [instruction-encoding]
99 questions
0
votes
0 answers
How does an x86 CPU distinguish between different size immediate operands?
I am currently looking through the intel x86 instruction manual (https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html), specifically volume 2, to get an understanding of the features of x86_64 (since I didn't program…

Hypatia of Sva
- 9
- 2
0
votes
1 answer
Why does RISC-V 'J-immediate' encode imm[11] in inst[20]?
Recently I was learning 'Computer Organization and Design RISC-V' book by David A. Patterson, and was stuck by some questions.
Why RISC-V 'J-immediate' put imm[11] in inst[20] instead of inst[24]?
Is it related with detailed circuit design, if so,…

zg c
- 113
- 1
- 1
- 7
0
votes
1 answer
How is data width determined for load/store instructions in Rocket Core?
I'm working on a project where we need to modify a Rocket-chip core with new instructions.
We're wondering: how does data width for load/store instructions is determined ?
For instance, LB/LH/LU have the same parameters set…

JohnDoe
- 1
- 2
0
votes
1 answer
Is "strb w0, [x2, w3, uxtw]" the same as "strb w0, [x2, w3, uxtw #0]"?
I'm totally puzzled.
I thought that the following instructions are totally the same:
strb w0,[x2,w3,uxtw 0]
strb w0,[x2,w3,uxtw]
but when I assemble them, I get different encoding:
40 48 23 38 strb w0, [x2, w3, uxtw]
40 58 23 38 …

raff
- 339
- 2
- 12
0
votes
1 answer
Why the risc-v instruction "addi sp,sp,-32" is converted to binary code "11 01"?
I'm learning risc-v instruction set. I know that "addi sp,sp,-40" will be converted to "fd810113". But I don't know why "addi sp,sp,-32" is converted to binary code "11 01".

Chris633
- 3
- 1
0
votes
0 answers
Finding address location with jump instruction
Assume Loop is at location 0xAB94258 and at 0xAB894264 we have a j loop instruction. How can we know the value of the label 'Loop'?
i tried switching it to binary and shifting right twice "target = address x 4" but i think im misunderstanding.
0
votes
0 answers
Why MOVZX r64, r/m8 behave like MOVZX r32, r/m8
Here is the code snippet
int main()
{
unsigned long int ui64{};
unsigned char ui8{ 0xAA };
unsigned short ui16 { 0xBBBB};
ui64 = ui8;
ui64 = ui16;
}
Here is the opcodes that will need
MOVZX—Move With Zero-Extend
…

UPinar
- 1,067
- 1
- 2
- 16
0
votes
1 answer
Jump addressing from PC to a target
Suppose we needed to jump to the memory address 0xAE87698C.
If the current PC value is 0xAF70018B show the j instruction to perform the jump
(display it as both a 32-bit binary number and as an equivalent hex value)
I know I need to shift one of…

eswcs
- 5
- 3
0
votes
0 answers
getting an opcode? To perform jmp
I specify:
E9 00 89 9F E8 90
But actually the transition to another address, I found a formula, but I don't understand how it works.
"FROM - TO - 5 bytes.
Let's say the OT is 0057A3FF.
And BC is 00899FE8.
Then: 0057A3FF - 00899FE8 = 31FBE9.
How do I…

Вили Били
- 11
- 1
0
votes
0 answers
How to decide if FF instruction is a call instruction or a jmp instruction in X86-64 ELF under linux?
I have such ELF in linux and I disassemble it to do some research. However, I get confused "How to decide if FF instruction is a call instruction or a jmp instruction?
For example, the ff instruction occurs like
`
8405de: 48 8b 04 c5 00 81 98 …

yun qi
- 1
- 1
0
votes
2 answers
Why is x86 MOV two bytes, not one? How does the opcode and machine code work?
I'm having trouble understanding a very basic x86 instruction. The instruction is
0x080491d7 <+1>: mov %esp,%ebp
I know that it moves the value of esp into ebp. But I'm trying to understand the opcodes.
The instruction is 2 bytes long, not…

Neurosis
- 1
- 1
0
votes
1 answer
NASM produces unexpected extra operand size prefix
I am having a problem with NASM running on Linux amd64.
Running nasm on a single instruction mov eax, 0x12345678 produces 6 bytes:
00000000 <.data>:
0: 66 b8 78 56 mov $0x5678,%ax
4: 34 12 xor …

iBug
- 35,554
- 7
- 89
- 134
0
votes
1 answer
Little Endian in Instruction
I'm learning about RISC-V instructions in Computer Architecture.
What i wonder is, because of little endian, any number in RISC-V's instruction's little digit is on little bit.
I know that RISC-V use little endian to express data in memory. but I'm…

WooLyung
- 1
- 2
0
votes
0 answers
arm instructionLoad Register (immediate) Encoding T4 , P/U/W meaning
From:
https://developer.arm.com/documentation/ddi0403/latest page 246,
Load Register (immediate) Encoding T4,
where to find the definition of P/U/W for bit 10/9/8?

PZ30
- 1
0
votes
0 answers
How to manually calculate jump offsets in intel x86-32 ? How are the instructions fetched in x86? One instruction at a time or as chunks of 4 bytes?
I was going through the paper Smashing The Stack For Fun And Profit. Now there is a section of assembly code where we need to calculate the offsets manually forjmp and call instruction, which are relative to the program counter.
jmp …

Abhishek Ghosh
- 597
- 7
- 18