Click for homepage

web page last updated 15th Mar 2006

x86 asm URLS. new URLs (15mar2006)

16 bit is big!

x86 A1!

All the options are bad!

I am trying to convince people that x86-AmigaOS is the way forward and that it is very feasible to create x86-native AmigaOS. I've just begun learning x86-asm so am finding out directly what x86 h/w is about. I'll try and put any general observations here. I'm having the time of my life because the x86 is a really astonishing paradigm. x86-asm is like a holiday camp compared to any other hardware I've looked at. It takes effort to learn but once you've learned its fantastic. And I'm getting into the subject at just the right time when 64bit is becoming cheap. Jammy dodger! I'm doing this for practical reasons, namely I want to get my FS project to boot directly from x86. I want to see if I can boot the FS from a floppy, remember that even the A1200's ROM will fit on a floppy.

29.12.2005: so far I've found all tutorials disappointing. None talk about 64 bit x86, the x86 has at least 5 different modes and the tutorials dont explain how you set these up. I should gradually learn this stuff but not via tutorials.

Most users have known for years that x86-AmigaOS is a winner. WinUAE, AROS, Amithlon all have gone down this path. It's a path of unlimited success. The people in charge of the OS however have done everything they can to stop x86-AmigaOS. They are wedded to PPC and the whole story seems to have been problematic. A path of neverending problems.

AFAICS x86 asm is very highly space efficient. Every single register has a special purpose eg CX is a loop counter, SI and DI are source and dest indices for copying arrays, etc. x86 asm is almost a compression scheme.

Copying an array in an inner loop can be done without mentioning registers!:

copy_loop:

	lodsb
	stosb
	loop copy_loop


There are 6 implicit registers, lodsb copies the byte ds:[si] to al and increases si, and stosb copies al to es:[di] automatically increasing di. And cx is the counter register for the loop. Here you see (or dont see!) 6 special purpose registers in action. lodsb==load-string-byte, stosb==store-string-byte.

The above is 4 bytes of machine code! lodsb==$AC, stosb==$AA, loop copy_loop==$E2FC

Furthermore lodsb could do the 2 ops in parallel, so as far as asm goes it is optimal. Spatially optimal, semantically optimal, optimal. And this isnt just one example, the whole design is like this. It is basically geometrically optimised hardware. As you see above they even thought about having 2 special purpose index registers.

Now maybe PPC *could* outdo x86, PPC zealots assert that its a better architecture than x86. At the same time most of them use either Linux or x86 machines, so they'll tell you how wonderful PPC is from a Windows or Linux email program or browser! RISC is just one optimisation paradigm, x86 have explored a totally different optimisation paradigm. RISC is clever optimisation, but x86 is pragmatic optimisation. If and when some RISC platform outdoes x86 for performance/price and is available in plentiful supply you then switch to RISC. You have to think in terms of numbers and not brands: price/power/availability/demand. x86 wins on all 4 factors. next question!

A good strategy is to develop the OS on *both* x86 and PPC, a sort of pincer movement, Linux is on both, bringing the OS to x86 wont be a lot of work, you are talking about months rather than years of coding.

Unix's philosophy is that the hardware is irrelevant, if you want Unix you buy whatever hardware gives you best cost-performance value and Unix's HAL is redirected to this new hardware. Hardware is like a battery, if the shop isnt selling Duracell you buy Varta. The music from your walkman or light from your torch will be exactly the same whether it is Duracell or Varta. This is why the first OS on the A1 was Linux and not OS4 (Linux is a reimplementation of Unix) and that Unix also ran on the Amiga 3000. Also Unix has been around since the 1970's so this is probably the oldest OS strategy, much older than AmigaOS. So there is no excuse for not following this principle. In particular it prevents hardware companies holding you to ransom by discontinuing lines, eg the discontinuation of the 68k series by Motorola caused all the problems.

Even if PPC could outdo x86 I'm talking about the present tense not the future tense. If my info is correct that you can buy a 3GHz 64 bit x86 + mobo for 100 and that such a mobo is backwards compatible with even a 286 from pre-history. PPC's design is definitely much more "correct" yet x86 appear to perpetually hack away around bad design decisions. And CISC above a RISC core is probably the ultimate way to do things.

27.1.2006: x86 is the most difficult CPU ever to code, it really is tricky. So 68k and PPC are ahead in this respect.

