From: detlef@dmhh.hanse.de (Detlef Mueller)
Newsgroups: comp.sys.hp48
Subject: Re: <--- need to know basics of machine code progr.
Distribution: world
Date: Sat, 19 Dec 92 04:12:14 GMT

In article <BSON.92Dec17054416@churchy.gnu.ai.mit.edu> bson@gnu.ai.mit.edu (Jan Brittenson) writes:
>In article <snill.4.724533634@dhhalden.no> snill@dhhalden.no (Tor Atle Lunde) writes:
> [..]
>
>In HP syntax, you'd write:
>
>		A=B A
>
>Whereas in AG syntax you'd write:
>
>		move.a	b, a
>
>(I.e. op.f src, dst)
>
>   HP's assembler's grammar also isn't context-free. This means that
>the syntax varies depending on the meaning. For instance, a dash
>(``-'') is a valid symbol character (otherwise they wouldn't be able
>to create symbols such as ``A=B'' above) if the parser is currently
>scanning a symbol name; if it's scanning on the expression level it
>means subtraction. In other grammatical contexts it may mean other
>things, although I'm not sure whether it actually does. You get the
>hint: context-dependent grammars are a bitch to learn. Most research
>in this area in the late 60's singularly concluded that context-free
>grammars are easier to learn and use -- today virtually no grammars
>are context- dependent, and most parser generator tools (such as
>``yacc'') are mostly optimized for context-free grammars, and require
>extensive workarounds otherwise. This is usually a point left ignored
>when people engage in discussions over the respective merits of the
>different syntaxes, which is why I elaborate like this.
>
>   The second big issue is error diagnostics.
> [..]
>		D=A A
>
>   Now, you can't load register D directly from register A. In the
>worst case, the assembler will print ``syntax error'' (we all know
>which junky Basic that helped make a famous man rich used to have
>tendencies in this direction). A slightly better assembler will print
>``unrecognized symbol.'' An even better one will recognize that it's
>an instruction, and print ``unrecognized instruction.'' The best one
>can hope for is an assembler that has a symbol table that is huge
>enough to include all invalid combinations.

Today most assembler programs work on a line base; a line is divided into
three parts (seperated by whitespace), the label field (starts in colum one -
if col one is whitespace, this line don't have a label), the mnemonic field
(including the parameter field) (can also be a macro or control word etc.)
and the comment field. This convention makes detection of illegal or invallid
mnemonic fields very easy.

BTW, the listing for the invallid example above of the HP assembler SASM (PC
based):

Saturn Assembler                                       Sat Dec 19 03:47:27 1992
Ver. 1.56, 12/20/89                                    tst.a          Page    1

*** ERROR: Illegal mnemonic ***
   1 00000         d=a a
Saturn Assembler                                       Sat Dec 19 03:47:27 1992
Ver. 1.56, 12/20/89 Statistics                         tst.a          Page    2

Input Parameters

  Source file name is tst.a

  Listing file name is tst.l

  Object file name is tst.o

  Flags set on command line
    None

Errors

  1 error (line 1)

> [..]
> >   2)        What compiling-programs does one usually use, and where can i get 
> >        it ???
>
>   If you have access to FTP, look in pub/star-1.04.4.tar.Z on
>ftp.ai.mit.edu. The HP kit can be found on wuarchive.wustl.edu.
>
>   If you're a hardcore assembler programmer, I would definitely
>recommend STAR (it's loosely modeled after DEC's Macro-10 and Macro-11

That's the reason why I decided for not using it - you can't get confused
when switching to HPs manemonics ;)

>assemblers); you'll probably find it similar to most other assemblers
>you have used. Use the HP kit if you plan to write System RPL
>programs; I never write System RPL code, except to launch Code objects
>(objects consisting of machine code).

Get the HP kit !!! The SASM doc is very complete; the whole doc gives a good
overview how the 48 is working. If you decide to use the HP mnemos mail me a
short notice, I'll send you a copy of the <-RPL-> library (a sys-RPL
de/compiler and dis/assembler - needs ~50k RAM on a freed card for a full
installation) so you can use the 48 itself for coding.

Well, I've some experience in 680x00, Z80, 6502 and at least 80x86 (urgh) -
IMO the HP Saturn assembler is only another one to learn (I agree that it
is funny :). Why not program a CPU using the mnemonics specified by the
manufactor of this CPU ?

        8-Detlef
--
+------------------------------------+--------------------------------------+
|`What a depressingly stupid machine'|             Detlef Mueller           |
| -- Marvin                          |          detlef@dmhh.hanse.de        |
+------------------------------------+--------------------------------------+