Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

machine code loader or assembler

14 views
Skip to first unread message

Ian

unread,
Aug 15, 2001, 9:51:18 AM8/15/01
to
I was wondering how people wrote games. On the trail to this knowledge I
discovered a machine code loader in basic, and also z80 assemblers.

Which is the more popular, and why?

I am sadly interested in this stuff, wonder if anyone can give me any info
on it.

Thanks


LCD

unread,
Aug 15, 2001, 12:04:48 PM8/15/01
to

Ian schrieb:

mc loader in basic is just for input of hexadecimal or decimal numbers
into memory, for example: printed listing in a magazine.
z80 assembler works with mnemonics, some kind of advanced orders,
these are then transformet at compilation time into hexadecimal or
decimal numbers to print them out ;-). The mnemonics and what they do
is easier to learn, hexadecimal or decimal code is easier to input.
Example:
RET=201
CALL xx=205,L,H (L=Low, H= High, the formula is: H*256+L)
If you want to write your own games, forget mc loader, assembler is
the true coding language.

/LCD

Chris Cowley

unread,
Aug 16, 2001, 7:21:56 AM8/16/01
to
On Wed, 15 Aug 2001 14:51:18 +0100, "Ian" <M.R.D...@btinternet.com>
wrote:

You really need a Z80 assembler if you're writing a sizable program such
as a commercial-quality game (says me, who's never written a
commercial-quality game in me life). Some beardy wierdy types will tell
you that they wrote ultra-efficient 128K mega-games entirely in hex with
their eyes shut, but they're all KNOWN LIARs.

You can get away with writing small routines in hex without too many
headaches, but as soon as you start getting into the realms of having a
few sub-routines and look-up tables, it becomes much easier to use an
assembler, even if you know the hex values of all the instructions you
need to use off by heart. The reason is that you can mess around with
the size of subroutines in an assembler listing, and move routines,
variables, and look-up tables from one location to another without
having to manually recalculate the offsets for relative jump
instructions (which, if you're anything like me, you almost always get
wrong by one or two bytes).
--
Tel: +44 (0)20 8547 2304 |"The three principal virtues of a programmer are
Fax: +44 (0)20 8547 2305 | Laziness, Impatience, and Hubris".
http://www.grok.co.uk/ | Larry Wall, Perl Programmers Reference, p.6

Steve Jewkes

unread,
Aug 16, 2001, 10:13:13 AM8/16/01
to
"Chris Cowley" wrote in message:

> Some beardy wierdy types will tell
> you that they wrote ultra-efficient 128K mega-games entirely in hex with
> their eyes shut, but they're all KNOWN LIARs.

Just briefly delurking for a moment....

Hi Chris,

Sorry, but I couldn't resist forwarding on your comments about coding in hex
to my boss to see his reaction (seeing as he wrote a few 8-bit games all
those years ago).

He's given me permission to post his reply to redress the view that
programmers who write entire games in hex are "known liars" (all in good fun
of course). :-)

Actually, his reply's got some interesting info about how some of those
titles did get developed.

Cheers,
Steve Jewkes

-< Message begins >-

> Some beardy wierdy types will tell
> you that they wrote ultra-efficient 128K
> mega-games entirely in hex with their
> eyes shut, but they're all KNOWN LIARs.

I'll take issue with you right there. I wrote a few games in hex on my ZX81,
for my own amusement, and got quite good at doing hex coding of Z80 machine
code, to the point where I didn't actually have to write down the mnemonics.
I managed to graduate this "style" of coding to my first commercial project.

Although slightly off-topic for a Sinclair newsgroup, over the course of
1985 I wrote the Graphic Adventure Creator on an Amstrad (which was also Z80
based) entirely using a hex loader. This was not due to any beardiness (1985
was bumfluff time for me) or weirdiness (for once) but simply because I was
a poor student and couldn't actually afford an assembler.

> You can get away with writing small routines in hex without too many
> headaches, but as soon as you start getting into the realms
> of having a few sub-routines and look-up tables, it becomes
> much easier to use an assembler

No dispute there. Doing this in hex was in hindsight a complete and utter
bastard. Here's why:

> [In assembler] you can mess around with the size of subroutines [...]

I couldn't. If I wanted to extend a routine I had two choices - either move
it to the end of the code (freeing up the previously used bytes) or tack a
jump onto the end and put the rest of the routine at the end of the code.

Changes to the code usually involved either strategic use of NOPs, rewriting
or, again, tacking a patch routine onto the end of the code. This involved
taking 3 bytes out of the main code, tacking in a jump to the end, where
those 3 bytes were then added together with the patch, and a jump back.
Example:

...
0440: 2A 03 01 ld hl, ($103) ; oops! forgot to ld a,(hl)
0443: 11 00 00 ld de,0
...

becomes:

...
0440: C3 A0 41 jmp Patch41A0
0443: 11 00 00 ld de,0
...

...
41A0: 2A 03 01 ld hl,($103)
41A3: 7E ld a,(hl)
41A4: C3 43 04 jmp $0443
...

Blimey. 15 years later and I can still do this from memory. My memory
therefore needs a good clearout.

> [...] to manually recalculate the offsets for relative jump


> instructions (which, if you're anything like me, you almost
> always get wrong by one or two bytes).

After a couple of months, you get very, very adept at counting backwards in
hex. "FF,E,D,C,B,A,9,8,7,6,5,4,3,2,1,0,EF,E,D,C,B. Aha. EB.". See, I was
right.