If Motorola had continued the 68k series I would support that even if it was twice the price and thrice as slow. But they abandoned us at the 68060. The whole point of the 68000 was that it was to be forwards compatible ad infinitum. I would also have supported a continuation of the classic hardware if that had happened. But I've never used PPC, I cannot be loyal to something I've never used. Now the Coldfire project sounds interesting as that is probably the fastest classic Amiga. Should be a lot faster than current UAE's.

The real deciding factor is the immensity of the x86 market, not only is it immense but its growth is accelerating. Also the immensity gives them the advantage of economy of scale. From the asm I've learnt so far I believe it will actually be easier to bring AmigaOS to x86 than to 68k. I think that's why x86-AROS is so successful, eg x86-AROS is much more successful than ppc-AROS. They are moving forwards with x86 unstoppably as its the best architecture to work on. 29.12.2005: I'm actually attempting to create my own bootstrap functionality, so I'm not just talking about this. I already know now how to do some of this, not enough yet to do anything useful.

What I've noticed about x86 is that everything is in the right place. An x86 tower is like an optimal geometrical concept. And x86 asm is like an x86 tower, eg the above asm shows how you dont even need to mention registers because the special purpose registers are all in the right place. The only thing I dont like is Windows, everything else is a fantastic revelation.

AmigaOS has gone through 2 totally different CPU's so far: 68k and now PPC. So why not a 3rd? PPC is sufficiently recent that all PPC binaries could be ported to x86.

Here are some URL's worth looking at if you are a 68k coder and want to know about the x86 path:

URL's for x86 asm:

x86 tutorial

(29.12.2005: this tutorial starts off fantastically but gradually fizzles out. So far I havent found any completely good tutorial. Remember that 32 bit will soon be obsolete so a tutorial really needs to explain 64 bit.)

download Windows TASM and TLINK compatible with above tutorial

Ralf Brown's BIOS documentation (fantastic),

Cross platform documentation on PCI. (PCI is clever stuff).

Maximum compatibility FASM assembler :64 bit, Windows+Linux+Unix+DOS

(note FASM isnt compatible with xs4all tutorial. But is an excellent assembler once you understand it.)

documentation of 386 opcodes

(very useful reference if you are looking at some asm. Clearly it wont tell you about 64 bit, not sure what to do there!)

Official documentation of x86 s/w coding.

Official x86 asm documentation, opcodes A-M

Official x86 asm documentation, opcodes N-Z

Official x86 system level documentation, part A

Official x86 system level documentation, part B

