assembly

Mips, how to read array and print them??

okay, C++ and java i have no problem learning or what so ever when it comes to mips it is like hell okay i wanna learn how to read in the an array and print all the element out here is a simple array that i wrote int[] a = new int[20]; for(int i=0; i<a.length; i++){ a[i]=1; } for(int j=0; j<a.length; j++){ System.out.Println(a[i...

Stack usage with MMX intrinsics and Microsoft C++

I have an inline assembler loop that cumulatively adds elements from an int32 data array with MMX instructions. In particular, it uses the fact that the MMX registers can accommodate 16 int32s to calculate 16 different cumulative sums in parallel. I would now like to convert this piece of code to MMX intrinsics but I am afraid that I wi...

x86 gcc assembly output help please

Pasted below is unoptimized GCC assembly output for "int main(){}". I'm relatively good with x86 assembly, but some of this is unfamiliar. Could someone please do a line-by-line walk-through of what's going on here? Thanks! .text .globl _main _main: LFB2: pushq %rbp LCFI0: movq %rsp, %rbp LCFI1: leave ret LFE...

How do you find a functions virtual call address in assembly?

I've googled around but i'm not sure i am asking the right question or not and i couldn't find much regardless, perhaps a link would be helpful. I made a c++ program that shows a message box, then I opened it up with Ollydbg and went to the part where it calls MessageBoxW. The call address of MessageBoxW changes each time i run the ap...

Sign Flag and Overflow Flag are not functioning according to expectation

Suppose AX=8FFE and BX= 0FFF Now if we write Cmp ax,bx Now at this point what will happen is, source (bx) will be subtracted from destination (ax) and the appropriate flags will be updated. As computer represent each number in 2’s complement form so 8FFE is a 2’s complement of some number similarly 0FFF is 2’s complement of some numb...

x86 architecture

I'm studying x86 and Real Time Systems, and I have a question, that is: Which steps x86 follows to handle any interrupt ? ...

the carry flag issue!

Suppose AX =FFFE and BX=1234 now if we write cmp ax,bx (bx will be subtracted from ax and the approprite flages will be updated) now the binary representation of the numbers in ax and bx is given by AX = 1111 1111 1111 1110 BX= 0001 0010 0011 0100 As bx will be subtracted from ax so we have to negate b...

Explanation of the disassembly of the simplest program (x86)

The following code int _main() {return 0;} Compiled using the command: gcc -s -nostdlib -nostartfiles 01-simple.c -o01-simple.exe gcc version 4.4.1 (TDM-1 mingw32) OllyDbg produced this output: Can you explain what happens here? Analysis so far: // these two seems to be an idiom: PUSH EBP // places EBP on stack MOV EBP...

Do you have suggestions for these assembly mnemonics?

Greetings! Last semester in college, my teacher in the Computer Languages class taught us the esoteric language named Whitespace. In the interest of learning the language better with a very busy schedule (midterms), I wrote an interpreter and assembler in Python. An assembly language was designed to facilitate writing programs easily, an...

Programatically detect number of physical processors/cores or if hyper-threading is active on Windows, Mac and Linux

I have a multithreaded c++ application that runs on Windows, Mac and a few Linux flavours. To make a long story short: Inorder for it to run at maximum efficiency I have to be able to instantiate a single thread per physical processor/core. Creating more threads than there are physical processors/cores degrades the performance of my prog...

Check if address exists before use/jump in assembly?

Say i have loaded some random address like 0x00001234 into eax. Is there a way to test that this address is valid/exists before jumping to it or dereferencing it? Or do I have to implement an exception handler? ...

C/C++/Assembly Programatically detect if hyper-threading is active on Windows, Mac and Linux

I can already correctly detect the number of logical processors correctly on all three of these platforms. To be able to detect the number of physical processors/cores correctly I'll have to detect if hyperthreading is supported AND active (or enabled if you prefer) and if so divide the number of logical processors by 2 to determine the...

Pros and cons with a ready-queue for diffrent semaphores in a mini OS.

In a OS we originally have a ready-queue for the threads, note only one queue. Why would it be better to have different queues for each semaphore. Pros and cons can be about efficiency, complexity or something else. ...

weird performance in C++ (VC 2010)

Hello, I have this loop written in C++, that compiled with MSVC2010 takes a long time to run. (300ms) for (int i=0; i<h; i++) { for (int j=0; j<w; j++) { if (buf[i*w+j] > 0) { const int sy = max(0, i - hr); const int ey = min(h, i + hr + 1); const int sx = max(0, j - hr); c...

"cpuid" before "rdtsc"

Sometimes I encounter code that reads TSC with rdtsc instruction, but calls cpuid right before. Why is calling cpuid necessary? I realize it may have something to do with different cores having TSC values, but what exactly happens when you call those two instructions in sequence? ...

Calling a non-exported function in a DLL

I have a program which loads DLLs and I need to call one of the non-exported functions it contains. Is there any way I can do this, via searching in a debugger or otherwise? Before anyone asks, yes I have the prototypes and stuff for the functions. ...

Sparc Assembly Call corrupts data

I am at the moment working with some assembler code for the Sparc processor family, and i am having some truble with a piece of code.. I think the code and output explains more, but in the short.. When i do a call to the function println my varaibels that i have written to the %fp - 8 memory location is destoryed.. here is my assembler...

ARMv6 FIQ, acknowledge interrupt

I'm working with an i.mx35 armv6 core processor. I have Interrupt 62 configured as a FIQ with my handler installed and being called. My handler at the moment just toggles an output pin so I can test latency with a scope. With the code below, once I trigger the FIQ it continues forever as fast as it can, apparently not being acknowledg...

Need some constructive criticism on my SSE/Assembly attempt

Hello, I'm working on converting a bit of code to SSE, and while I have the correct output it turns out to be slower than standard c++ code. The bit of code that I need to do this for is: float ox = p2x - (px * c - py * s)*m; float oy = p2y - (px * s - py * c)*m; What I've got for SSE code is: void assemblycalc(vector4 &p, vector4 &...

C2244 when trying to call the pow function from inline assembly

I would like to call the pow function from inline assembly. The problem is i'm getting error C2244: 'pow' : unable to match function definition to an existing declaration. I'm new to assembly so this may be a trivial question but how do i resolve this? I guess it has something to do with the compiler not beeing able to properly resolve t...