Worst of all, when the time came for others to port the thing onto the
Spectrum, Commode and BBC, I then had to write a disassembler (in hex) and
spent the best part of a month fixing up the patches in a text editor and
commenting the code printout in pencil. And there was a bug in the
disassembler that meant that IX and IY instructions weren't handled
properly.

Of course, I've learned my lesson now, and use C++ and a Big Computer (tm)
to code stuff. But I still long for the old, nostalgic days of the ZX81,
when men were real men, etc.


Actually, no I don't, it was a complete pig. But it made you think terribly
hard about how your code worked and what went into it.

Sean Ellis

-< Message ends >-


Adam Short

unread,
Aug 16, 2001, 11:13:31 AM8/16/01
to
Steve Jewkess bullets cannot harm me, my wings are like a shield of steel

> Sorry, but I couldn't resist forwarding on your comments about coding
> in hex to my boss to see his reaction (seeing as he wrote a few 8-bit
> games all those years ago).
>
> He's given me permission to post his reply to redress the view that
> programmers who write entire games in hex are "known liars" (all in
> good fun of course). :-)
>
> Actually, his reply's got some interesting info about how some of those
> titles did get developed.

<snip a hell of a lot of frightening stuff>

Steve, your boss is as mad as fruitcake and twice as nutty as squirrel pie.
I usually hate uber-gurus because of their superiority to my own dumb self
(I'm a product of a broken generation, my morals are not my fault), but I
have to admit, that level of adeptitude (I made it up, do you like it?) in
the face of z80 adversity demands respect.

Respect Steves boss!

/me does the "we're not worthy" thing.


--
"CanYouPleaseHelpMeToFixTheSpaceBarOnMyKeyboard?" - Tech support email.

Chris Cowley

unread,
Aug 16, 2001, 12:05:49 PM8/16/01
to
On Thu, 16 Aug 2001 15:13:13 +0100, "Steve Jewkes"
<Steve...@hotmail.com> wrote:

>Sorry, but I couldn't resist forwarding on your comments about coding in hex
>to my boss to see his reaction (seeing as he wrote a few 8-bit games all
>those years ago).
>
>He's given me permission to post his reply to redress the view that
>programmers who write entire games in hex are "known liars" (all in good fun
>of course). :-)

Ah but he is, by definition, a KNOWN LIAR and therefore his comments
must be entirely dismissed outright...

Oh, okay then, I'll admit he might actually be telling truth. Thanks for
the interesting follow-up. I remember buying the speccy version of GAC
at a computer show and using it to write several quarter-finished
adventures games on me speccy (I can still picture those distinctive
green octagons that were used to draw the map on).

I also recall poke-ing machine code routines into REM statements on my
ZX81, and sulking for hours afterwards when I lost everything because I
ran them without saving and I'd got loads of the jump offsets
wrong...Bastard bloody things.
--
Chris Cowley http://www.grok.co.uk/

USER ERROR: Replace user and press any key to continue...

Steve Jewkes

unread,
Aug 17, 2001, 11:24:07 AM8/17/01
to
"Adam Short" wrote in message

> <snip a hell of a lot of frightening stuff>
>
> Steve, your boss is as mad as fruitcake and twice as nutty as squirrel
pie.
> I usually hate uber-gurus because of their superiority to my own dumb self
> (I'm a product of a broken generation, my morals are not my fault), but I
> have to admit, that level of adeptitude (I made it up, do you like it?) in
> the face of z80 adversity demands respect.
>
> Respect Steves boss!
>
> /me does the "we're not worthy" thing.
>

I often feel unworthy in this place! There are several people from the old
8/16 bit days of Incentive Software here and they're all far too intelligent
for their own good. Oh well, at least they let me work here - after all
someone needs to sweep the floors and clean the coffee mugs. :-)

==
SteveJ


Steve Jewkes

unread,
Aug 17, 2001, 11:32:56 AM8/17/01
to
"Chris Cowley" wrote in message >
> Ah but he is, by definition, a KNOWN LIAR and therefore his comments
> must be entirely dismissed outright...
>
> Oh, okay then, I'll admit he might actually be telling truth. Thanks for
> the interesting follow-up. I remember buying the speccy version of GAC
> at a computer show and using it to write several quarter-finished
> adventures games on me speccy (I can still picture those distinctive
> green octagons that were used to draw the map on).

I still think "KNOWN LIAR" is a top phrase and I shall be using it often.
It'll help me win many a meeting argument. :-)

> I also recall poke-ing machine code routines into REM statements on my
> ZX81, and sulking for hours afterwards when I lost everything because I
> ran them without saving and I'd got loads of the jump offsets
> wrong...Bastard bloody things.

I could never get the hang of machine code programming on the Speccy. I
remember accessing the location of the draw routine in ROM via some simple
machine code (I noticed the routine listed in the back of manual). I naively
thought that it would be super fast. Imagine my disappointment when it
appeared to be as fast as the one in basic. Took a while for the penny to
drop there. :-)

Cheers,
==
SteveJ


Sean Ellis

unread,
Aug 19, 2001, 5:58:21 PM8/19/01
to
On Fri, 17 Aug 2001 16:32:56 +0100, "Steve Jewkes"
<Steve...@hotmail.com> wrote:

>I still think "KNOWN LIAR" is a top phrase and I shall be using it often.
>It'll help me win many a meeting argument. :-)

Only if your boss doesn't read this newsgroup, Mr Jewkes :-)

Steve Jewkes

unread,
Aug 20, 2001, 4:06:50 AM8/20/01
to
"Sean Ellis" <sean...@nospamplease.ntlworld.com> wrote in message
news:aid0otkcld7rpds08...@4ax.com...

Oh feck. :)

==
SteveJ


0 new messages