assembly

Producing x86 assembly code from a binary executable/C array

Hi, I have a C array that contains binary x86_64 machine code, which I need to convert to assembly code on a Linux machine. I have no problem in converting the C array to a binary executable, but can't find the utility to convert it to asm code. Any ideas? Thanks! ...

How to benchmark on multi-core processors

I am looking for ways to perform micro-benchmarks on multi-core processors. Context: At about the same time desktop processors introduced out-of-order execution that made performance hard to predict, they, perhaps not coincidentally, also introduced special instructions to get very precise timings. Example of these instructions are rdt...

Problem with asm program (nasm)

org 0x100 SEGMENT .CODE mov ah,0x9 mov dx, Msg1 int 0x21 ;string input mov ah,0xA mov dx,buff int 0x21 mov ax,0 mov al,[buff+1]; length ;string UPPERCASE mov cl, al mov si, buff cld loop1: lodsb; cmp al, 'a' jnb upper loop loop1 ;output mov ah,0x9 mov dx, buff int 0...

iPhone/ARM calling convention

Hi all, on iPhone/ARM, which CPU registers are functions supposed to preserve, if any? ...

Assembly 6800 Looping? Testing specific bits in a word.

Hi all, Trying to help a friend out with a friend out with some assembly code, but I've run into a small problem. I'm trying to work out how I would loop through a 8 bit binary word and check the value of specific bits. I need to check bits 1, 3, 5 & 7 to see if they are 1. i.e. int count = 1; int bitAdd = 0; foreach (var bit in wo...

Difference between lea and offset

ar db "Defference $" What the difference when I used mov dl,offset ar and lea dl,ar I think both are doing same work but what is the difference between these two Please specify clearly ...

Lua-Objective-C bridge on the iphone

I have partially ported the LuaObjCBridge to the iPhone. Most things work but there are still some issues I have to deal with. There are sections where #defines are defined with-respect-to intel or ppc. Is the ARM chip closer to intel or ppc? Here is the most relevant section where most of the defines are: #if defined(__ppc__)||define...

How To Create Your Own x86 Operating System for Modern PC Computers

I'd like to create a new operating system for x86 PC computers. I'd like it to be 64-bit but possibly run as 32-bit as well. I have these kinds of questions: What kinds of things do you start working on first? Knowing where to start in writing your own operating system seems to me to be a tricky subject, so I am interested in your inpu...

MIPS Assembler Instruction parameters

Hi, why does such a instruction as mul $t1, $v0 , 4 evaluates as expected. But mul $t1, 4 , $v0 results in a syntax error! I wonder why the first one works, because mul only works with registers per default, so I expect that only a solution like this will be workin li $t1, 4 # set $t1 = 4 mul $t1, $v0 , $...

invalid effective address calculation!

Hay Dear! Please look at the following program, the error is invalid effective address calculation and i have mentioned that line please tell me why its invalid effective address calculation here is the program [org 0x100] jmp start array1: dw 10,15,20,25,30,35,40,45,50,55 array2: dw 15,10,20,35,40,30,55,50,25,45 start: mov bx,0 ...

In-line assembly

For the below code, if i want to convert the for loop to in-line assembly, how would it be done? (Pardon the weird code, i just made it up.) 1) This is for the x86, using visual studio 2) This is a "how to use in line assembly" question, not a "how to optimize this code" question 3) Any other example will be fine. I will think of some...

How to catch a tab press in x86 assembly?

Hi, I'm working on a project in x86 assembly on Windows (MASM), and I need to somehow catch tab presses, but I'm not sure how to do that in assembly (I'm new to it). I can get get user input with int 21h, but as far as I can tell that only works if the users types the data, then presses enter. What I need is a way so that if the user ...

Writing a VM - well formed bytecode?

Hi, I'm writing a virtual machine in C just for fun. Lame, I know, but luckily I'm on SO so hopefully no one will make fun :) I wrote a really quick'n'dirty VM that reads lines of (my own) ASM and does stuff. Right now, I only have 3 instructions: add, jmp, end. All is well and it's actually pretty cool being able to feed lines (doing i...

Compile Assembly Output generated by VC++?

I have a simple hello world C program and compile it with /FA. As a consequence, the compiler also generates the corresponding assembly listing. Now I want to use masm/link to assemble an executable from the generated .asm listing. The following command line yields 3 linker errors: \masm32\bin\ml /I"C:\Program Files (x86)\Microsoft Vis...

ARM Assembly - Branch Instruction

I'm looking at some assembly for the start up of some firmware that runs on an ARM processor. The following exception vector table is defined: LDR pc, =resetHandler LDR pc, Undefined_Addr LDR pc, SWI_Addr LDR pc, Prefetch_Addr LDR pc, Abort_Addr B . LDR pc, =irqHandler LDR ...

Assembly GDB Print String

So in assembly I declare the following String: Sample db "This is a sample string",0 In GDB I type "p Sample" (without quotes) and it spits out 0x73696854. I want the actual String to print out. So I tried "printf "%s", Sample" (again, without quotes) and it spits out "Cannot access memory at address 0x73696854." Short version: How d...

Most Efficient way to set Register to 1 or (-1)

I am taking an assembly course now, and the guy who checks our home assignments is a very pedantic old-school optimization freak. For example he deducts 10% if he sees: mov ax, 0 instead of: xor ax,ax even if it's only used once. I am not a complete beginner in assembly programing but I'm not an optimization expert, so I need yo...

invalid program counter value: 0

Hello , i'm currently working with assembly language under the MIPS processor. I'm currently using MARS simulator and for reasons unknown i get the following error message after every run: Go: running try.s Error in : invalid program counter value: 0 Go: execution terminated with errors. I get this error message independent of the co...

LIFO stack algorithm design

I'm implementing a stack-based VM and I've been trying to read up on literature that explains or outlines algorithms for dealing with stacks no no avail. Here's an example: int i = 3 int j = 4 int k = 5 Lets assume i, j, and k are local variables so they would be traditionally stored on the stack. The assembly/bytecode translation wou...

Why is FLD1 loading NaN instead?

I have a one-liner C function that is just return value * pow(1.+rate, -delay); - it discounts a future value to a present value. The interesting part of the disassembly is 0x080555b9 : neg %eax 0x080555bb : push %eax 0x080555bc : fildl (%esp) 0x080555bf : lea 0x4(%esp),%esp 0x080555c3 : fldl 0xffff...