Copy Link
Add to Bookmark
Report
Saxonia Issue 04 Part 025
Intel assembler
By Rumrunner/VOID
l
Ofcourse it had to happen. Since I started an informatics-course at
Høyskolen I Vestfold, I bought first an old pentium2 to do some schoolwork
on, then later a laptop, to make work at the schoolplace easier. Coming
from the Amigascene and being a coder, I had to look into intelassembler
after awhile.
To put it short, I have never seen anything that ugly on computers before,
apart from the Windows openingscreen. Let's start off brutally by comparing
some instructions :
1
move.b (a0),d0 (68000)
mov al,[ebx] (intel)
move.w (a0),d0 (68000)
mov ax,[ebx] (intel)
move.l (a0),d0 (68000)
mov eax,[ebx] (intel)
0
Clearly the intelprocessor's instructionset was never meant to handle
longwords, or doublewords as intel likes to call them. Having a register
ax (wordlength) and referring to al for the low part and ah for the high
part is something I can deal with, but when you have to also use e infront
to make the processor understand that you want the longword, it's too
messy. What will happen when intelprocessors get registers of two
longwords length? My bet is that they will throw in even more letters in
the register names, instead of specifying length in the instruction.
Moving on to comparisons :
1
cmp.b #4,(a0) (68000)
cmp byte [ebx],4 (intel)
cmp.w #4,(a0) (68000)
cmp word [ebx],4 (intel)
cmp.l #4,(a0) (68000)
cmp dword [ebx],4 (intel)
2
The intelinstructionset should really have gone in the thrashcan long time
ago if you ask me. You can work the intel way here, but it looks horrible.
Also, in comparisons, I usually want postincrement. I have not found a way
to do this with intelprocessors yet, and I doubt if it's even supported.
d Where do you want your program to run?
There are differences in the 68000 processorseries that make programs crash
on other processors than it was written for. I'm not thinking of timingloops
here, rather what you can do in user and what you can do in supervisormodes.
Once you get into this, there's really not much you have to consider, I
for one have never had the need of writing to the statusregister in usermode
on 020+. Look at the intelprocessors, and there's lots more to take into
consideration. If you want your program to work on computers back to
486, you only have eight registers to play with :
1 ax, bx, cx, dx, si, di, sp, bp 0
If you use new registers introduced later, things will go down the bog.
It's on one hand excellent that intel introduced new registers, but
even if you lost all compatibility, they should have come up with a new
instructionset at the same time. After all, even though I like the
instructionset on 6502, I don't need it on a longword-processor.
d It is possible to do stuff if you want to, even on intel
One of the first pieces of code I put together on intel was a cgiprogram
for use with the apache webserver. Cgi is rather nice, you can write it
in whatever you want to, from assembled/compiled languages to
scriptlanguages like perl, python, and even yabasic. Php is the easy
alternative today, but even though I like it in some areas, it's not quite
speedy. Things take alot of time, and you shouldn't have to use a new huge
computer to chuck out some simple dynamic webpages to people. I won't
even consider shite like asp and asp.net here, since they are even slower
than php, have ugly syntax, and mostly run on Windowscomputers, even though
you can run asp.net with the module from the mono-project for apache on
unix.
d Tools please
Well, there are no decent assembler for intelcomputers, atleast not that
I have found. The best is perhaps microasm for Windows, but that's out of
the question since I don't run Windows on my computers. (Well I have a small
partition left with the Windows that came preinstalled on my laptop, wonder
when that was last booted). On linux/unix, you have two choices. Either
you can go for the gnu assembler called as, which comes preinstalled on
most linuxes, or you can go for something like nasm. The gnu assembler
has it's own syntax. You see, unlike the 68000-series, there's not just
one way to write intelassembler. The gnu syntax is something like an
"I wish I was an 68000" thingy. They have put length in the instruction,
and also use source,destination instead of destination,source like intel
likes to do. So you could change the examples above a bit and halfway make
it look like it's 68000-assembler. If you have ever written a line of
assembler on Amiga or other 68000-computers, you will laugh however, it
sucks perhaps even more than intel's syntax. By the way, the reason for
making this strange syntax for intelopcodes is supposed to be because
SystemV Unix used this syntax sometime. Then it ofcourse lives on in the
unixworld, as much other stuff that should never be an issue.
Nasm uses the regular intelsyntax, and works more or less as it should,
that's the best I can say about it. It's a commandlineassembler, and as you
know if you have read previous codingarticles from me, I don't like that.
No easy debugging/singlestepping/tracing, memorypeeking/poking or saving
parts of memory to file. Especially when you are new to a processor this is
invaluable.
I recently came across Yasm, another assembler that looks and works just
like Nasm, however, it's a bit better. Atleast it doesn't chuck lots of
junk into your files, like sections containing the name of the assembler
and such. So files get a little smaller, and ofcourse I use it now, both
to get smaller files and also so I won't have to edit my files with a
hexeditor later on. Never will I accept that a junkassembler tucks it's
name in my code.