machine-code

Matching the intel codes to disassembly output

試著忘記壹切 提交于 2021-02-05 08:18:52
问题 I'm starting to use the Intel reference page to look up and learn about the op codes (instead of asking everything on SO). I'd like to make sure that my understanding is OK and ask a few questions on the output between a basic asm program and the intel instruction codes. Here is the program I have to compare various mov instructions into the rax -ish register (is there a better way to say "rax" and its 32- 16- and 8- bit components?): .globl _start _start: movq $1, %rax # move immediate into

Matching the intel codes to disassembly output

大兔子大兔子 提交于 2021-02-05 08:18:49
问题 I'm starting to use the Intel reference page to look up and learn about the op codes (instead of asking everything on SO). I'd like to make sure that my understanding is OK and ask a few questions on the output between a basic asm program and the intel instruction codes. Here is the program I have to compare various mov instructions into the rax -ish register (is there a better way to say "rax" and its 32- 16- and 8- bit components?): .globl _start _start: movq $1, %rax # move immediate into

Shorter x86 call instruction

半腔热情 提交于 2021-01-28 09:26:52
问题 For context I am x86 golfing. 00000005 <start>: 5: e8 25 00 00 00 call 2f <cube> a: 50 push %eax Multiple calls later... 0000002f <cube>: 2f: 89 c8 mov %ecx,%eax 31: f7 e9 imul %ecx 33: f7 e9 imul %ecx 35: c3 ret call took 5 bytes even though the offset fit into a single byte! Is there any way to write call cube and assemble with GNU assembler and get a smaller offset? I understand 16 bit offsets could be used, but ideally I'd have a 2 byte instruction like call reg . 回答1: There is no call

In this x86-64 instruction encoding documentation, what's the use of having 8, 16, 32, 64 bit GPRs? [duplicate]

放肆的年华 提交于 2021-01-28 07:37:10
问题 This question already has answers here : The advantages of using 32bit registers/instructions in x86-64 (2 answers) Intel X86 Assembly: How to tell many bits wide is an argument? (1 answer) x86 find out operand size of instruction given only the hex machine code? (2 answers) Why is default operand size 32 bits in 64 mode? (1 answer) 64 bit assembly, when to use smaller size registers (5 answers) Closed 3 months ago . I'm learning (slowly and painfully) about x86-64 instructions, and found

Difference between MOV r/m8,r8 and MOV r8,r/m8

荒凉一梦 提交于 2021-01-27 04:39:44
问题 By looking at intel volume of instructions, I found this: 1) 88 /r MOV r/m8,r8 2) 8A /r MOV r8,r/m8 When I write a line like this in NASM, and assemble it with the listing option: mov al, bl I get this in the listing: 88D8 mov al, bl So obviously NASM chosed the first instruction of the two above, but isn't the second instruction an option two? if so, on what basis did NASM chosed the first? 回答1: These two encodings exist because a modr/m byte can only encode one memory operand. So to allow

Does the compiler actually produce Machine Code?

感情迁移 提交于 2020-12-30 02:18:29
问题 I've been reading that in most cases (like gcc) the compiler reads the source code in a high level language and spits out the corresponding machine code. Now, machine code by definition is the code that a processor can understand directly. So, machine code should be only machine (processor) dependent and OS independent. But this is not the case. Even if 2 different operating systems are running on the same processor, I can not run the same compiled file (.exe for Windows or .out for Linux) on

Does the compiler actually produce Machine Code?

痞子三分冷 提交于 2020-12-30 02:18:22
问题 I've been reading that in most cases (like gcc) the compiler reads the source code in a high level language and spits out the corresponding machine code. Now, machine code by definition is the code that a processor can understand directly. So, machine code should be only machine (processor) dependent and OS independent. But this is not the case. Even if 2 different operating systems are running on the same processor, I can not run the same compiled file (.exe for Windows or .out for Linux) on