assembly

Can someone explain this directly assembled x86 JMP opcode?

At school we have been using a bootstrap program to run stand-alone programs without an operating system. I have been studying this program and when protected mode is enabled there is a far jump executed by directly assembling the opcode and operands as data within the program. This was for the GNU assembler: /* this code imme...

How to perform low-level IO with a USB flash drive under the BIOS (compared to a floppy)?

I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ? For example, here is...

How to use address constants in GCC x86 inline assembly

The GCC toolchain uses AT&T assembler syntax by default, but support for Intel syntax is available via the .intel_syntax directive. Additionally, both AT&T and Intel syntax are available in a prefix and a noprefix version, which differ in whether or not they require to prefix register names with a % sigil. Depending on which directives...

MASM32 Memory Locations

I am attempting to read from main memory using masm32 assembly and in order to do this I created (as previously recommended in an answer to another of my questions here) an array that will contain the greatly separated memory locations (in order to avoid reading from cache). I have managed to create the array and have it being read, how...

Why isn't pass struct by reference a common optimization?

Up until today, I had always thought that decent compilers automatically convert struct pass-by-value to pass-by-reference if the struct is large enough that the latter would be faster. To the best of my knowledge, this seems like a no-brainer optimization. However, to satisfy my curiosity as to whether this actually happens, I created...

SPARC Assembly Tutorial

Any recommendations for a good tutorial on SPARC assembly online for free? Thanks ...

How does the stack work in assembly language?

I'm currently trying to understand how the stack works, so I've decided teach myself some assembly language, I'm using this book: http://savannah.nongnu.org/projects/pgubook/ I'm using Gas and doing my development on Linux Mint. I'm a bit confused by something: As far as I was aware a stack is simply a data structure. So I assumed i...

How thoroughly should one learn languages like C, ASM, Lisp, Haskell?

Languages like C, Haskell, Lisp, Smalltalk, and assembly language are often touted as things every programmer should know for their effect on the way one thinks about programming, even if they're used very little in real world situations. However, to really learn a language in depth to the point where you know not only the syntax and se...

Recursive assembly Call though no recursion in source code

I have a code fragment from a dump which I want to understand. What bothers me most, are the (seemingly) recursive calls like bd604: e8 fc ff ff ff call bd605 + 0xb5 What do they do? I don't use recursion in the original function. Thanks@schnaader it seems as if the calls make cld and jump to EAX EDIT: full dmp of my func...

Cygwin: Assembly language development?

Firstly I'm not sure if this should be part of the thread I started yesterday on assembly and the stack but I think the question I'm asking here is quite different. I'm been trying to understand what exactly Cygwin is, via Wikipedia and Google, I'm not having much luck. I've just begun assembly programming on Linux using the gcc gas ass...

Write MBR Code

I am an electrical engineer who has recently discovered the need to modify the code in the MBR. Basically I need the ability to execute code on the HDD before, the OS starts up and takes over. I fully understand that this will need to be written in Assembly and given the 446 bytes or so of code space in the MBR I just expect to call ot...

Disassemling a Win32 DLL with symbols

I've scoured Google and found to large a variety of tools and answers. I want to disassemble a DLL into something at least readable, e.g. recognise Win32 API calls by their names etc. How do I go about this? ...

Best book to learn Windows assembly programming?

The other day I came across a site by the name http://securityxploded.com/enumheaps.php. On this site the author was able to understand and analyze the Windows assembly code generated. Which book can I follow to grab the knowledge of understanding Windows assembly code? ...

What is your favourite anti-debugging trick?

At my previous employer we used a third party component which basically was just a DLL and a header file. That particular module handled printing in Win32. However, the company that made the component went bankcrupt so I couldn't report a bug I'd found. So I decided to fix the bug myself and launched the debugger. I was surprised to fin...

64-bit linux, Assembly Language, Issues?

I'm currently in the process of learning assembly language. I'm using Gas on Linux Mint (32-bit). Using this book: Programming from the Ground Up. The machine I'm using has an AMD Turion 64 bit processor, but I'm limited to 2 GB of RAM. I'm thinking of upgrading my Linux installation to the 64-bit version of Linux Mint, but I'm worried ...

Drain the instruction pipeline of Intel Core 2 Duo?

I'm writing some micro-benchmarking code for some very short operations in C. For example, one thing I'm measuring is how many cycles are needed to call an empty function depending on the number of arguments passed. Currently, I'm timing using an RDTSC instruction before and after each operation to get the CPU's cycle count. However, I...

Difference between K&R and ANSI function outputs

I ran the following code, and found some strange output. int mean_ansi (int num1, int num2) { printf ("In %s\n", __FUNCTION__); printf ("num1,num2 is %d,%d\n", num1, num2); return (num1 + num2) / 2; } int mean_K_and_R (num1, num2) int num1, num2; { printf ("In %s\n", __FUNCTION__); printf ("num1,num2 is %d,%d\n", num1,...

When is assembler faster than C?

One of the stated reasons for knowing assembler is that, on occasion, it can be employed to write code that will be more performant than writing that code in a higher-level language, C in particular. However, I've also heard it stated many times that although that's not entirely false, the cases where assembler can actually be used to g...

What is the purpose of the frame pointer?

I'm a beginner in assembly language and have noticed that the x86 code emitted by compilers usually keeps the frame pointer around even in release/optimized mode, when it could use the EBP register for something else. I undertand why the frame pointer might make code easier to debug, and might be necessary if alloca() is called within a...

Making an OS in C++

What kind of C++(Restate to programming) would I have to learn to make my own OS kernel? (I know I would also have to learn assembly.) EDIT*Like interrupts , keyboard driver, getting input.* Ok everyone I made a really * 3 basic OS and would like to share it. Here you go. http://bcsy.hostzi.com/BytOS.zip Compile on linux ...