Status
Not open for further replies.

Hat Monster

Ars Legatus Legionis
47,680
Subscriptor
Many moons ago, I programmed in 680x0 assembly, knowing the ins and outs of optimizing for 000, 020, 030 and 060, often releasing seperate binaries for each. Therefore, I have no concept of a 16bit ISA (68000 was always 32bit), I feel constrained by having only 8 GPRs at my disposal and I'm just plain confused with LSB ordering. I just can't get my head around x86 and x87 is just absolutely stupid compared to the 6888x that I'm used to.
My questions are:
Is there anything to ease the transition? How can I best take advantage of today's CPU architectures and things like virtual registers? The closest I've been is the three way superscalar 060, but even that didn't have register renamers thanks to the ISA having enough to begin with.
And can I program the MMU? In the 68851, 68030, 68040 and 68060 I could enslave the MMU for things I'd rather the CPU not do. Does the OS prevent me from doing this, I'd guess it would.

H@
 

Prototyped

Ars Legatus Legionis
11,126
First stop: http://developer.intel.com/

Grab the three IA32 Software manuals, as well as the Optimization Guide.
Read through the manuals to get a feel for what you're up against. ;)

It also helps to get some assembly source and go through it, e.g. parts of
the Linux or *BSD kernels come to mind.

These should give you enough background to proceed.

Also, Windows comes with MS-DOS DEBUG, which can assemble IA16 instructions
on the fly. While this will not help much with IA32 proper, it should help
in giving you some background on how the instruction set works. IA32 is
essentially a 32-bit extension on IA16 (and coincidentally, the 80386 added
a proper, non-buggy MMU to provide protected virtual memory support), and
eases the constraints on the use of registers in various situations.

Try familiarizing yourself with integer IA32 before trying to tackle the x87
instruction set of the FPU (which is treated as a coprocessor), which uses
an entirely different stack of registers, and whose register behavior is
quite different.

Only after this should you think about tackling the SIMD instructions (MMX,
3DNow!, SSE, SSE2). :)

And, AFAIK, only the supervisor can control the MMU (which is usually
setting up descriptor tables, descriptor registers and addressing modes).

[This message was edited by Prototyped on January 25, 2002 at 20:07.]
 

Midlands

Ars Praetorian
535
Subscriptor
Hat -- out of curiosity, what makes you program in assembly nowadays? I can understand it for low-level debugging, but, beyond that, I don't know -- assuming you're programming for a PC, instead of an embedded situation.

Beating a modern compiler on current chip architectures is absolutely, insanely hard, as far as I can tell. One of my Masters' classes on chip architecture (taught by Patterson, the guy who did RISC and RAID) involved tracing through all the steps taken by a modern chip as it does speculative and/or OOO execution; the results were staggering. After three hours, we'd traced maybe 25 instructions.

Plus, optimization is becoming more and more about memory references. A blown cache lookup will burn 1000+ cycles on a modern chip, so optimizing for memory references and cache architectures wins you a lot more, typically, than playing with virtual registers.

(I, too, learned on the 680x0 series, and then PowerPC. Now there were sane assembly languages.)


[Edit: it's RAID, not RAIS. ;-)
 

wb

Ars Legatus Legionis
25,208
Subscriptor
One of my Masters' classes on chip architecture (taught by Patterson, the guy who did RISC and RAID) involved tracing through all the steps taken by a modern chip as it does speculative and/or OOO execution; the results were staggering. After three hours, we'd traced maybe 25 instructions.

This is exactly why I don't mess with assembly and detailed optimization on modern processors and compilers. You simply cannot predict the state of the processor and cache when your instructions execute, and you're much better off letting the compiler make those kinds of decisions for you. Of course on a VLIW architecture you can still swing some impressive optimizations when coding by hand, but that will generally only apply to the specific processor you're dealing with. Add another FU or change the cache dimensions, and all bets are off.
 

puppybane

Wise, Aged Ars Veteran
119
Well, I've noticed that gcc doesn't always do the smartest thing for PowerPC code generation. If nothing else, I can often take the code it generates and improve it.

Also I think it should be clarified that register renaming is mostly independent of the number of registers you have. It's necessary when processors can execute instructions out of order. You use the renames to avoid a problem with code like this:

add r5,r3,r4 # r5 = r3+r4
add r3,r6,r7 # r3 = r6+r7

If, for some reason, the second instruction got to execute first (for instance, if the first was waiting for the value of r4), it would overwrite r3 before the first instruction read it. So r3 is renamed for the second instruction, and later, after the first instruction is done, r3 will be actually updated. Also, until that happens, all instructions after the second will use the renamed r3's value.
 
Status
Not open for further replies.