assembly

x86 Assembly: INC and DEC instruction and overflow flag

In x86 assembly, the overflow flag is set when an add or sub operation on a signed integer overflows, and the carry flag is set when an operation on an unsigned integer overflows. However, when it comes to the inc and dec instructions, the situation seems to be somewhat different. According to this website, the inc instruction does not...

Nasm, bootloader switching foreground and background colors.

Hey some im writing a bootloader using nasm a virtual machine ect. Anyhow, im using vram to display background and font color changes triggered by keys s, d, f, g. S switches the color of the font with the background color. I know how this can be done but i do not know the proper way. vram is setup as so 2 bytes the first is the charact...

divide 64bit in two 32bit registers by 32bit

I am trying to write an x86 emulator in JavaScript for education purposes. I have already written a compiler and at the moment I am trying to write the x86 emulator in JavaScript. I have however a problem with the DIV instruction. According to http://siyobik.info/index.php?module=x86&id=72 DIV takes a 64bit number as input by interp...

Immediate call/jmp in Visual C inline assembler

When I try to make an immediate call or jump in VC++ 2010 inline assembler _asm { call 00405B90h; jmp 00405B90h; jmp far 00405B90h; } it generates an error C2415: improper operand type Is it possbile and how to do this? So far I have a work around: _asm { push 00405B90h; // This is a jump work around call 0...

Why is pointer access slower than vector::iterator access? (compiler code generation)

OK, the question title is a bit crappy, but I didn't really know how to phrase this better. The problem I have is that given a std::vector<T> vs. a T* + size_t count my compiler (Visual Studio 2005 / VC++ 8) will actually generate worse code when looping over the pointer than when looping over the vector. That is, I have a test struct ...

Where does the frame pointer point after set up?

Despite looking at textbooks trying to grasp this, I'm having trouble. 0x08048b29 <func+0>: push %ebp 0x08048b2a <func+1>: mov %esp,%ebp 0x08048b2c <func+3>: push %ebx ... 0x08048b30 <phase_2+7>: lea -0x28(%ebp),%eax In the lea instruction, I understand that %eax gets the value at 0x28 before %ebp, but wh...

nasm random number generator function

I need a random number generator function written in nasm. I'm sorry for asking, but I couldn't find any! ...

how to sample instructions retired from C# application

I'm looking to sample the hardware event "instructions retired" or "exclusive instructions retired" from an intel chip from a C# application. Specifically, I need to sample this number at the beginning and end of a function call, so running a profiling run using cpu counters in visual studio 2010 according to this article: http://msdn....

functional assembly language

Hey guys, Lets say there was an architecture XYZ which was optimised for functional languages (like haskell). Can any tell me the advantages of such an architecture and also a "functional" assembly language? Thanks in advance ...

Relocation overflow when performing bitwise AND (SPARC Assembly)?

I am trying to perform a bitwise AND on a register, as a bitmask to remove the most significant bit (which happens to be bit 16 when counting from 0). However, when I try to compile my code using gcc, it gives me the following error messages: Assembler messages: 19: Error: relocation overflow My guess is that this has something to do w...

DPPS on older version GCC

Hei! I need to optimize some matrix multiplication code in c, and I'm doing it using SSE vector instructions. I also found that there exists SSE4.1 that already has instruction for dot-product, dpps. The problem is that on machine this software is supposed to work there is an old version of gcc installed (4.1.2), which has no support f...

What segment is used by default in x86 indirect addressing?

I'm a little confused as to exactly what segment is used when you have x86 assembly like the below (Intel syntax): mov ax, [di] I'm pretty certain it wouldn't be the code segment, I'm thinking either the data segment or the stack? (Or is the stack part of the data segment?) ...

Which one of these two ways of writing this code would be more suited?

I've got a code that as you can see I can write in either of two following ways, the matter is the only difference is since in second function the parameter is declared as non-constant I can use that instead of declaring a new variable(num1 in first function) but I' curious which one would be more suited if there would be any difference ...

Fastest way to run a program in a 64 bit environment?

It's been a couple of decades since I've done any programming. As a matter of fact the last time I programmed was in an MS-DOS environment before Windows came out. I've had this programming idea that I have wanted to try for a few years now and I thought I would give it a try. The amount of calculations are enormous. Consequently I want ...

Assembly Character Comparison Problem

Hi all, We are trying to implement levensteing distance algorithm in assembly and calling the assembly function from C code. But we have some char comparison problem and could not solve the problem. Function takes two char* parameters. In the first two lines i mov the these addressess to ecx and edx. iminusOne and jminusOne are indexe...

problem with asm code, computing the factorial.

Given a number, this program computes the factorial, but it no long works with number bigger than 9 .section .data .section .text .globl _start _start: pushl $10 movl %eax, %ebx call func addl $4, %esp movl %eax, %ebx movl $1, %eax int $0x80 .type func,@function func: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax ...

Is there a assembly tester ?

I mean something like a regular expression tester. I could input the machine code and the software could verify/disassemble it to see whether the code is correct/what does the code represent. I could also input the assembly and the software could also verify/assemble it to machine code. It should have a GUI interface and run under Win...

Question regarding assembly language.

I am reading the book The Art of Assembly Language. I came across this paragraph. To determine a particular instruction’s opcode, you need only select the appropriate bits for the iii, rr, and mmm fields. For example, to encode the mov ax, bx instruction you would select iii=110 (mov reg, reg), rr=00 (ax), and mmm=001 (bx). This pr...

Question regarding assembly language.

I am reading the book The Art of Assembly Language. I came across these two lines. the three byte encoding for mov ax, [1000] would be 0C6h, 00h, 10h and the three byte encoding for mov ax, [2000] would be 0C6h, 00h, 20h. Can anybody show me how mov ax, [1000] converted to oc6h, ooh, 10h and mov ax, [2000] converted to 0C6h, 00h, 2...

checking if a key was pressed

I need to know which interrupt in linux checks if any key was pressed. Thanks. ...