Re: Writing Assembler!

9 Jun 1997 00:53:52 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Writing Assembler! (1997-05-17)
Re: Writing Assembler! (Mr J R Hall) (1997-05-22)
Re: Writing Assembler! (JUKKA) (1997-05-22)
Re: Writing Assembler! (Charles Fiterman) (1997-05-22)
Re: Writing Assembler! (1997-05-25)
Re: Writing Assembler! (1997-05-25)
Re: Writing Assembler! (JUKKA) (1997-06-09)
Re: Writing Assembler! (1997-06-09)
Re: Writing Assembler! (1997-06-09)
Re: Writing Assembler! (1997-06-11)
Re: Writing Assembler! (Cliff Click) (1997-06-11)
Re: Writing Assembler! (1997-06-13)
Re: Writing Assembler! (1997-06-13)
[5 later articles]
| List of all articles for this month |

From: JUKKA <>
Newsgroups: comp.compilers
Date: 9 Jun 1997 00:53:52 -0400
Organization: GOOD
References: 97-05-156 97-05-245 97-05-289
Keywords: assembler, syntax

> >You can use lot of from compiler books when making the assembler
> >scanner and parser. In assemblers you should treat also end of lines
> >and spaces as tokens and not just skip them.
> Why that ? Spaces does not seem to mean anything for asm... Even
> worse: since the number of possible instructions and fields are so
> limited why not use a lookup table with all of it ? Anyway I am using
> it in the assembler I am building in QBASIC and it seems to work out
> great. Scanning and parsing seems to me a waste in this case ...


Spaces and eol's do in some assembler have meaning! For example the
old IBM assembler format which was copied to Motorola assemblers
has the following rules:

1. An identifier starting a line is a label. There after there may be a
      mnemonic or not.

2. If a space starts a line there is no label and the next identifier is
        a mnemonic.

3. A star "*" starting a line is a comment line.


* This is a comment
LABEL MOV R0,R1 Any comment text

So you have to know where is a start of a new line. You know if you
also know where was the last eol. Then you have to know if there is
a space in the begining of the line or not .. so you have to have also
the space token.

<EOL><IDENT> -> IDENT is a label
<EOL><SPACE><IDENT> -> IDENT is a mnemonic

But there are also other syntaxes .. they maybe don't need the spaces
and eols. Some assembly languages say that a label have to be followed
by a ":" .. so you know from that if it is a label or a mnemonic. You could
also check all the mnemonics and if the ident is not there .. it must be a

But the eol is anyway meaningfull because assembly is always line
oriented. But if you already read everything as lines .. you already have
there a "pseudo eol" token.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.