assembly

How do I compile DOS programs on Debian?

For my assembly language class, we're writing DOS programs using DPMI. Unfortunately, I don't have access to a 32-bit windows machine all the time. I do have a Debian virtual machine installed on just about every computer I do use. I've got both DOSBox and DOSEMU installed. Is there any way that I can assemble and compile the program...

Developing kernels and testing them in virtual machines

I like programming challenges, and writing a kernel seems a programming challenge. Unfortunately, kernels are particularly hard to test because they are basically the core of operating systems and so they can't be easily ran on top of an operating system. However, I know about applications called Virtual Machines that can emulate compu...

Does x86 have an atomic increment that keeps the value that was stored?

I have found lock inc addr but that doesn't keep a copy of the stored value around and even a read immediately after it in the same thread could come after a competing write. The best solution I have found is a load/inc/cas loop. ...

Are there any languages that talk straight to the hardware and that aren't assembly?

Just wondering how the world of assembly works, and I was reading about the assembly language on wiki and this quote struck me: It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. I always thought assembly was a fixed language based on your CPU (w...

Shutdown the computer using assembly

How can I shutdown the computer using only assembly code? ...

Question regarding assembler output

Consider the following assembler output: START 100 MOVER BREG, ONE 101) + 04 2 105 MOVEM BREG, RESULT 102) + 05 2 106 PRINT RESULT 103) + 10 0 106 STOP 104) + 00 0 000 ONE DC '1' ...

Low level programming: How to find data in a memory of another running process?

I am trying to write a statistics tool for a game by extracting values from game's process memory (as there is no other way). The biggest challenge is to find out required addresses that store data I am interested. What makes it even more harder is dynamic memory allocation - I need to find not only addresses that store data but also poi...

Determine whether memory location is in CPU cache.

It is possible for an operating system to determine whether a page of memory is in DRAM or in swap; for example, simply try to access it and if a page fault occurs, it wasn't. However, is the same thing possible with CPU cache? Is there any efficient way to tell whether a given memory location has been loaded into a cache line, or to ...

EMMS instuction execution time?

I'm reading "The Art of Assembly - Chapter 11. The MMX Instruction Set" After executing some MMX instructions, the EMMS instruction needs to be executed to reset the FPU. It states the EMMS instruction is quite slow. However when I profiled the EMMS execution time to see just how slow it was, (using RDTSC to count clock cycles), it ap...

dword ptr usage confusion

In assembly language if we use mov eax, dword ptr[ebx] then it means copy the value pointed by ebx (ebx contains the address value, not the actual value, this instruction copies the actual value in the address)? If we use mov eax, dword ptr[some_variable] then it means copy the value of variable "some_variable" itself to eax, not ...

How CPUs implement Instructions like MUL/MULT?

In different assembly languages MUL (x86)/MULT (mips) refer to multiplication. It is a black box for the programmer. I am interested in how actually a CPU accomplishes a multiplication regardless of the architecture. Lets say I have two 16-bit values in my registers and I am the cpu, so I have to implement MUL using the other bit-fiddlin...

how to find CPU cycle for an assembly instruction

Hello everyone, I heard there is Intel book online which describes the CPU cycles needed for a specific assembly instruction, but I can not find it out (after trying hard). Could anyone show me how to find CPU cycle please? Here is an example, in the below code, mov/lock is 1 CPU cycle, and xchg is 3 CPU cycles. // This part is Platfo...

Learning x86 asm on linux

Duplicate What is a Good x86 Assembly Book? Could someone point me to a book/tutorial which is best for x86 asm on linux. I know there are threads that exist for this already, and probably some books even. ...

Code optimization bibles

Hello, What are the most highly regarded books on optimization / performance tuning of C/C++ code? ...

teaching my self Z/OS assembler?

'I've interned at a company that does a lot of mainframe work. Most of my mainframe experience has been using Java and Unix System Services. I've had some experience with the ISPF interface and C but none with assembler. I’m graduating shortly and will be taking an independent study my last semester. I’d like to stick with the mainframe ...

Need Help Understanding Compilers/HLL->Assembly

I am an electronics student and I have programmed mostly in Assembly. Last night I saw an amazing article that discussed writing a compiler in Ruby. What the author had done was use GCC to peek how the C translates to Assembly. That resonated a lot for me. I could finally see how the C program translated to Assembly.My question/request t...

Alloca implementation

How does one implement alloca() using inline x86 assembler in languages like D, C, and C++? I want to create a slightly modified version of it, but first I need to know how the standard version is implemented. Reading the disassembly from compilers doesn't help because they perform so many optimizations, and I just want the canonical f...

Threads in x86 assembler (using the GNU assember: as)

Whilst learning the "assembler language" (in linux on a x86 architecture using the GNU as assembler), one of the aha moments was the possibility of using system calls. These system calls come in very handy and are sometimes even necessary as your program runs in user-space. However system calls are rather expensive in terms of performanc...

intel syntax tcc (tiny c compiler)

Hi, I'm wondering if it's possible to use inline assembly with the intel syntax in c, using tcc (not gcc) thanks ...

How to translate NASM "push byte" to GAS syntax?

Why I'm "porting" a NASM source to GAS and I found the following lines of code: push byte 0 push byte 37 GAS doesn't allow "push byte" or "pushb". How should I translate the above code to GAS syntax? Thanks ...