assembly

Gentle introduction to JIT and dynamic compilation / code generation.

The deceptively simple foundation of dynamic code generation within a C/C++ framework has already been covered in another question. Are there any gentle introductions into topic with code examples? My eyes are starting to bleed staring at highly intricate open source JIT compilers when my needs are much more modest. Are there good te...

Problem with LIB-USB? "Error -5" after random # of bytes transferred

I'm having an issue with a USB project using LIB-USB. The USB device is based on a PIC18F4550 and has a single control endpoint. The PC front-end is written in MSVC and uses Lib-Usb 1.12. On the PC end, the program begins by setting the configuration, claiming the interface, then sending (and receiving) control messages (vendor specif...

COM calling convention on x64

I am trying to get a definitive answer regarding the way COM behaves on a x64 machine. Does Windows use the normal x64 calling convention when dispatching calls to COM interfaces on x64 machines (assuming the COM implementation is 64 bits)? Specifically, I dynamically generate my vtbl entries to point to a chunk of assembly that's dynami...

Best resources for learning x86_64 assembly?

Hello everyone. I'm currently teaching myself x86_64 assembly, mostly via AMD's ABI. There's tons of great resources out there for learning x86, but I'm finding that the 64 bit arena is pretty sparse. Anyone have some good resources hidden away? ...

Register allocation rules in code generated by major C/C++ compilers

I remember some rules from a time ago (pre-32bit Intel processors), when was quite frequent (at least for me) having to analyze the assembly output generated by C/C++ compilers (in my case, Borland/Turbo at that time) to find performance bottlenecks, and to safely mix assembly routines with C/C++ code. Things like using the SI register f...

Patching out CALLL by replacing with NOPs works in user space but not in kernel space

I have a device driver I want to patch. This device driver calls IOLog and I want to get rid of the logging. If I replace the CALLL to IOLog with (the corresponding number of) NOPs inside the device driver (kext), the kernel crashes with what looks like a smashed stack ("Backtrace terminated-invalid frame pointer 0"). The same techniqu...

ARM to C calling convention, registers to save

It's been a while since I last coded arm assembler and I'm a little rusty on the details. If I call a C function from arm, I only have to worry about saving r0-r3 and lr, right? If the C function uses any other registers, is it responsible for saving those on the stack and restoring them? In other words, the compiler would generate code...

Is there a programming language "below" Assembly?

Is there a programming language "below" Assembly? Thanks. ...

Doxygen and Assembly Language

I'd like to use Doxygen to document legacy code that's a mix of C and x86 assembly language. The assembly language is not inline, but in separate assembly-only files. What is the recommended way to deal with the assembly language portion? ...

C Training on 16-bit microcontrollers

My comany is transistioning from assembly coded microcontrollers to C. We are considering Microchip, Atmel, Renasas, et. al. for future projects using C code. Are there good training resources to bring our engineers up to speed with C? Seminars, instructors, classes, etc. The experience level of the engineers varies from no training ...

Resources for learning ARM assembly

I am looking for resources, either online tutorials or books, for learning ARM assembly. What would you recommend? ...

Is it possible to "decompile" a Windows .exe? Or at least view the Assembly?

A friend of mine downloaded some malware from Facebook, and I'm curious to see what it does without infecting myself. I know that you can't really decompile an .exe, but can I at least view it in Assembly or attach a debugger? Edit to say it is not a .NET executable, no CLI header. ...

Python ctypes and function calls

My friend produced a small proof-of-concept assembler that worked on x86. I decided to port it for x86_64 as well, but I immediately hit a problem. I wrote a small piece of program in C, then compiled and objdumped the code. After that I inserted it to my python script, therefore the x86_64 code is correct: from ctypes import cast, CFU...

Dumping the values of the registers in GCC

I need to get the values in the registers with GCC. Something similar to this: EAX=00000002 EBX=00000001 ECX=00000005 EDX=BFFC94C0 ESI=8184C544 EDI=00000000 EBP=0063FF78 ESP=0063FE3C CF=0 SF=0 ZF=0 OF=0 Getting the 32-bit registers is easy enough, but I'm not sure what the simplest way to get the flags is. In the examples ...

Setting up IRQ mapping

I'm following several tutorials and references trying to get my kernel set up, and I've come across voodoo code in a tutorial that isn't explained at all. Its code that I'm told maps the 16 IRQs (0-15) to ISR locations 32-47: void irq_remap(void) { outportb(0x20, 0x11); outportb(0xA0, 0x11); outportb(0x21, 0x20); outport...

"Hello World" in less than 20 bytes

We have had an interesting competition once, where everyone would write their implementation of hello world program. One requirement was that is should be less than 20 bytes in compiled form. the winner would be the one whose version is the smallest... What would be your solution? :) Platform: 32bit, x86 OS: DOS, Win, GNU/Linux, *BSD ...

How can I use gcc to compile x86 assembly code on an x64 computer

For a school assignment I have to write x86 assembly code, except I can't use gcc to compile it since my computer is an x64 machine, and gcc is only excpecting x86 code. Is there a command that'll make gcc accept it x86 assembly code? Thanks P.S. I know my code is valid since it compiles just fine on x86 machines. ...

Clear upper 16-bits in 1 ARM instruction

In ARM assembly immediates are encoded by an 8-bit rotated value which means we can only encode (0-256)^2n. Now my problem is that I want to clear the upper 16-bits of r0 and replace it with the half-word stored r1. But because of the limited range of the immediates I have to do: - bic r0, r0, #0xff000000 bic r0, r0, #0x00ff0000 add...

variable initialization in assembly for IA-32

Hello all, I have a question about variable initialization in MASM's assembly. How can I initialize 2^32 to a variable and to what kind of variable should I initialize? DWORD or REAL4? I try to do it like: val DWORD 2.0E+32 When I assign var to a register(e.g. mov eax,val) and try to write the value, I see something that is not 2^3...

a question regarding assembly program

Hey I'm studying assembly language from the book "art of x86 assembly" and I have a question I could'nt figure the answer. the program goes like this: "in this exercise you will start a program running that examines and operates on values found in mmory. then you will switch to the memory screen and modify values in memory (that is, you...