assembly

x86 Assembly, misleading Error

I am trying to learn assembly, and have a program in AT&T syntax, for use with GNU AS Which I believe should work. I receive this error with GDB: Program received signal SIGSEGV, Segmentation fault. .PROGRAM () at concatenator.s:60 60 call strlen Current language: auto; currently asm The code is: .file "concatenator....

Code for detecting APIC id returns same ids for different logical processors

I run my NT service on an Intel Core2 based Win2k3 machine where I need to iterate through all logical CPUs (all bits in process affinity). To do so I call GetProcessAffinityMask() to retrieve the system affinity mask and then switch the process to each processor in turn: DWORD systemMask; GetProcessAffinityMask( ... &systemMask ); D...

help with my MARS MIPS Simulator Code

hey, i need help. I have written this code in MARS. It is supposed to receive an integer from the user, and convert it to HEX. I've been going over it for hours and as far as i can see, it should work fine. I have only included the loop and output part of the program as this is the only part that is not working. Can someone PLEASE point ...

Microsoft ASM interview question?

I was looking online through samples of interview questions asked in the past by Microsoft and came across this one: The following asm block performs a common math function, what is it? cwd xor ax, dx sub ax, dx Can somebody please answer this and explain the answer to me? Thanks!! Update : okay, so its computes the absolute ...

what do these instructions do

I am working on a simulator for the msp430 instruction set. gnu assembler will let you encode instructions like these: fc0a: 12 10 00 02 rrc &0x0200 fc0e: 22 11 rra #4 fc10: 23 52 add #4,#2 My guess is that rrc &0x0200 will fetch from address 0x0200 perform the rotate then write the answer back to address 0x0200...

Book resources for x86/x64 assembly programming on Win platform

Hello, I ran a search for assembly language resources on stackoverflow.com and found some interesting results, but they seemed to boil down to two groups: 1) Assembly references to old ia32 architecture, such as the 80386 to Pentium 2) Windows agnostic books. Most of the commenters make the point that assembler is CPU dependent and tha...

How un-portable is assembly language, /really/?

I understand that writing anything in assembly, or adding assembly to any program harms its portability. But, how bad? I mean, basically all PC's are x86 or x64 these days, right? So, if I embed assembly into a C program, why wouldn't it still compile no matter where it went? Does this notion of un-portability just refer to when you rea...

How to write this code with assembly code?

Hi guys, I want to change this code into assembly code, working on mac, how to do this? while (a --) { *pDest ++ += *pSrc ++; } ...

MIPS: How do parse out digits of a number? Basic question but yet hard.

I am currently learing MIPS for a class and wrote the below sample code. # UNTITLED PROGRAM .data # Data declaration section .text main: # Start of code section li $t1, 72 move $a0, $t1 li $v0,1 exit: li $v0, 10 syscall # END OF PROGRAM As show...

TI DSP programming - is C fast enough or do I need an assembler?

I am going to write some image processing programs for Texas Instruments DaVinci platform. There are tools appropriate for programming in the C language, but I wonder if it is really possible to take full advantage of the DSP processor without resorting to an assembly language. Do you know about any comparisons of speed between programs ...

How can I access system time using NASM?

I am trying to seed my random number generator with current system time. How can I access the system time using NASM? (I am using linux) ...

Whats the best resource to learn Assembly language for PIC microcontroller's

I'm going to start working on a project where I need to have a decent understanding of Assembly language for the PIC microcontroller's. I'm intimately familiar with C/C++, so I know how to code for the most part, and I have done many projects for the PIC already so I understand the architecture, but have done all my programming for it i...

How do you compile high-level code to get assembly code?

I was wondering if there's some special way to compile high-level code (preferably from c/c++ or java) to get the corresponding assembly code. ...

Convert Inline C Assembler (Intel syntax to AT&T)

I am trying to convert this function from MSVC++ to MINGW (this is the original MSVC function) VOID __declspec(naked) BNSTUB() { __asm { pushad; call OnChatPacketReceived; TEST EAX,EAX; popad; jnz oldCall; MOV EAX,0; MOV DWORD PTR DS:[EBX+0x6FF3EBA0],1 ret; oldCall: C...

Linux assembler error "impossible constraint in ‘asm’"

I'm starting with assembler under Linux. I have saved the following code as testasm.c and compiled it with: gcc testasm.c -otestasm The compiler replies: "impossible constraint in ‘asm’". #include <stdio.h> int main(void) { int foo=10,bar=15; __asm__ __volatile__ ("addl %%ebx,%%eax" : "=eax"(foo) : "eax"(foo), "ebx"(...

How do you get how much memory a program uses?

I have two programs, one in C++, the other in assembler. I want to compare how much memory they use when running respectively. How can I do this? I am doing the testing on Windows, but I also would like to know how to do it on Linux. ...

Clean x86_64 assembly output with gcc?

I've been teaching myself GNU Assembly for a while now by writing statements in C, compiling them with "gcc -S" and studying the output. This works alright on x86 (and compiling with -m32) but on my AMD64 box, for this code (just as an example): int main() { return 0; } GCC gives me: .file "test.c" .text .globl main .type main...

A simple C program without #include <stdio.h>

How to call "printf" directly without including stdio.h ? I found a interesting tutorial here: http://www.halcode.com/archives/2008/05/11/hello-world-c-and-gnu-as/ So, here's my attempt: int main(){ char ss[] = "hello"; asm ( "pushl %ebp ;" "movl %esp, %ebp ;" "subl $4, %esp ;" "movl $ss, (%esp) ;" "call _printf ;" "mov...

What is the practical difference between the SI and DI registers?

I don't get what is the difference. ...

sparc assembly and the %y register

I am currently working with a sparc computer and I am trying to know if a number is prime or not. here is a part of the code : mov 0,%y mov 3, %l1 nop nop nop sdiv %l1,2,%l3 rd %y, %l6 cmp %l6, 0 So basicaly what we have here is 3/2. So there should be a reminder of 1. This r...