assembly

What are the limitations of assembler? (NASM)

Is there a technical limitation of what kind of programs I can write with assembler (NASM)? For now I've only seem some program that do arithmetic operations, like adding two numbers. Is it possible to write complex assembler programs, that provide a GUI, access the file system, plays sounds et cetera? I know I wouldn't write such pr...

Interrupt On GAS

I'm trying to convert my simple program from Intel syntax to the AT&T(to compile it with GAS). I've successfully converted a big part of my application, but I'm still getting an error with the int(the interrupts). My function is like this: printf: mov $0x0e, %ah mov $0x07, %bl nextchar: lodsb or %al, %al ...

NASM: Count how many bits in a 32 Bit number are set to 1.

I have a 32 Bit number and want to count know how many bits are 1. I'm thinking of this pseudocode: mov eax, [number] while(eax != 0) { div eax, 2 if(edx == 1) { ecx++; } shr eax, 1 } Is there a more efficient way? I'm using NASM on a x86 processor. (I'm just beginning with assembler, so please do not tell me to use ...

Blur filter in assembler

I am trying to get it working but still no results. Do you know some kind of tutorial or sample assembler code for blur image filtering? ...

Saving integers as Strings in MIPS

Hello , i was just wondering, is there any way in MIPS to store a summation of numbers as a string and later read them byte by byte, for example: the sum 657 -> sw into a .ascii directive -> later lb on the first index to get 6 (in ascii code) same with 5 and so on Is this possible ? //Thx in advance ...

Accessing array in MASM

Hi guys, let's assume I've got the address of my array (passed as a pointer to the function) in esi register. How can I access a particular cell of the array? i.e: my_array[a + b * c] where c is constant. Thank you for the fast reply! Cheers ...

Clang doesn't support the Lock Prefix. How shall I workaround?

Assume this code: static inline void inc(int64_t* atomic) { __asm__ __volatile__ ( "lock incq %0\n" : "=m" (*atomic) : "m" (*atomic) ); } The Clang compiler doesn't support the lock prefix (yet?). What shall I do now? ...

Help with optimizing C# function via C and/or Assembly

I have this C# method which I'm trying to optimize: // assume arrays are same dimensions private void DoSomething(int[] bigArray1, int[] bigArray2) { int data1; byte A1, B1, C1, D1; int data2; byte A2, B2, C2, D2; for (int i = 0; i < bigArray1.Length; i++) { data1 = bigArray1[i]; data2 = bigArray2...

Assembler: jmpf, testb and else instructions.

Hello. Help me please, i don't understand this code: ... BUFFER = 0x0600 ... rep movs jmpf BUFFER+migrate, 0 ;??? migrate: findactive: testb dl,dl ; ??? jns nextdisk ...

Is it possible to include inline assembly in Google Go code?

Is it possible to include inline assembly in Google Go code? ...

ARM Simulator on Windows

I am studying ARM Processors from a textbook... I thought it will be more useful if I could apply what I learn on an ARM simulator... writing code then watching results and different execution stages would be more fun... I have searched for it, but all I could find was either a freeware on linux or a demo on windows Is there a simulat...

how to make struct member pointer in assembly?

I`m trying to create a macro which would make easier to point to a structs member. Currently i am pointing to a structs member in assembly file using the STRUCT_NAME + offset method. For example if i want to point structs third member,i would have to do it like this: STRUCT_NAME + 3. This seems stupid way to do it, and if i insert mor...

ARM assembly puzzle

First of all, I'm not sure if solution even exists. I spent more than a couple of hours trying to come up with one, so beware. The problem: r1 contains an arbitrary integer, flags are not set according to its value. Set r0 to 1 if r1 is 0x80000000, to 0 otherwise, using only two instructions. It's easy to do that in 3 instructions (th...

Concise SSE and MMX instruction reference with latencies and throughput

I am trying to optimize some arithmetic by using the MMX and SSE instruction sets with inline assembly. However, I have been unable to find good references for the timings and usages of these enhanced instruction sets. Could you please help me find references that contain information about the throughput, latency, operands, and perhaps s...

Inline assembler get address of pointer Visual Studio

I have a function in VS where I pass a pointer to the function. I then want to store the pointer in a register to further manipulate. How do you do that? I have tried float __declspec(align(16)) x[16] = { 0.125000, 0.125000, 0.125000, 0, -0.125000, 0.125000, -0.125000, 0, 0.125000, -0.125000, -0.125000, 0, -0.125000, -...

Where to get all versions of x86 aka IA32 Instruction Set Architecture manuals

Hello, I know about Intel 64 and IA-32 Architectures Software Developer's Manuals. I also know that these cover all the legacy & old processor ISAs. But I want the individual manual (the one that released along with the processor) for each of the processors. I managed to find the 80386 manual EDIT: I'm starting bounty. ...

Exceptions & Interrupts

When I was searching for a distinction between Exceptions and Interrupts, I found this question Interrupts and exceptions on SO... Some answers there were not suitable (at least for assembly level): "Exception are software-version of an interrupt" But there exist software interrupts!! "Interrupts are asynchronous but exceptions are s...

Tracing/profiling instructions

I'd like to statistically profile my C code at the instruction level. I need to know how many additions, multiplications, divisions, etc I'm performing. This is not your usual run of the mill code profiling requirement. I'm an algorithm developer and I want to estimate the cost of converting my code to hardware implementations. For this...

FASM vc MASM trasnlation problem in mov si, offset msg

hi folks, just did my first test with MASM and FASM with the same code (almos) and I falled in trouble. The only difference is that to produce just the 104 bytes I need to write to MBR in FASM I put org 7c00h and in MASM 0h. The problem is on the mov si, offset msg that in the first case transletes it to 44 7C (7c44h) and with masm ...

why it is up to the compiler to decide what value to assign when assigning an out-of-range value to a variable

in C++ Primer 4th edition 2.1.1, it says "when assigning an out-of-range value to a signed type, it is up to the compiler to decide what value to assign". I can't understand it. I mean, if you have code like "char 5 = 299", certainly the compiler will generate asm code like "mov BYTE PTR _sc$[ebp], 43"(VC) or "movb $43, -2(%ebp)"(gc...