How and why to use a cross-assembler


Last updated Aug 30 2017. Edited by Herb Johnson, (c) Herb Johnson, except for content written by others. Contact Herb at www.retrotechnology.com, an email address is on that page..

In Aug 2017, a person asked in an email discussion group, about using a cross-assembler like the ones I offer, on some particular program, to run on some particular hardware he/she was about to build. I think my general answer may be helpful to other people who find "my" crossassemblers. I'm adding this advice to my cross-assembler Web pages. As my old microcomputer world gets older, I find I have to explain more and more background - as I'm about to describe - to 21st century people who are entirely foreign to the 20th century microcomputing I represent on my Web site. - Herb

Question: what's broken here?

I'm looking at building [an 1802 microcomputer board], but I want to make sure I can use something on it if I do build it. I'm trying to compile some assembler code using [an 1802 cross assembler I found], but am having trouble. The [large program found on the board's Web site] gets over 100 errors. Also, I downloaded a [Windows based 1802 emulator to test-run the code].

[Person shows listing output from the cross-assembler, with like 200 errors for 200 lines or more.]

Can someone help? It looks like some configuration problem. [Later on,] I looked at Herb Johnson's website, ... but didn't see anything that I thought could help me in this. Lots of other good stuff. I also tried assembling with his A18 assembler, but it just turned most commands into NOPs, even the CALL commands, which doesn't look right to me. I don't have much experience with assembler, though.

Some ideas about assembly language and assemblers

Hello, I'm Herb Johnson. Thanks for the compliments on my Web site. I offer an 1802 cross assembler called "A18", for the COSMAC 1802. The Web page and the manual with A18, describe what that assembler is about, where it comes from. But, my Web site doesn't have "how to program" information like cosmacelf.com and other Web sites - because they do that already.

Here's the thing, in a nutshell. You want to use the tools you've described - an assembly language program, a cross-assembler, a ELF 1802 emulator. In my humble but experienced opinion, you need to have more than a few clues about "assembly language", and about a microprocessor specifically the 1802, before you will find them useful, and know what to do when they don't work as you expect. And, you'll need to recognize how non-standard "assembly language" is, across the 20th century microprocessor world of the ELF-class 1802 computer you want to work upon. And so you have two choices: either find the original software tools to run that set of programs you want to run; or learn how to change those programs to fit the tools you use.

Here's my suggested general strategy

1) read about the 1802 op-codes and how it works as a microprocessor running instructions.

2) learn a bit more about the 1802 instruction set, poke at a few TINY programs. Make those work, even if only by hand on paper, or on an emulator.

3) Then look up a couple of cross-assemblers; read their manuals; try to assemble those tiny programs.

4) Then choose a cross-assembler you think is "compatible" with your large program; or make changes to the code you throw at that cross assembler, to make it compatible.

Where do you find "the opcodes", the "tiny programs", "cross-assemblers"?Look at the Web site where you got the hardware and software; look at Web links that site provides. And Web search is your friend.

Briefly: assembly language has a syntax - words and symbols, in some order on a line or in a file, which have specific effects. Of course that includes the assembler's instruction set (op codes) and whatever data those instructions need. Even for the same microprocessor, the syntax of someone's assembler may not match someone else's assembler. This was normal in the 20th century era of microprocessors. Why? Let's just say IBM and Apple and Intel had not dominated personal computing yet.

For the COSMAC 1802, and my A18 cross assembler, one Web site with how-to COSMAC information is cosmacelf.com and their list of 1802 documents.

Why am I telling you this?

I haven't described this strategy and background on my Web site - how to learn to program microprocessors, how to use assemblers, what are the differences - because other Web sites and other documents on those sites, accomplish that task. I provide a couple of cross-assemblers as a matter of convenience, and because they are simple C-sourced programs "about" microprocessors. (See my notes at the end.)

Web sites like cosmacelf.com's Web page of how-to books from the 1802 early-days is one of many Web site resources. The 1802 chip is unchanged, so the old-days information still works. MOre Web searching, will find more 20th century 1802 resources. They will all be of a kind - and you'll have to learn something about the 1802 and about assembly language, to make better use of them, and "my" or someone else's cross-assembler.

The same strategy applies, to any other vintage microprocessor of the 1970's and early 80's. With IBM PC's and Apple II's and Macs, and "branded" systems from Atari, Commodore, Tandy, and so on - they each have their own "world" of Web sites and programs and asseemblers and compilers. You'll have to find that "world" on the Web or among actual human beings. ;)

What does all this have to do with you and your hardware and software?

So: the "reason" you weren't able to assemble the large ASM file without massive errors, is because you expected to find the "magic" cross-assembler which it was written for; or expected all 1802 cross-assemblers to be "the same". Or some simple "configuration fix" to resolve the problem. Well - they aren't all the same, and it's challenging to choose among them to fit some specific program. And you can't often tweak a magic symbol to "fix" bad syntax. What I've described, is normal for 20th century microcomputing. again: It was an era before "standards", including standard ways to write assembly-language programs. And if the hardware and software is 20th century, you'll have to know how it worked back then, to use it today.

But among cross-assemblers and ASM programs, the differences you find won't make sense - you won't be able to edit the ASM file, or find the magic assembler for it - unless you have some clues about assemblers, and about the 1802. That's why I suggested the "general strategy" in the order I described.

And if you the reader, have interest in another processor? Same reasoning applies.

Does this even apply to you?

Finally, my apologies. I don't know the person reading this. I don't know your background or history, or patience. But I'm guessing this: if using 8-bit assemblers is strange to you, you are probably from the 21st century. If the above advice doesn't apply to you, that's certainly your call, and you have my apologies. But I'd give the same advice to a master of 21st century coding, who have never seen an assembler program before; and to a novice to 20th century microcomputers. And one could be both.

As I said at the start of this Web document, more time is passing, from the 1970's and 80's days of early microprocessor use and the beginnings of what became "personal computing". So that experience is more and more foreign to people living in the 21st century, with different expectations about "programming" little computers. It was a different world, it requires more explanation to understand it. I believe one cannot understand and use - and poke at and enjoy - 20th century microcomputers without that background in mind.

- Herb Johnson, retrotechnology.com

Notes

One reason for c-sourced cross assemblers, is so some programmer-person (like me!), can add or change a feature in a cross-assembler. They can do that, with the C source, and tell me (if they want) what they did and why. That's happened.


Contact information:
Herb Johnson
New Jersey, USA

This page and edited content is copyright Herb Johnson (c) 2017. Copyright of other contents beyond brief quotes, is held by authors of that content. Contact Herb at www.retrotechnology.com, an email address is available on that page..