From what I know, back in the days of 16bit PC's we had the Segment registers contain the address of each type of segment and you could access an offset with something like this SS:[EDI], this would take the value contained in EDI as an offset to the Stack Segment.
Now I know that in 32bit systems, we have the GDT (Global Descriptor Ta...
Is there an equivalent of the XADD command in .Net? This is, after all, the most efficient method of locking / checking locks for critical sections or for ensuring accurate increments in a multi-threaded environment.
I looked through the IL opcodes, but couldn't find an equivalent.
...
Is it true that the x86 ASM "LOCK" command prefix causes all cores to freeze while the instruction following "LOCK" is being executed?
I read this in a blog post and it doesn't make sense. I can't find anything that indicates if this is true or not.
...
I'm writing to memory space a few address and I need to optimize the code. There is a better way to do the following?
SETB 00h
SETB 01h
SETB 02h
SETB 03h
SETB 04h
SETB 05h
SETB 06h
SETB 07h
...
Hello,
i am writing a simple c program and my requirement is to print RIP(Instruction Pointer) from some function of the program. i dont want to use ptrace.
the one thing i tried with inline asm is:
asm("movl %%rip, %0;" : "=r"(val) )
this should copy my rip register value to variable val, but i am getting compilation error.
if i use ...
The host has ultimate control over the
bus and may inhibit communication at
any time by pulling the Clock line
low.
How to pull the Clock line low in assembly and release in windows?
...
I know how to use LOCK to thread-safely increment a value:
lock inc [J];
But how do I read [J] (or any value) in a thread-safe manner? The LOCK prefix can't be used with mov. And if I do the following:
xor eax, eax;
lock add eax, [J];
mov [JC], eax;
It raises an error on line 2.
...
I'm trying to learn assembly -- x86 in a Linux environment. The most useful tutorial I can find is Writing A Useful Program With NASM. The task I'm setting myself is simple: read a file and write it to stdout.
This is what I have:
section .text ; declaring our .text segment
global _start ; telling where pr...
I know how to atomically write a value in x86 ASM. But how do I read one? The LOCK prefix can't be used with mov.
To increase a value, I am doing:
lock inc dword ptr Counter
How do I read Counter in a thread-safe way?
...
Hi, I have a method to check weather a number is even or odd:
-(BOOL)numberIsEven:(unsigned int *)x {
if (x & 1)
{
return TRUE;
}
else
{
return FALSE;
}
}
however whenever I compile it I get the error:
Invalid operands to binary %
So it's compiling into assembly as a modulus function and failing, somehow, however if...
I've been revisiting Motorola 68000 programming lately. Admittedly, when I took the course I just did what was necessary to pass (and had a horrible professor)...but NOW I'm actually interested in the stuff. Anyway, looking through my old textbook The 68000 Microprocessor by James L. Antonakos, he uses the following code:
ORG ...
Many SSE instructions allow the source operand to be a 16-byte aligned memory address. For example, the various (un)pack instructions. PUNCKLBW has the following signature:
PUNPCKLBW xmm1, xmm2/m128
Now this doesn't seem to be possible at all with intrinsics. It looks like it's mandatory to use _mm_load* intrinsics to read anything...
I was coding a snake game, and i got an apple image to use in the game, so i created a DC and then loaded the apple to this DC, when the game is running, it should copy the apple to the buffer and then the buffer to the screen, but the apple ends black and white in the screen, any1 has idea why? here is some of my code, might help...
...
Hello,
I just noticed some strange assembly language code of empty main method.
//filename: main.c
void main()
{
}
disassembly:
push ebp
mov ebp,esp
sub esp,0C0h; why on the earth is it reserving 192 bytes?
push ebx
push esi
push edi ; good compiler. Its saving ebx, esi & edi v...
I was drawing a bitmap on the screen, and i wanted to set a transparent color on this bitmap (0xFFFFFF White) i wanted to know if its possible, and if it is, how to do so xP
I use this code to load the bitmap
invoke LoadBitmap,eax,10
push eax
invoke GetDC,0
invoke CreateCompatibleDC,eax
pop ecx
mov [mapple],eax
invoke SelectObject,[ma...
I have a project where i manually define a very long array(over 30, every one is a struct object with 2 values). When I define the array in multiple rows I get an error for every row, I don't get the error after I define it one row.how can i write the array in multiple rows?
i have a second problem that when i compile the code
include ...
Hi all,
I'm having a problem converting an inline assembler function to .asm file. I need seperate inline assembler code because in x64 architecture doesn't have support for inline assembly.
Here is the code,
#include <windows.h>
#include <string>
#include <iostream>
#include <tlhelp32.h>
using namespace std;
int filter(int code...
Hello, I would like to know how memory allocation on the lowest levels works. For example if program wants to create some long array or anything else, how it will ask for the memory, how does the program ensure itself that it does not take memory same other program is using.
I would be very grateful if someone would bring some light fo...
I'm learning asm on Linux (noobuntu 10.04)
I got the following code off of: http://asm.sourceforge.net/intro/hello.html
section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call numb...
There is a program I would like to understand a bit more of, but most of it is in ASM. MatrixMultiply
The reference page is here.
I understand C++, but the ASM part is a bit vague. Can someone explain?
...