x86

why .net assemblies differ for different architectures?

I can build my C# project for x86 and for x64. Why? I thought it generates a special code which is not platform specific at all. ...

Assembler Stack Alignment (or better misaligned example with PUSH)

Hello!, Well first I understand (or a I think that I understand) the problems of misaligned stack. But I know (like a definition) that pushing a 16bit value to 32bit wide stack could cause a stack misaligned. But the thing I dont understand, is how this could happend...since PUSH and POP check the D flag at the segment descriptor (so ...

Assembler: Using "Flat assembler" how do I produce EXE files (compile, link..)?

I'm using FASM to compile a small piece of code: mov ah,4ch mov al,00 int 21h I click Run -> Compile, and what I get is a .BIN file. sorry for the noobish question but why don't I get an OBJ, or an EXE file, and what is this BIN? ...

Storing data below the stack pointer?

Looking at the disassembly (along with an instruction trace) of ld.so installed in Ubuntu 9.04, I swear I'm seeing data being stored below the stack pointer (i.e., beyond the top of the stack) at times. This seems insane to me, but maybe this is more common than I think. Does this happen often? Here's what I see: ebp: 0xBF8269E8, esp: ...

How do I pass arguments to C++ functions when I call them from inline assembly.

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...

Why do segments begin on paragraph boundaries?

In real mode segmented memory model, a segment always begins on a paragraph boundary. A paragraph is 16 bytes in size so the segment address is always divisible by 16. What is the reason/benefit of having segments on paragraph boundaries? ...

Is it possible to vectorize myNum += a[b[i]] * c[i]; on x86_64?

What intrinsics would I use to vectorize the following(if it's even possible to vectorize) on the x86_64? double myNum = 0; for(int i=0;i<n;i++){ myNum += a[b[i]] * c[i]; //b[i] = int, a[b[i]] = double, c[i] = double } ...

Assembly - 32 bit vs 64 bit...?

Hey guys... I'm really wanting to learn assembly. I'm pretty good at c/c++, but want a better understanding of what's going on at a lower level. I realize that asembly related questions have been asked before, but I'm just looking for some direction that's particular to my situation: I'm running windows 7, and am confused about how I ...

Do x86/x64 chips still use microprogramming?

If I understand these two articles, the Intel architecture, at it's lowest level, has transitioned to using RISC instructions, instead of the the traditional CISC instruction set that Intel is known for: http://www.hardwaresecrets.com/article/235/4 http://www.tomshardware.com/reviews/intel,264-6.html If that's the case, then are x86/x64...

difference in jump statements in assembly programming

how do you decide when do you use which jump statement...statements such as JG JNLE JNC can do the same job how do u diffrentiate them? ...

Assembler : why BCD exists?

Hello, I know BCD is like more intuitive datatype if you dont know binary. But I dont know why to use this encoding, its like dont makes a lot os sense since its waste representacion in 4bits (when representacion is bigger than 9). Also I think x86 anly supports adds and subs directly (you can convert them via FPU). Its possible that t...

Generating Assembly For an x86 Processor

I'm currently working my way through Andrew Appel's Modern Compiler Implementation in Java, and I'm right around the point where I build the low-level intermediate representation. Initially, I had decided to target the JVM and ignore all of the low-level machine stuff, but in the interest of learning things that I don't know much about ...

Is ARM a more secure instruction set?

I have read that 'Normal' ARM instructions are fixed length - 32 bits. And that no ARM instruction can jump into the middle of another instruction - something that is easy to do with x86 instructions. (For x86, Google's NaCl tries to 'fix' this by aligning instructions on 32 byte boundaries.) Does this make ARM programs more secure or ...

How do I store the value of a register into a memory location pointed to by a pointer ?

I have the following code: void * storage = malloc( 4 ); __asm { //assume the interger 1 is stored in eax mov eax, storage //I've tried *storage as well but apparently it's illegal syntax } /* other code here */ free(storage); However, in the code, when I dereference the storage pointer ( as in *(int *)storage ), I do not ge...

How to compile application for wince 5.0 x86 using VS

Hello, i was looking for a way of compiling application for wince 5.0 x86 using VS. I found a thread http://stackoverflow.com/questions/1313001/intel-c-compiler-for-windows-ce where you mentioned ... "For Windows CE based on x86 architecture probably yes.... we just need to use general windows compiler." I was wondering if you could p...

How is thread synchronization implemented, at the assembly language level?

While I'm familiar with concurrent programming concepts such as mutexes and semaphores, I have never understood how they are implemented at the assembly language level. I imagine there being a set of memory "flags" saying: lock A is held by thread 1 lock B is held by thread 3 lock C is not held by any thread etc But how is access to...

What does this assembly code mean?

Recently, i am looking into some assembly codes generated by GCC. But I dont understand some of them: movl $0x2d, 0x4(%esp) In the second operand, what does 0x4 stands for? offset address? And what the use of register EAX? ...

Help understanding part of this generated assembly code

Can anyone explain to me the assembly generated by GCC of the following C++ codes? espeically, the meaning of setg and test in the codes. thx! .cpp codes: 1 /*for loop*/ 2 int main() 3 { 4 int floop_id; 5 for(floop_id=100;floop_id>=1;floop_id--) 6 {} 7 return 0; 8 } assembly codes: 3 p...

Delphi label and asm weirdness?

I written an asm function in Delphi 7 but it transforms my code to something else: function f(x: Cardinal): Cardinal; register; label err; asm not eax mov edx,eax shr edx, 1 and eax, edx bsf ecx, eax jz err mov eax, 1 shl eax, cl mov edx, eax add edx, edx or eax, edx ret err: xor eax, eax end; // compiled ...

MOV src dest (or) MOV dest src?

MOV is probably the first instruction everyone learns while learning ASM. Just now I encountered a book Assembly Language Programming in GNU/Linux for IA32 Architectures By Rajat Moona which says: But I learnt that it is MOV dest, src. Its like "Load dest with src". Even Wiki says the same. I'm not saying that the author is wrong. I...