Let's say we have the following c++ code:
int var1;
__asm {
mov var1, 2;
}
Now, what I'd like to know is if I didn't want to define var1 outside the __asm directive, what would I have to do to put it inside it. Is it even possible?
Thanks
...
I can't search for | in Google. If you had found it in a software source code that you are trying to interpret, you didn't know what it does and you couldn't ask other people for help, how would you find out what it does?
...
I'm wanting to read hex numbers from a text file into an unsigned integer so that I can execute Machine instructions. It's just a simulation type thing that looks inside the text file and according to the values and its corresponding instruction outputs the new values in the registers.
For example, the instructions would be:
1RXY -> ...
Many CPUs have single assembly opcodes for returning the high order bits of a 32 bit integer multiplication. Normally multiplying two 32 bit integers produces a 64 bit result, but this is truncated to the low 32 bits if you store it in a 32 bit integer.
For example, on PowerPC, the mulhw opcode returns the high 32 bits of the 64 bit res...
Thanks to the respondents on this question (http://stackoverflow.com/questions/1396949/this-loop-is-very-slow-i-think-because-i-create-a-lot-of-intermediate-strings-h) I was able to speed up my code many orders of magnitude.
I think I can probably do a bit better though. Is it possible to avoid the creation of a bunch of NSString's here...
//obj C version, with some - less than one second on 18,000 iterations
for (NSString* coordStr in splitPoints) {
char *buf = [coordStr UTF8String];
sscanf(buf, "%f,%f,", &routePoints[i].latitude, &routePoints[i].longitude);
i++;
}
//C version - over 13 seconds on 18,000 iterations
for (i = 0; buf != NULL; buf = strchr(buf,'[...
Say I have a command line C program which is currently executing, and I want to read a file or execute another binary in the same directory - how can I find out what directory that is?
Note that I'm not looking for the current working directory. The user may have invoked my original program in any of the following ways (and possibly oth...
Hi guys, I have a variable declared like this in a class:
Entity *array[BOARD_SIZE][BOARD_SIZE];
I need to set up either a @property that allows me to access (read) the array elements, or a function that returns a reference so I can access the array elements.
- ( ??? ) getEntityArray
{
return ???;
}
or
@property (????) Entity ...
Why does this fail, once Masm reaches jmp?
struct gdt_entry
{
unsigned short limit_low;
unsigned short base_low;
unsigned char base_middle;
unsigned char access;
unsigned char granularity;
unsigned char base_high;
};
struct gdt_ptr
{
unsigned short limit;
unsigned int base;
};
struct gdt_entry gdt[3];
s...
I have some code in a couple of different functions that looks something like this:
void someFunction (int *data) {
data = (int *) malloc (sizeof (data));
}
void useData (int *data) {
printf ("%p", data);
}
int main () {
int *data = NULL;
someFunction (data);
useData (data);
return 0;
}
someFunction () and useData () ...
I have a funny problem using this function.
I use it as follow:
int nSeq = 1;
char cBuf[8];
int j = sprintf_s(cBuf, sizeof(cBuf), "%08d", nSeq);
And every time I get an exception. The exception is buffer to small.
When I changed the second field in the function to sizeof(cBuf) + 1.
Why do I need to add one if I only want to copy 8 by...
Just calculating sum of two arrays with slight modification in code
int main()
{
int a[10000]={0}; //initialize something
int b[10000]={0}; //initialize something
int sumA=0, sumB=0;
for(int i=0; i<10000; i++)
{
sumA += a[i];
sumB += b[i];
}
printf("%d %d",sumA,sumB);
}
OR
int main()
{
...
Ok guys, just a quick question hopefully someone can find my mistake quickly, but I just can't see it at the moment
Here is my struct:
typedef struct {
Car *buffer[CAR_PARK_SIZE];
char *arrival_time[CAR_PARK_SIZE];
int keep_running;
int size;
} CarPark;
typedef struct {
Car *buffer...
I sometimes see keywords starting with two underscores and other times just one. Is there any difference?
...
Hi, does anyone have any pointers to (rough) estimates on how much effort is needed to port an application from C to Java? Of course it will depend a lot, but
would for instance using Intermediate COCOMO make sense?
Estimating how much effort is needed for writing new code is difficult, but still needs to be done. When starting from no...
I have a program for a C class I need to write. The program asks for a quantity, and I need to multiply that quantity by another variable which the user inputs. Basic calculator script for a c class :)
I have it set up like this,
int qty; //basic quantity var
float euro, euro_result;
//assign values to my float vars
euro = .6896; ...
Hello,
I am writing to binary file using fstream and when open the file using binary flag.
I needed to write some text as binary, which a simple write did the trick.
The problem is that I need also to write (as shown in hexadecimal) 0. The value when opened in binary notepad is shown zero, but when tried to write this the value not zer...
I need to profile my JAVA SRC code for some particular problem I am currently working on. I've been using the trial version of a tool called JProfiler.
I'd like to learn of some good community open-source tools, if available; other than that I am also looking forward to learn of some standard techniques that are widely adopted (or must ...
Why would one use realloc() function to resize an dynamically allocated array rather than using free() function before calling the malloc() function again (i.e. pros and cons, advantages vs. disadvantages, etc.)? It's for C programming, but I can't find the proper tag for it. Thanks in advance.
...
I have been programming an FTP server in my free time. But I have a problem with sending listings of a directory.
I use the Unix format, also used by ls
drwxr-xr-x 28 kasper kasper 4096 2009-08-14 01:32 Music
drwxr-xr-x 4 kasper kasper 4096 2009-09-06 13:52 Pictures
drwxr-xr-x 14 kasper kasper 4096 2009-09-09 18:49 Source
drwxr-xr-x 2...