cpu-registers

how to use processor registers in visual studio ?

i'm trying to write a program that solves the rsa challenge (yes i have interesting goals) and currently i don't have a 64 bit linux box and i don't really wanna spend my time writing a program that doesn't have a chance to ever finish. so while i can do some assembler programming, i would prefer using C++. however, i would also be inter...

In MIPS, what is HI and LO

I'm reading about division in MIPS and I've found that div Divides $s by $t and stores the quotient in $LO and the remainder in $HI http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html And Wikipedia says HI and LO are used to access the multiplier/divider results, accessed by the mfhi (move from high) and mflo com...

Set CPU register values while debugging managed app in VS

I am debugging a .NET app in Visual Studio 2010 RC using disassembly view. The code is optimized and JIT-ed. At a particular point, I need to change ZR CPU flag so that JNE instruction would take a different path. For some strange reason, the registers window in VS is readonly and does not let me change register values, nor can I use "se...

What are CPU registers and how are they used, particularly WRT multithreading?

This question and my answer below are mainly in response to an area of confusion in another question. At the end of the answer, there are some issues WRT "volatile" and thread synchronisation that I'm not entirely confident about - I welcome comments and alternative answers. The point of the question primarily relates to CPU registers a...

What does ESP mean in assembly?

ESP = ? stack pointer What does E stand for here? UPDATE RSP for 64bit? What does R mean here? ...

Quick, beginner MASM register question - DX:AX

Hello, I am currently studying for an exam I'll have on x86 assembly. I didn't have much luck googling for ":", too common of a punctuation mark :/ IDIV - Signed Integer Division Usage: IDIV src Modifies flags: (AF,CF,OF,PF,SF,ZF undefined) Signed binary division of accumulator by source. If source is a byte va...

Simple way to print value of a register in x86 assembly.

I need to write a program in 8086 Assembly that receives data from the user, does some mathematical calculations and prints the answer on the screen, I have written all parts of the program and all work fine but I don't know how to print the number to the screen. At the end of all my calculation the answer is AX and it is treated as an ...

Why is the JVM stack-based and the DalvikVM register based?

I'm curious, why did Sun decide to make the JVM stack-based and Google decide to make the DalvikVM register based? I suppose the JVM can't really assume that a certain number of registers are available on the target platform, since it is supposed to be platform independent. Therefor it just postpones the register-allocation etc, to the ...

Could this code damage my processor?

A friend sent me that code and alleges that it could damage the processor. Is that true? void damage_processor() { while (true) { // Assembly code that sets the five control registers bits to ones which causes a bunch of exceptions in the system and then damages the processor Asm( "mov cr0, 0xffffffff \n\...

How is the implicit segment register of a near pointer determined?

In section 4.3 of Intel 64® and IA-32 Architectures Software Developer's Manual. Volume 1: Basic Architecture, it says: A near pointer is a 32-bit offset ... within a segment. Near pointers are used for all memory references in a flat memory model or for references in a segmented model where the identity of the segment being accessed...

Is it possible to access 32-bit registers in C ?

Is it possible to access 32-bit registers in C ? If it is, how ? And if not, then is there any way to embed Assembly code in C ? I`m using the MinGW compiler, by the way. Thanks in advance! ...

How do i write Simple inline asm instruction from C on Linux 64 bit?

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 ...

Is there a standard way to detect bit width of hardware ?

Variables of type int are allegedly "one machine-type word in length" but in embedded systems, C compilers for 8 bit micro use to have int of 16 bits!, (8 bits for unsigned char) then for more bits, int behave normally: in 16 bit micros int is 16 bits too, and in 32 bit micros int is 32 bits, etc.. So, is there a standar way to test it,...

Reading RIP(Instruction Pointer) using offset from RBP(Base Pointer+offset)

Hello All, i am working on an application where i need to find RIP value several times during execution of my application on 64 bit linux. this is relevant to stack walk algorithm on Linux 64 bit. i can use asm instructions and ptrace for the same, but now i want to use some other algorithm for the same. for this understanding of the r...

Is this a valid C code?

Possible Duplicate: What does the code do? void duff(register char *to, register char *from, register int count) { register int n=(count+7)/8; switch(count%8) { case 0: do{ *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *t...

Modern CPU Inner Loop Indirection Optimizations

From http://www.boost.org/community/implementation_variations.html "... coding differences such as changing a class from virtual to non-virtual members or removing a level of indirection are unlikely to make any measurable difference unless deep in an inner loop. And even in an inner loop, modern CPUs often execute such competing code s...

Can gcc/g++ tell me when it ignores my register?

When compiling C/C++ codes using gcc/g++, if it ignores my register, can it tell me? For example, in this code int main() { register int j; int k; for(k = 0; k < 1000; k++) for(j = 0; j < 32000; j++) ; return 0; } j will be used as register, but in this code int main() { register int j; int...

Are CPU registers and CPU cache different?

Are CPU registers and CPU cache different? ...

Why are CPU registers fast to access?

Register variables are a well-known way to get fast access (register int i). But why are registers on the top of hierarchy (registers, cache, main memory, secondary memory)? What are all the things that make accessing registers so fast? ...

What CPU registers are to be restored at the end of an asm procedure in Delphi

When writing a Delphi procedure or function in assembly code, which registers must be saved and restored to the original value at the end of the procedure? When calling another Delphi procedure or function from (inline) assembly code, what can I expect that other function to do with the registers? Which registers will be restored to the...