att

What does AT&T syntax do about ambiguity between other mnemonics and operand-size suffixes?

邮差的信 提交于 2021-02-05 07:11:26
问题 In AT&T syntax instructions often have to be suffixed with the appropriate operand size, with q for operations on 64-bit operands. However in MMX and SSE there is also movq instruction, with the q being in the original Intel mnemonic and not an additional suffix. So how will this be represented in AT&T? Is another q suffix needed like movqq %mm1, %mm0 movqq %xmm1, %xmm0 or not? And if there are any other instructions that end like AT&T suffixes (like paddd , slld ), do they work the same way?

x86 Assembly (AT&T): How do I dynamically allocate memory to a variable at runtime?

穿精又带淫゛_ 提交于 2021-02-04 08:36:07
问题 I am trying to allocate an amount of space to a variable at runtime. I know that I can allocate a constant amount of space to a variable at compile time, for instance: .data variable: # Allocate 100 bytes for data .space 100 However, how do I allocate a variable amount of space to a variable at runtime? For instance, allocating %eax bytes of space to the variable at runtime? 回答1: You can't dynamically allocate static storage. You need to use the stack, or malloc / mmap / whatever (sometimes

How to convert an 8086 emu assembly program to linux assembly comaptible

点点圈 提交于 2021-01-29 14:17:12
问题 I am writing a code to convert hex (A-F) to decimal in assembly. I managed to write it on 8086 emu but I need it for linux. I need help. The code works absolutely fine on 8086 emulator n windows. But I am unable to convert it into Linux syntax. I am not familiar with the Linux Syntax for assembly. This is my 8686 code. org 100h .model small .stack 100h .data msg1 db 'Enter a hex digit:$' msg2 db 'In decimal it is:$' .code main proc mov ax,@data mov ds,ax lea dx,msg1 mov ah,9 int 21h mov ah,1

Can't size instruction

这一生的挚爱 提交于 2021-01-28 02:20:50
问题 I was wondering why some assembly instructions can be inferred, but others cannot. For example, in the following program I have: .globl main main: push %rbp mov %rsp, %rbp mov $8, -8(%rbp) mov -8(%rbp), %rax pop %rbp ret I get the following error: stack.s:5: Error: no instruction mnemonic suffix given and no register operands; can't size instruction However, if I change: the 5th line to: movq $8, -8(%rbp) It runs without error. How can all the other operations infer the size, but that

What does 'callq *(%rax)' mean?

混江龙づ霸主 提交于 2021-01-27 18:53:56
问题 I'm in a gdb session to analyze a postmortem crash. I'm looking at disassemble output for a function and I see this: => 0x00007f8d354aed52 <+50>: callq *(%rax) The => indicates that this was the instruction called at the time of the crash. So I got a seg fault calling the function at *(%rax) . I'm pretty new to assembly. I see that parens around a register mean to deference (get the value at) that address. Thus (%rax) means to get the value of the pointer currently stored in %rax . What does

How do I pass inputs into extended asm?

匆匆过客 提交于 2021-01-27 13:09:14
问题 Consider this code, from my earlier question. int main(){ asm("movq $100000000, %rcx;" "startofloop: ; " "sub $0x1, %rcx; " "jne startofloop; "); } I would like to make number of iterations of the loop a C variable, so I tried the following after reading this document. int main(){ int count = 100000000; asm("movq %0, %rcx;" "startofloop: ; " "sub $0x1, %rcx; " "jne startofloop; ":: "r"(count)); } Unfortunately, this fails to compile, and breaks with the following error. asm_fail.c: In

How to determine the appropriate MOV instruction suffix based on the operands?

社会主义新天地 提交于 2021-01-16 03:52:01
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

How to determine the appropriate MOV instruction suffix based on the operands?

一世执手 提交于 2021-01-16 03:51:07
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

X86 read from stdin and write to stdout without referring the standard library

六月ゝ 毕业季﹏ 提交于 2020-12-30 03:56:06
问题 I'm a beginner in X86 assembly language. I know how to read from stdin and write to stdout using build-in functions, but I'm not sure how to do it with plain assembly code(i.e. manipulating registers and taking advantage of system calls). #include <stdio.h> #include <unistd.h> int main(){ /* copy input to output */ char buf[BUFSIZ]; int n; while ((n = read(0, buf, BUFSIZ)) > 0) write(1, buf, n); return 0; } This is the C code I wrote to first read from the standard input (represented by

X86 read from stdin and write to stdout without referring the standard library

做~自己de王妃 提交于 2020-12-30 03:55:50
问题 I'm a beginner in X86 assembly language. I know how to read from stdin and write to stdout using build-in functions, but I'm not sure how to do it with plain assembly code(i.e. manipulating registers and taking advantage of system calls). #include <stdio.h> #include <unistd.h> int main(){ /* copy input to output */ char buf[BUFSIZ]; int n; while ((n = read(0, buf, BUFSIZ)) > 0) write(1, buf, n); return 0; } This is the C code I wrote to first read from the standard input (represented by