cpu-registers

Can you modify CPU registers from within VS2008 IDE?

Was just wondering if there was a way to edit the CPU registers (i.e. EAX, EBX, ECX, etc) or flags (OV, UP, erc) from within the Visual Studio IDE. I know you can view them using the Registers pane (ctrl-shift-G) and you can cycle through them with TAB or ENTER, but I don't seem to be able to change any of them while debugging (yes, pro...

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

Why did Windows 64 choose to require xmm6 and xmm7 to be saved/restored?

Why did Windows 64 choose to require xmm6 and xmm7 to be saved/restored? In Windows 32, you could write assembly routines which clobbered xmm0...xmm7. But if you take that same assembly code and run it in Windows 64, it will usually cause an application fault because VS2007 stores double-precision values in xmm6 and xmm7. It seemed to ...

What's a good example of register variable usage in C?

I'm reading through K&R and came to the small section on register variables, and was wondering if people here have some good examples of this put into practice. From section 4.7 in K&R: The register declaration looks like register int x; register char c; To be clear, I'm just hoping to see some cool code samples. I ...

Debugging managed code: Viewing return value

On Win32, with unmanaged code, the return value is usually stored in the EAX register. This is useful when the program doesn't save the return value in a variable. This can easily be seen in the Visual Studio debugger. Is there an equivalent for managed code? ...

Can I control register allocation in g++?

I have highly optimized piece of C++ and making even small changes in places far from hot spots can hit performance as much as 20%. After deeper investigation it turned out to be (probably) slightly different registers used in hot spots. I can control inlineing with always_inline attribute, but can I control register allocation? ...

Can increment of a register be used to determine the clock rate?

Can increment of a register (in a loop) be used to determine the (effective) clock rate? I've naturally assumed it can, but I was commented that Cpu's may implant Super-scalar techniques that make this kind of computation useless. Also I was told that incrementing of registers on CPU can be done in less than one clock cycle. is it true...

Reading from 16-bit hardware registers

On an embedded system we have a setup that allows us to read arbitrary data over a command-line interface for diagnostic purposes. For most data, this works fine, we use memcpy() to copy data at the requested address and send it back across a serial connection. However, for 16-bit hardware registers, memcpy() causes some problems. If I ...

Callee save with the caller passing the used registers?

In compiler design, why instead of having a caller or callee register saving arrangement, couldn't the caller pass its list of used registers (that it would push in case of a caller saving arrangement) to the callee so that the callee can compare its list of used registers to the registers used by the caller. Then only the registers that...

Terminology: "registers" in assembly language programming

I've heard the terminologies: register, hardware register, program register,register file. What's the difference between all these? And in assebmly, what is the type of the EAX register? Program register? ...

Embedding assembly in C with compiler finding registers for you

When embedding assembly code into a C/C++ program, you can avoid clobbering registers by saving them with a push instruction (or specify clobber list of compiler supports it). If you are including assembly inline and want to avoid the overhead of pushing and popping clobbered registers, is there a way of letting gcc choose registers for...

What does the PIC register (%ebx) do?

I have written a "dangerous" program in C++ that jumps back and forth from one stack frame to another. The goal is to be jump from the lowest level of a call stack to a caller, do something, and then jump back down again, each time skipping all the calls inbetween. I do this by manually changing the stack base address (setting %ebp) and...

What is the practical difference between the SI and DI registers?

I don't get what is the difference. ...

Is there a way to store part of a 16 bit value in an 8 bit variable in Assembly?

I created one variable that stores a 16 bit variable, and I'm tring to store the upper half in an 8 bit variable. How do I do this? EDIT: its for the IA-32, and I don't think i can use registers EDIT2: I am allowed to use registers. ...

Cannot access label through segment registers, error in assembly

INCLUDE Irvine16.inc .data byteArray BYTE 6 DUP(?) listSize = ($ - byteArray) aSum WORD 0 soffset = 0 .code main PROC mov ax, @data mov ds, ax mov cx, listSize Loop1: mov ax, 0 movzx ax, [byteArray + soffset] add aSum, ax soffset = soffset + 1 loop Loop1 exit main ENDP END main ...

Show CPU Registers in VS2008 watch window

Is it possible to add CPU registers (RAX, EAX, flags, etc etc) with a specific syntax in a watch window so they are displayed like regular variables and printed in base-10 (or hex if Hexadecimal Display is on) ? e.g: if Registers window shows RAX = 00000000027A6468, adding %rax to watch would result in: Name Value Type %rax ...

CPUID on Intel i7 processors

I'm having an issue with my CPUID-based code on newer i7-based machines. It is detecting the CPU as having a single core with 8 HT units instead of 4 cores each with 2 HT units. I must be misinterpreting the results of the CPUID information coming back from the CPU, but I can't see how. Basically, I iterate through each processor visi...

C++ CPU Register Usage

In C++, local variables are always allocated on the stack. The stack is a part of the allowed memory that your application can occupy. That memory is kept in your RAM (if not swapped out to disk). Now, does a C++ compiler always create assembler code that stores local variables on the stack? Take, for example, the following simple code:...

when to use registers in C?

Hi, I have something like this register unsigned int a, b, c; int n; for (n = 0; n < 10; ++n){ c = a + b b = a a = c array[n] = c; } what it does, it doesn't matter. The code runs quickly the way it is now, slower if the register keyword is removed. However, when I add in register before int n, it actually runs slower than now, but f...

Debugging assembly

How do I debug assembly code? I'm on Linux and have gdb handy. I know I can watch registers. What are some methods for debugging assembly code? ...