inline-assembly

Vector Sum using AVX Inline Assembly on XeonPhi

喜夏-厌秋 提交于 2019-12-11 13:15:37
问题 I am new to use XeonPhi Intel co-processor. I want to write code for a simple Vector sum using AVX 512 bit instructions. I use k1om-mpss-linux-gcc as a compiler and want to write inline assembly. Here it is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <assert.h> #include <stdint.h> void* aligned_malloc(size_t size, size_t alignment) { uintptr_t r = (uintptr_t)malloc(size + --alignment + sizeof(uintptr_t)); uintptr_t t = r + sizeof(uintptr

gcc assembly extended register

微笑、不失礼 提交于 2019-12-11 12:46:43
问题 What parameter/constraint do I have to use in order to tell the compiler to use an extended register pair as the output/input? static inline void mac_dsp(int64_t *c, uint32_t a, uint32_t b){ //This does not compile - "madd.u [%a15]0,[%a15]0,%d15,%d2: Too many operands" __asm__ ("madd.u %0,%0,%1,%2" : "+m" (*c) : "d" (a), "d" (b)); //This does compile but I don't explicitly want to use e2 only but let the compiler //chose which one... __asm__ ("madd.u %%e2,%%e2,%1,%2" : "+m" (*c) : "d" (a), "d

passing arguments between c and inline assembly

爷,独闯天下 提交于 2019-12-11 12:19:45
问题 I have a question about passing arguments between c and inline assembly I'm having trouble passing an array into my inline assembly. I keep getting the error 'error: memory input 1 is not directly addressable' Here is an example of my code: void main() { char name[] = "thisisatest"; __asm__ ("\ .intel_syntax noprefix \n\ mov eax, %[name] \n\ inc (eax) \n\ " :/*no output*/ :[name]"m"(name) ); } This should increment the first letter of my string (making it 'u'), but it doesn't build. Ideas?

Manipulating an array in memory via the arm c inline assembler

人盡茶涼 提交于 2019-12-11 10:14:28
问题 int smplSize = 48; int Smpl[48]; for(int i = 0; i < smplSize; i++) Smpl[i] = 0x0; Smpl[smplSize-1] = 0x1; int *ptrToSmpl = &Smpl[0]; printf("Sample @%p of Size %i :\n",(void*)ptrToSmpl,smplSize); asm volatile( "@ ------------------------------------------------- \n" "@ Invert the sample \n" "@ ------------------------------------------------- \n" //"0: \n" "ldr r2,[r3] \n" //"cmp r2,#0x1 \n" //"bne 1f \n" "add r2,#0x1 \n" //"add r2,#0x1 \n" "str r2,[r3] \n" //"ldr r1, .0 \n" //"bx r1 \n" //"1

How to get this sqrt inline assembly working for iOS

与世无争的帅哥 提交于 2019-12-11 09:09:27
问题 I am trying to follow another SO post and implement sqrt14 within my iOS app: double inline __declspec (naked) __fastcall sqrt14(double n) { _asm fld qword ptr [esp+4] _asm fsqrt _asm ret 8 } I have modified this to the following in my code: double inline __declspec (naked) sqrt14(double n) { __asm__("fld qword ptr [esp+4]"); __asm__("fsqrt"); __asm__("ret 8"); } Above, I have removed the "__fastcall" keyword from the method definition since my understanding is that it is for x86 only. The

SPARC Assembly question

旧时模样 提交于 2019-12-11 08:47:22
问题 I wanna write a very simple inline assembly routine in my C program which does nothing else then setting the local registers %l0 - %l7 to different values. I tried the following straightforward approach: asm volatile ( ".text\n\t" "mov 0, %%l0 \n\t" "mov 1, %%l1 \n\t" "mov 2, %%l2 \n\t" "mov 3, %%l3 \n\t" "mov 4, %%l4 \n\t" "mov 5, %%l5 \n\t" "mov 6, %%l6 \n\t" "mov 7, %%l7 \n\t" ); unfortuantely, the assembler tells: illegal operand for each instruction. Could somebody please be so nice to

warning C4799: function has no EMMS instruction

我只是一个虾纸丫 提交于 2019-12-11 08:06:54
问题 I'm trying to create C# app which uses dll library which contains C++ code and inline assembly. In function test_MMX I want to add two arrays of specific length. extern "C" __declspec(dllexport) void __stdcall test_MMX(int *first_array,int *second_array,int length) { __asm { mov ecx,length; mov esi,first_array; shr ecx,1; mov edi,second_array; label: movq mm0,QWORD PTR[esi]; paddd mm0,QWORD PTR[edi]; add edi,8; movq QWORD PTR[esi],mm0; add esi,8; dec ecx; jnz label; } } After run app it's

Using int 21h with inline assembly

99封情书 提交于 2019-12-11 07:36:53
问题 I am using inline assembly in Visual C++ and have been trying for days now to get int 21h to work with my program. Other interrupts work (int 3) which leads me to believe either I'm calling 21h wrong or it is blocked somehow. I only get a runtime error when I use int 21h. If I comment it out it can move registers fine. So far I've gotten this together: int _tmain(int argc, _TCHAR* argv[]) { __asm { mov ah, 1h int 21h mov dl, al mov ah, 2h int 21h } } 回答1: You can't use DOS interrupts in a

ARM assembly - code to replace character on a string

﹥>﹥吖頭↗ 提交于 2019-12-11 06:48:33
问题 I have this C driver program #include <stdlib.h> #include <stdio.h> extern void subs( char *string, char this_c, char that_cr ) ; int main(int argc, char *argv[] ) { char this_c= 'e' ; char that_c = 'X' ; char orgstr[] = "sir sid easily teases sea sick seals" ; subs( orgstr, this_c, that_c ) ; printf( "Changed string: %s\n", orgstr ) ; exit( 0 ) ; } I have to make an arm program that changes the 'e' on the String to 'x', so far this is what I have \ .global subs subs: stmfd sp!, {v1-v6, lr} /

What's the meaning of MOV EAX, DWORD PTR SS:[EBP+8h] and how can I translate it into AT&T format?

亡梦爱人 提交于 2019-12-11 06:26:13
问题 I'm using Code::Blocks to code, but one of the code I referenced is from Visual C++,so I have difficulties on the difference...:( the full code are here NAKED void ijlWrite() { __asm { PUSH EBP MOV EBP, ESP MOV EAX, DWORD PTR SS:[EBP+8h] MOV ECX, ssQuality MOV DWORD PTR DS:[EAX+50h], ECX MOV EDX, DWORD PTR SS:[EBP+0Ch] PUSH EDX MOV EAX, DWORD PTR SS:[EBP+08h] PUSH EAX CALL lpfnIJLWrite //a global variable POP EBP RETN } } I'll be very grateful if you translate them all. P.S. I also don't know