inline-assembly

How do I tell GCC asm that an input register is clobbered?

点点圈 提交于 2019-12-29 07:48:27
问题 I'm trying to do a 64=32x32 multiply via the x86 mul instruction, but I only need the high dword of the result (the edx register). So naturally, I tried listing edx as an output register and eax as a clobbered register. This seems natural to me, but eax is also an input register. When I try to tell GCC that eax is clobbered, it gives an error message. __asm__("mull\t%2" : "=d"(div10) : "%a"(UINT32_C(0x1999999A)), "r"(number) : "cc", "rax"); If I try that, it throws this error message:

How do I tell GCC asm that an input register is clobbered?

别等时光非礼了梦想. 提交于 2019-12-29 07:48:06
问题 I'm trying to do a 64=32x32 multiply via the x86 mul instruction, but I only need the high dword of the result (the edx register). So naturally, I tried listing edx as an output register and eax as a clobbered register. This seems natural to me, but eax is also an input register. When I try to tell GCC that eax is clobbered, it gives an error message. __asm__("mull\t%2" : "=d"(div10) : "%a"(UINT32_C(0x1999999A)), "r"(number) : "cc", "rax"); If I try that, it throws this error message:

When to use earlyclobber constraint in extended GCC inline assembly?

左心房为你撑大大i 提交于 2019-12-28 06:32:06
问题 I understand when to use a cobbler list (e.g. listing a register which is modified in the assembly so that it doesn't get chosen for use as an input register, etc), but I can't wrap my head around the the earlyclobber constraint & . If you list your outputs, wouldn't that already mean that inputs can't use the selected register (aside from matching digit constraints)? For example: asm( "movl $1, %0;" "addl $3, %0;" "addl $4, %1;" "addl %1, %0;" : "=g"(num_out) : "g"(num_in) : ); Would & even

How to convert Linux 32-bit gcc inline assembly to 64-bit code? [closed]

旧街凉风 提交于 2019-12-28 04:09:03
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I'm attempting to convert RR0D Rasta Ring 0 Debugger from 32-bit mode to 64-bit mode (long mode) in Linux, using gcc. I'm familiar with x86 32-bit assembly (in MS-DOS environment) but I'm a beginner in x86 64-bit

What is the syntax for directives in gcc asm command?

北慕城南 提交于 2019-12-25 19:02:35
问题 I'm trying to use .ascii directive in the gcc extended asm command but I keep getting compiler errors. What is the exact syntax for directives inside extended asm? I tried the following options but none of the worked: asm ("NOP;" ".ASCII ""ABC""" ); I got "Error: junk at end of line, first unrecognized character is `/'" asm ("NOP;" ".ASCII "ABC"" ); I got Error: junk at end of line, first unrecognized character is `/'" asm ("NOP;" .ASCII "ABC" ); I got "error: expected ‘:’ or ‘)’ before ‘/’

High Level to ASM conversion

蹲街弑〆低调 提交于 2019-12-25 18:35:19
问题 I'm learning assembly programming and I've been tasked with converting a for loop (along with any array use) into assembly within my program. The program simply takes an encryption key ( EKey ) and uses it to encrypt an array of letters ( hello for example). Here is the loop in C++ : void encrypt_chars(int length, char EKey) { char temp_char; // char temporary store for (int i = 0; i < length; i++) // encrypt characters one at a time { temp_char = OChars[i]; // temp_char now contains the

(inline assembly in C) Funny memory segmentation fault [closed]

柔情痞子 提交于 2019-12-25 17:03:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have the following part in my asm assembly code "LOOP%=:\n\t" "movapd (%%eax), %%xmm4\n\t" "addl $32, %%eax\n\t" "movsd (%%edx), %%xmm5\n\t" "addl $16, %%edx\n\t" "movapd %%xmm4, %%xmm6\n\t" "subl $1, %%ecx\n\t" "unpcklpd %%xmm5, %%xmm5\n\t" "testl %%ecx, %%ecx\n\t" "mulpd %%xmm5, %%xmm6\n\t" "movsd -8(%%edx),

Pointers and release build in Visual Studio

China☆狼群 提交于 2019-12-25 10:02:19
问题 I have a weird problem when I create a release build with Visual Studio 2008. I was wondering if one of you could help me understand what is going on. Description: I have a class member function which returns a pointer to a structure stored in the class: const MyStruct * Myclass::getPointer() { return mystruct_variable; // this is properly initialyzed } One another point worth pointing out is that this class/method is in a dll, and I export it to use in a separate executable project. When I

Pointers and release build in Visual Studio

冷暖自知 提交于 2019-12-25 10:01:49
问题 I have a weird problem when I create a release build with Visual Studio 2008. I was wondering if one of you could help me understand what is going on. Description: I have a class member function which returns a pointer to a structure stored in the class: const MyStruct * Myclass::getPointer() { return mystruct_variable; // this is properly initialyzed } One another point worth pointing out is that this class/method is in a dll, and I export it to use in a separate executable project. When I

Code blocks Ver.16.01 crashing during run cycle of programme

不羁的心 提交于 2019-12-25 08:20:05
问题 I have a program which has been proved to run on an older version of codeblocks (ver 13.12) but does not seem to work when I try it on the newer version (ver 16.01). The purpose of the programme is to enter two integers which will then be added, mult etc. It uses asm code which I am new at. My question is why does it say windows has stopped responding after I type 2 integers and press enter? Here is the code: //Program 16 #include <stdio.h> #include <iostream> using namespace std; int main()