x86

How to power down the computer from a freestanding environment?

I'm making a protected-mode OS based on Intel's x86 architecture, and was looking for some information on how to power off the computer via assembly code, or something like that. Could you help me with this problem? ...

Difference in position-independent code: x86 vs x86-64

I was recently building a certain shared library (ELF) targeting x86-64 architecture, like this: g++ -o binary.so -shared --no-undefined ... -lfoo -lbar This failed with the following error: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC Of course, it means I nee...

File Compressor In Assembly

In an effort to get better at programming assembly, and as an academic exercise, I would like to write a non-trivial program in x86 assembly. Since file compression has always been kind of an interest to me, I would like to write something like the zip utility in assembly. I'm not exactly out of my element here, having written a simple...

x86-64 and far calls / jumps

Quick summary: in x86-64 mode, are far jumps as slow as in x86-32 mode? On the x86 processor, jumps fall into three types: short, with a PC-offset of +/-127 bytes (2 byte instruction) near, with a +/- 32k offset that "rolls around" the current segment (3 byte instruction) far, which can jump anywhere (5 byte instruction) short and n...

x86 memory and I/O map

Hi, the semester is over so I sank a bit into assembly again. I have read some articles and parts of x86 family user's manual concerning the memory map and I/Os and I still haven't figured out how does it work.. As I understand it now, I can access the I/Os with IN and OUT instructions, in that case is it like the port number I use as a...

Resources for x86 decompilation

I'd like to get a solid understanding of the low level process for representing and running a program. I've decided to do this by writing a program to parse and display object file information (headers, sections, etc.). I've nearly finished this part. A natural extension is to decompile the remaining relevant data into assembly instructi...

What are IN & OUT instructions in x86 used for?

I've encoutered these to instructions IN & OUT while reading "Understanding Linux Kernel" book. I've looked up reference manual. 5.1.9 I/O Instructions These instructions move data between the processor’s I/O ports and a register or memory. IN Read from a port OUT Write to a port INS/INSB Input string from port/Inpu...

Learning about the x86 Instruction Set

What are good resources for learning about the x86 instruction set? I'm a total beginner, and have no real understanding of registers, interrupts, address modes etc, so perhaps a generic book on ISAs would be better first. I really have no clue, to be honest. My ultimate goal is to be fluent in x86 assembly. ...

Need little more clarification on address lines of processor

Yesterday, while I was pondering over Why can’t OS use entire 64-bits for addressing? I found another interesting thing. Lets take Intel Core 2 Duo Processor for example. From "4.2 Alphabetical Signals Reference" of Intel Core 2 Duo Processor E8000 and E7000 Series - Datasheet I came to know that it has 36 address lines & 64 data lines....

What does MOV EAX, DWORD PTR DS:[ESI] mean and what does it do?

Alright so I have this line in my assembly MOV EAX, DWORD PTR DS:[ESI] where ESI is 00402050 (ascii, "123456789012") After this instruction: EAX = 34333231 What really happened here? How is this value calculated, and why? Where could I get some good reference on this kind of thing? ...

In Intel x86 assembly, what does 00+ mean?

In the Intel documentiation manuals, I see references to 00+ multiple places, but no definition. What is this 00+ instruction/opcode? ...

What's the point of cache coherency?

On CPUs like x86, which provide cache coherency, how is this useful from a practical perspective? I understand that the idea is to make memory updates done on one core immediately visible on all other cores. This is a useful property. However, one can't rely too heavily on it if not writing in assembly language, because the compiler c...

How to measure x86 and x86-64 assembly commands execution time in processor cycles?

I want to write a bunch of optimizations for gcc using genetic algorithms. I need to measure execution time of an assembly functions for some stats and fit functions. The usual time measurement can't be used, 'cause it is influenced by the cache size. So I need a table where I can see something like this. command | operands | operands s...

One instruction to clear PF (Parity Flag) -- get odd number of bits in result register

In X86 assembly, is it possible to clear the Parity Flag in one and only one instruction, working under ANY initial register configuration? This is equivalent to creating a result register with an ODD number of bits, with any operation that sets flags (expressly excluding "mov"). For contrast, setting the parity flag can be done in o...

Clearing bits in a register in assembly

How to write an instruction that clears bits 0 and 1 in the AL register using assembly? ...

OS's Boot-loader doesn't work

I am making a custom Operating System. I have two nasm files: boot.asm: [BITS 16] ;tell the assembler that its a 16 bit code [ORG 0x7C00] ;Origin, tell the assembler that where the code will ;be in memory after it is been loaded INT 0x13 JMP $ ;infinite loop TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0 DW 0...

Documentation about inline gas

Hi When reading the linux 0.01 kernel I pass throw some inline gas which is hard for me to decode: __asm__("movl $0x3ff000,%%eax\n\t" "movl %%eax,%%db0\n\t" "movl $0x000d0303,%%eax\n\t" "movl %%eax,%%db7" :::"ax") or __asm__("push %%fs;mov %%ax,%%fs;movl %%fs:%2,%%eax;pop %%fs" \ ...

Compile/run assembler in linux?

I'm fairly new to linux(ubuntu 10.04) and a total novice to assembler. I was following some tutorials and I couldn't find anything specific to linux. So, my question is, what is a good package to compile/run assembler and what are the command line commands to compile/run for that package? ...

assembly on X86 machines, Windows vs Linux

Are they the same? Longer version : Say I wrote, in assembly, on a windows machine, a small app that all it does is add 1+1 and stores it in a register. THEN, I write the exact same code on a Linux machine. Would it work? Im thinking yes, because at the hardware level, its the same machine, so the 'language of the hardware' (forgive t...

Assembler: Relative Jump

Can someone explain in English what a relative jump is in assembler? ...