Art of Assembler (very sophisticated look at x86 asm, appears not to deal with 64 bit, and AFA graphics is concerned only looks at 80 x 25 text graphics in chapter 23 (x86 has text hardware! no pixels). I'm reading this pdf (printed via gs850) at the moment as the author has a very deep grasp of the subject. Apparently the material used to be 16 bit only and he then modernised it to 32 bit. He conveniently has 1 pdf file per chapter which makes it easier to navigate the printout. The font of the HTML version is unreadably small. )

GRUB is the official way to boot to alternative x86 OS's, eg I boot to x86-Linux and x86-AROS via GRUB. GRUB is x86's equivalent of UBoot (I think):

GRUB2 website

webpage for GRUB2 v1.91 download

GRUB documentation

I'm trying to get a "hello world" experiment to bootstrap above GRUB.

16 bit is big!

x86 by default is 16 bit, 16 bit registers, 16 bit addresses, etc. Not tried this yet myself but you can then switch to 32 or 64 bit. Now many people probably think 16 bit is small. But 16 bit is 2^16==64*2^10 which is 64K. You can actually code an app in 64K! eg Memacs is less than 64K:

8: list Memacs
Memacs                           50796 ----rwed 08-Oct-02 23:35:57


And gcc is only a bit bigger than 64K:


8: list gg:bin/gcc
Directory "gg:bin" on Sunday 18-Dec-05
gcc                              74784 ----rwed 05-Apr-05 08:18:54


So actually 64K is plenty of space. The 64K which many think of as an inconvenience is actually a very effective space optimisation.

Bear in mind that 64K is some 32000 asm instructions. You can do a lot of stuff with 32000 instructions. At 50 lines of text per screen that is 640 screens of asm.

Unix, Linux and Windows have brainwashed people about size. One other thing is: never confuse size with difficulty. 10 lines of tricky code could take much longer to generate than 10 pages of straightforward code. Also something which is easy to do for a user could be difficult for the coder. And something easy for the coder could be highly nontrivial for the API developer. 20 lines of badly written code could be much more work than 5 lines of well written code that does the same thing: however the latter probably takes more time to figure out.

x86 A1!

I've learnt some interesting things about the Amiga. Apparently the A1 uses a customised x86 mobo. An x86 mobo has been hacked so that it can be powered by a PPC. So in fact people with A1's are using x86 hardware. I remember in the early 2000's Eyetech saying that the only way forward for the Amiga was to use x86 architecture. Now I understand what they meant. So this means that all non CPU hardware coding I learn about x86 should be applicable to the A1.

I also learnt that Pegasos uses a totally different approach and they actually create their own mobos.

Another strange development is that Microsoft XBOX will be using PPC! Apparently its to prevent people hacking the hardware. People figured a way to get XBox programs to run on ordinary PCs.

For me I dont care which system wins but I will make sure to only spend my time on whichever is the currently winning system. I've just bought a 64bit AMD x86 setup. Very tricky setting up a tower system for the first time. The edge of one of the IDE sockets broke and the pins got bent!

All the options are bad!

I've decided that all hardware and OS options are bad. The only OS I like is 68k-AmigaOS. I dont like Linux or Windows, I have no interest in BeOS or Mac. After looking at all options the only one I really like is 68k AmigaOS and the only option I want is x86-AmigaOS.

I've been doing a lot of studying and now coding with x86 and it is the most severe hardware under the sun. But I intend to continue learning x86 as it is so central to this planet.

With 68k or RISC you just write your programs and that is it. But with x86 when the machine is switched on it is 16 bit only with just 1MB of ram. 1MB because it uses the 16 bits shifted left 4 bits, giving you 2^(16+4) bytes which is 1MB. (in fact it is (2^16-1)*2^4 + 2^16-1 bytes, approx 1MB).

If you want 32 bit and more than the 1MB you have to go to hell and back! It is a very very complicated architecture.

I got my numbers wrong about prices, a 64 bit AMD is maybe 60, the mobo is maybe 60, the gfx card 60, the tower case maybe 30, the HD 60, optical drive 40, transformer 20. So the hardware is maybe 330, and Windows XP Home Edition is 150. So a basic powerful XP system is 480. And thats without monitor. Dont forget also RAM, they sell cheap RAM for 10 but quality RAM I think could be 60, then you'll need 2 IDE cables, which is 18, and you really need 2 IDE drives, OS on the 1 and user stuff on the other so thats another 60, maybe a 3rd IDE drive in a USB2 case 60 + 50 so you can access your data from another computer. And BTW USB2 isnt fast, it says 480Mb/second, but that is mega-bit not mega-byte so its only 60MB/second. You really need 2 optical drives so you can do drive to drive copies so thats another 40.

So when you go to pay your hardware will be: 618 and 150 for XP full version. You need the full version for full flexibility. (Upgrade versions cost 90 but if you are new to Windows you wont have anything to upgrade from unless you are planning to buy Windows 98! also to avoid viruses you want to avoid upgrades, create a clean new full install.).

I made an error purchasing my 64bit AMD + mobo, if I had bought a different one I would have got twice the memspeed via 2 identical DIMMs.

My cheap pre-built tower PC had a Celeron, CD-writer but DVD read only, weak PSU, pre-installed untransferrable Windows XP Home Edition, 40G drive, no gfx card, 256MB DIMM, bugged USB2 controller. I soon replaced the DVD-ROM drive by 2 DVD writer drives, replaced the PSU with a 550W one, bought 2 120G drives, and bought an ATI Radeon 9800 that is maybe 320 of h/w.

Look out for the television adverts for bargain price PCs, those PCs are total rubbish, dont even think about it!

So the A1's price isnt too severe, whatever computer you get I think its expensive. People sometimes talk about cheap PC's but those use cheap low grade parts eg they usually use Celeron CPUs, the optical drive probably wont be a DVD writer, and you get Windows cheap because it cannot be transferred to another mobo. So you are stuck with Windows XP on your cheapo mobo. In the end it is more expensive to buy a cheap PC because you'll soon start upgrading everything in the system. If you want to upgrade your CPU you will probably have to upgrade the mobo as well which means you have to buy the full XP at 150 instead of the cheap pre-installed XP.