x86

How to print string in OS-neutral way?

I am trying to print a string in a way that's OS-neutral. For example, the program should run the same on Windows as it does on *nix. Is this even possible? I'm assuming that since the underlying architecture is the same (x86) that the method would be the same. Is it as simple as calling an interrupt? The reason for this is I'm trying ...

What does the `cc` option `-ldl` do in the following command?

hi... during compilation of dynlinktest.c it gives following error: unipro@ubuguest:~$ cc dynamiclinktest.c -o dynamiclinktest /tmp/ccli8dp2.o: In function main': dynamiclinktest.c:(.text+0x53): undefined reference todlopen' dynamiclinktest.c:(.text+0x83): undefined reference to dlsym' dynamiclinktest.c:(.text+0x109): undefined referenc...

Global Descriptor Table and Local Descriptor Table

I want to know if the global descriptor table resides in each process memory space or it is shared among all processes. What about LDT? Where is the LDTR stored? Thank you. ...

How to encode an AVI from x64 .Net Application?

I have a .Net application which we compile in both x86 and x64 bit. One feature is the video export to avi, but on the x64 version this doesn't work. The reason, I think, is that it uses the win32 dll called AviFil32.dll to encode the avis, and this doesn't like being called by a x64 process. Originally I thought the problem was a lack ...

How do you view segment-offset memory addresses in the Visual Studio debugger?

I'm debugging some code from the disassembly (no source code is available), and there a number of instructions accessing data via the ds segment register, e.g. something like this: 66 3B 05 8A B1 43 00 cmp ax,word ptr ds:[43B18Ah] How do you get the Visual Studio debugger to tell you the offset of the ds segment register so th...

Can't modify memory using 32bit assembler

Hello. I am using NASM to assemble my assembler code. The code I assembled looks like this: [BITS 32] [ORG 0] jmp 07c0h:start testvar db 0, 0, 0, 0, 0, 0, 4, 8, 15, 16, 23, 42 start: mov byte [testvar], 47 hang: jmp hang times 510-($-$$) db 0 dw 0AA55h I had problems with another piece of code, I noticed that I cou...

How to call C++ function taking UDT object as argument with inline assembler instruction?

Hello, I am facing a problem related Inline assembler in c++ in order calling C++ functions at runtime. Suppose the function to which I need to call is just taking UDT(User defined data type) as object. But my problem is I am not aware of of that user defined type in code. That UDT is not defined there in the caller's code. Suppose I...

How to manipulate strings with x86 assembly?

I'm in the process of writing an assembly program that takes two strings as input and concatenates them. Here's what I have: (using NASM syntax) SECTION .data hello: db "Hello ",0 world: db "world!",0 SECTION .text ; do the concatenation Since I've never done any work with strings in x86 assembly before, I need to know how...

Assembler mov issue

I have the next code: mov ax,@data mov ds,ax Why I can not write just like this? mov ds,@data All source: .MODEL small .STACK 100h .DATA HelloMessage DB 'Hello, world',13,10,'$' .CODE .startup mov ax,@data mov ds,ax mov ah,9 mov dx,OFFSET HelloMessage int 21h mov ah,4ch int 21h E...

Can I test an x64 version of my application on an x86 machine?

Hello. My laptop is running an x86 version of Windows XP. An application we've developed has problems with people running x64 machines. Is there a way to simulate an x64 machine on an x86 machine? Thanks. ...

What instructions should I be using for floating point operations?

I'm somewhat familiar with the x87 instructions for manipulating floating point numbers in x86 assembly. However, I read somewhere that these were seldom used anymore. (And weren't allowed in 64-bit Windows drivers)[1] If that's the case, what instructions should I be using? I saw something about SSE, but unless I'm mistaken, those inst...

Why is this simple program outputting so many characters?

Here is my short assembly program: ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic&gt; extern printf ; Initialized data SECTION .data f_0 dd 5.5 printf_f: db "%f",10,0 SECTION .text ; Code global main main: push ebp mov ebp,esp push dword [f_0] push printf_f call printf add esp,8...

Bit popcount for large buffer, assembly preferred

I'm looking for the fastest way to popcount on large buffer of 512 or more bytes. I can guarantee any required alignment, and the buffer size is always a power of 2. The buffer corresponds to block allocations, so typically the bits are either all set, none set, or mostly set favoring the "left" of the buffer, with occasional holes. Som...

structure of object files

hi, i'm kinda having some issues with linking my assembly. I use NASM for assembly and then I link it with ld. One minor problem is that the GLOBAL directive only works if I define .data section which.. I believe has something reasonable behind it, but still how is that importnant for exporting symbols? (I decided to use coff since that ...

Why is scanf returning 0.000000 when it is supplied with a double?

I have the following assembly code (written for NASM on Linux): ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic&gt; extern printf extern scanf SECTION .data printf_f: db "%f",10,0 scanf_f: db "%f",0 SECTION .bss v_0 resb 8 SECTION .text global main main: push ebp mov ebp,esp ...

What is stack frame in assembly?

What is the structure of a stack frame and how is it used while calling functions in assembly? ...

Addressing data using relative pointers (x86-32 assembler)

Hello. I'm writing in 32-bit x86 assembler, and I'm not quite sure how to address data that is always in the same relation to the code. Do I have to use EIP to calculate the absolute address, or is there a better way? ...

How to return a complex return value?

Hi awesomes~ Currently I am writing some assembly language procedures. As some convention says, when I want to return some value to the caller, say an integer, I should return it in the EAX register. Now I am wondering what if I want to return a float, a double, an enum, or even a complex struct. How to return these type of values? I c...

add vs mul (IA32-Assembly)

I know that add is faster as compared to mul function. I want to know how to go about using add instead of mul in the following code in order to make it more efficient. Sample code: mov eax, [ebp + 8] #eax = x1 mov ecx, [ebp + 12] #ecx = x2 mov edx, [ebp + 16] #e...

Anyone knows what "mov edi,edi " does?

69A8AB13 int 3 69A8AB14 int 3 69A8AB15 mov edi,edi 69A8AB17 push ebp 69A8AB18 mov ebp,esp mov edi,edi doesn't make sense for me,what's it for? ...