Hi,
I have question about inline assembler. It's possible to call another assembler subroutine from inline assembler within the same function? For example:
void FindValidPID(unsigned int &Pid)
{
__asm
{
sub esp, 20h
mov eax, Pid
add eax,eax
call sub123 ; another assm subroutine
mov Pid, ...
i have some code(inline assembly).
void NativeLoop()
{
int m;
__asm
{
PUSH ECX
PUSH EDX
MOV ECX, 100000000
NEXTLOOP:
MOV EDX, ECX
AND EDX, 0X7FFFFFFF
MOV DWORD PTR m, EDX
DEC ECX
JNZ NEXTLOOP
POP EDX
POP ECX
}
}
MS C++ Automagical...
char* ReadNumericFormat = "%i";
int Read(void)
{
int Storage;
__asm
{
LEA EAX, [Storage]
PUSH EAX
PUSH DWORD PTR [ReadNumericFormat]
CALL DWORD PTR [scanf]
ADD ESP, 8
MOV EAX, DWORD PTR [Storage]
}
}
when the user enters "023919" the procedure returns 1...
Essentially, I'd like to be able to do something like this:
//assume myFunction is defined and takes one argument that is an int
char * functionName = "myFunction";
int arg = 5;
__asm{
push a
call functionName
}
Basically I want to call a function whose name is stored in a string. What would be the proper syntax for doing thi...
If I have the following C++ code to compare two 128-bit unsigned integers, with inline amd-64 asm:
struct uint128_t {
uint64_t lo, hi;
};
inline bool operator< (const uint128_t &a, const uint128_t &b)
{
uint64_t temp;
bool result;
__asm__(
"cmpq %3, %2;"
"sbbq %4, %1;"
"setc %0;"
: // outp...
So, I would like to be able to call functions from a c++ dll.
For certain reasons, I would like to call them from an __asm block in my C++ code.
My question is this: I know that before I call the function, I have to push its arguments on the stack in the order specified by the function's calling convention.However, can i simply do someth...
Once again, I play with MinGW inline assembly.
#include <stdio.h>
int foobar(int);
int main(){
int n = 0;
printf("Number: ");
scanf("%d", &n);
printf("\n%d",foobar(n));
return 0;
}
int foobar(int num){
int result = 0;
asm(".intel_syntax noprefix\n");
asm("mov eax, num\n");
asm("add eax, 110b\n");
asm("sub eax, 2\n");
as...
Hello everyone. While trying to compile my project, that uses some third party headers, with mingw 4.4, I encountered the following error:
Assembler messages:
Error: junk at end of line, first unrecognized character is '"'
Error: unknown pseudo-op: '.previous'
I found this code at the end of one of the included headers:
__asm_...
Hi, I always thought that functions like printf() are in the last step defined using inline assembly. That deep into stdio.h is burried some asm code that actually tells CPU what to do. Something like in dos, first mov bagining of the string to some memory location or register and than call some int. But since x64 version of Visual Studi...
#include <stdlib.h>
static inline uint
xchg(volatile unsigned int *addr, unsigned int newval)
{
uint result;
asm volatile("lock; xchgl %0, %1" : "+m" (*addr), "=a" (result) : "1" (newval) : "cc");
return result;
}
Can some one tell me what this code does exactly? I mean I have an idea or the parts of this command. "1" newva...
I have a piece of C++ code (compiled with g++ under a GNU/Linux environment) that load a function pointer (how it does that doesn't matter), pushes some arguments onto the stack with some inline assembly and then calls that function, the code is like :
unsigned long stack[] = { 1, 23, 33, 43 };
/* save all the registers and the stack p...
I'm doing some experimenting and would like to be able to see what is saved on the stack during a system call (the saved state of the user land process). According to http://lxr.linux.no/#linux+v2.6.30.1/arch/x86/kernel/entry_32.S it shows that the various values of registers are saved at those particular offsets to the stack pointer. He...
Hi, i've had a go at converting this little bit of C code to ARM vfp assembler
can anyone see any problems with it or possible improvements
for(int j=0;j<count; j++)
{
output += array[j]*(*p++);
}
to this VFM assembly:
for(int j=0;j<count;j++){
asm volatile(
VFP_VECTOR_LENGTH(8)
...
When I code, I always write little pieces of unit, and compile it often. This helps me to make sure that everything run correctly, but it's very time consumed. is there any programming language that can support us to do coding and running at the same time side by side ? i mean as soon as a key press leads to valid code, the effect of the...
I am trying to build an old 16 bit DOS like OS.
My example kernel code:
asm(".code16\n");
void putchar(char);
int main()
{
putchar('A');
return 0;
}
void putchar(char val)
{
asm("movb %0, %%al\n"
"movb $0x0E, %%ah\n"
"int $0x10\n"
:
:"r"(val)
...
I want to convert the for loop in the following code into assembly but i am not sure how to start. An explanation of how to do it and why it works would be appreciated.
I am using VS2010, C++, writing for the x86. The code is as follows:
for (n = 0; norm2 < 4.0 && n < N; ++n)
{
__asm{
///a*a - b*b + x
fld a // a
...
Let's say we use NASM as they do in this answer: how to write hellow world in assembly under windows.
I got a couple of thoughts and questions regarding assembly combined with c# or any other .net languages for that matter.
First of all I want to be able to create a library that has the following function HelloWorld that takes this par...
It used to be the case that if you needed to make a system call directly in linux without the use of an existing library, you could just include <linux/unistd.h> and it would define a macro similar to this:
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
long __res; \
__a...
Hi all,
This is the first time I am posting a question on stackoverflow, so please try and overlook any errors I may have made in formatting my question/code. But please do point the same out to me so I may be more careful.
I was trying to write some simple intrinsics routines for the addition of two 128-bit (containing 4 float variabl...
Would somebody please tell me whats wrong with this code
I am just calling a Sleep function from the kernel32.dll
What's wrong?
I am using Visual Studio 2008.
Any help would be grateful.
Thank you very much.
__asm
{
mov eax, 77e2ef66h
push 9999
call eax
}
...