assembly

x86: ZF not always updated by AND?

Hello! I'm debugging my code on x86 and the problem tracks down to AND instruction sometimes does not clear ZF flag if the result is not zero. Here is the problematic piece of code: 0257A9F9 mov edx,dword ptr [ecx+18h] 0257A9FC and edx,80000h 0257AA02 int 3 0257AA03 je 0257AA2A I added a b...

How do you generate a random number in Assembly language using the FASM compiler?

Hey guys, I'm really new to assembly and I'm trying to create a simple program. For this I need to generate a random number. Anybody know how I can do this with the FASM compiler? Thanks, Sam ...

dollar-terminated strings

In my assembly language class, our first assignment was to write a program to print out a simple dollar-terminated string in DOS. It looked something like this: BITS 32 global _main section .data msg db "Hello, world!", 13, 10, ’$’ section .text _main: mov ah, 9 mov edx, msg int 21h ret As I understand it, the $ sign serves...

Do any FASM veterans want to become a mentor?

Learning assembly has so far been pretty hard, I have read every tutorial I could find and I'm still having trouble getting some of the basics down. Does anyone out there want to mentor me and answer a few questions every now and then? Thanks to anyone considering. ...

Should I still learn C if I already know Assembly?

Often one of the main reasons given for learning C is that it brings you closer to programming at a low level which gives you insights into how things really work in higher level languages. I've been programming in various Assembly flavors for awhile and you can't get any lower level than what I have been coding in and I have no illusio...

Return from interrupts in x86

I have loaded an idt table with 256 entries, all pointing to similar handlers: for exceptions 8 and 10-14, push the exception number (these exceptions push an error code automatically) for the others, push a "dummy" error code and the exception number; then jump to a common handler So when the common handler enters, the stack is prop...

Why are there extra instructions in my gcc output?

GCC compiles (using gcc --omit-frame-pointer -s): int the_answer() { return 42; } into .Text .globl _the_answer _the_answer: subl $12, %esp movl $42, %eax addl $12, %esp ret .subsections_via_symbols What is the '$12' constant doing here, and what is the '%esp' register?...

[gcc generated assembly] .comm?

I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; } to assembly using gcc producing, .cstring LC0: .ascii "Hello, World!\0" .text .globl _main _main: pushl %ebp movl %esp, %eb...

How to compare two similar g++ -S assembly outputs?

diff fails as the assembly listing is filled with slightly different labels. ...

Which is the correct branch instruction for branch if less than.

I wrote an answer yesterday to this: http://stackoverflow.com/questions/192479/whats-the-coolest-hack-youve-seen-or-done and I was trying really hard to remember my 6502 assembly, and I couldn't for the life of me remember how to branch if less than... :1 lda $C010 cmp #$80 bcc :1 ; branch if less than? I forget how to do that....

meaning of x86 assembler instruction

Can someone please explain what the following x86 assembler instruction does? call dword ptr ds:[00923030h] It's an indirect call I suspect but exactly how does it compute the address to call? Thanks Marek ...

A Simple Assembly Input Question

This is my first post on this site. I am taking an X86 assembly class and I am having a bit of trouble with my second project. The project is very simple. The program needs to take in a simple string from the user and display it back. I have gotten the program to take input from the user but I can't seem to store it. Here is what I have ...

Read from main memory and cache in Assembly

So I am being taught assembly and we have an assignment which is to find the time difference between reading from memory and reading from cache. We have to do this by creating 2 loops and timing them. (one reads from main memory and the other from cache). The thing is, I don't know and can't find anything that tells me how to read from e...

Assembly Prototype instruction

I am writing an assignment in MASM32 Assembly and I almost completed it but I have 2 questions I can't seem to answer. First, when I compile I get the message: INVOKE requires prototype for procedure & invalid instruction operands the first is due to this piece of code: .data? Freq DWORD ? Time1 DWORD ? Time2 DWORD...

How do I print 0,2,4,6,... in assembly language?

I have an assignment from my comp. system org. subject and unfortunately I'm kind of new when it comes to assembly language. I'm supposed to write a program that displays the numbers 0,2,4,6,8,10 respectively. How would I go about this? Maybe this'll answer my question: (Reactions please) .model small .stack 100H .data .code call proc...

MASM32 loop

I'm trying to make a loop in masm32 running under Windows Vista, however I did it this way and even though it actually finishes the loop, it crashes and I see no obvious reason why...any ideas? .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include...

Strange assembly from array 0-initialization

Inspired by the question Difference in initalizing and zeroing an array in c/c++ ?, I decided to actually examine the assembly of, in my case, an optimized release build for Windows Mobile Professional (ARM processor, from the Microsoft Optimizing Compiler). What I found was somewhat surprising, and I wonder if someone can shed some ligh...

Emulating variable bit-shift using only constant shifts?

I'm trying to find a way to perform an indirect shift-left/right operation without actually using the variable shift op or any branches. The particular PowerPC processor I'm working on has the quirk that a shift-by-constant-immediate, like int ShiftByConstant( int x ) { return x << 3 ; } is fast, single-op, and superscalar, whereas...

SPARC - Bit mask without shift

Hi, I'm learning SPARC assembly and I have to create a script that extracts a field from a register. The script accepts 3 values, initial number, field start position, field length. It can't use any shift functions, but it can use multiply and divide. I'm currently suffering from a respiratory virus, and am subsequently on a significant ...

x86 assember - illegal opcode 0xff /7 under Windows

Hi overflowers I'm currently developing an x86 disassembler, and I started disassembling a win32 PE file. Most of the disassembled code looks good, however there are some occurences of the illegal 0xff /7 opcode (/7 means reg=111, 0xff is the opcode group inc/dec/call/callf/jmp/jmpf/push/illegal with operand r/m 16/32). The first guess ...