[WP34s] Assembler question



#8

I guess that's for Neil only. ;-)

I have the problem that I don't understand the system behind having to use a space or not for different commands - let me give you a few expamples:

x[<->] Z   ... space needed
STO[->]Z ... no space allowed
What's the difference here between [<->] and [->], so that the first one requires a space before the argument but not the second one?

And now with the new aliases it's even more confusing, because e.g. the 2nd line would now look like one of these:
STO ->Z   ... space in front of the aliases
STO =>Z
And about [alpha]:
[alpha] a     ... space needed
[alpha]'abc' ... no space allowed
Again, why does [alpha]a without space not work?
[alpha]'a[space]b'  ... ok
[alpha]'a b' ... not ok
No single space possible within a string?

Don't get me wrong: I don't say that these are assembler bugs - I just would like to know and understand when/where a space is needed, because I would prefer to use such commands correctly when writing a program instead of waiting for an assembler error message when compiling.

(especially because the assembler is much slower since these aliases have been implemented - nevertheless a great feature of course!)

Franz


#9

Quote:
I have the problem that I don't understand the system behind having to use a space or not for different commands - let me give you a few expamples:

x[<->] Z   ... space needed
STO[->]Z ... no space allowed

What's the difference here between [<->] and [->], so that the first one requires a space before the argument but not the second one?


The [<->] character is part of the command name whereas the [->] is the separator between the command and its argument. Commands with arguments are separated from their argument by either a space or an indirection arrow, never both. Thus, it is possible to have a command x[<->][->]Z e.g.

This is an artifact of the on screen display where there isn't, in general, enough columns for a space after the indirection arrow. The assembler command list is generated by the same code that renders commands to the dot matrix portion of the display.


As for the rest, they smell like assembler troubles.


- Pauli


#10

Quote:
The [<->] character is part of the command name whereas the [->] is the separator between the command and its argument. Commands with arguments are separated from their argument by either a space or an indirection arrow, never both.

Thanks, that explains already one of my 'problems'. :-)

I've now checked it again in the emulator, but I assume you're using a [narrow-space] between x[<->] and its argument, because it's quite difficult to see a space here in the display.

Franz


#11

I believe the space there is two pixels wide. It used to be wider but got shrunk down to fit more in.

I don't know which is the worse limitation: the six pixels high or the forty three pixels wide. Both are sources of ongoing angst.


- Pauli

#12

Franz,

As you have seen, the assembler recently acquired the ability to use aliases in addition to the original mnemonics. These aliases are easier to use and (usually) more intuitive -- and the tools suite will take them all, old and new (even mixed in the same source!). [There are some examples of them being used in the SVN library directory. They files have names like "8queens_alias.wp34s".]

In order to allow the tool suite to not require continuous maintenance, it was designed to be table-driven from the "wp34s.op" file generated by the C build environment. Because of this, the assembler had little latitude in where a space was placed or not based on the original generation of this table. If there was a space in the table, you needed a space in your code.

Your 1st 2 examples are from the original mnemonic set and the format has always been exactly as you see here -- no change.

I think the newer aliases always use a space to make it more consistent (though I may be wrong).

The next 2 examples are new aliases for indirection. It was decided that the space here made more intuitive sense, especially when coupled with register arithmetic. For example "STO- ->00" would look truly strange as "STO-->00".

Given that the indirection syntax can use any of the following choices:

STO- ->00
STO- >00
STO- =>00
STO- @00

there would be confusion for "STO->00" if the space was not required.

For the alpha, it is almost always better to use the preprocessor to generate these. The preprocessor will handle your "No single space possible within a string?" example with ease:

"put as many spaces as you like!"

These will be converted to "[space]" within the tool and parsed into as many triple or single alpha op-codes as required. (See documentation for more details.)

We cannot (currently) use an undelimited space in the non-preprocessor source because the whitespace is used as delimiters in the "wp34s.op" file and an undelimited space just looks like a token separator to the assembler's "wp34s.op" parser.

As an example of the preprocessor in action, the output for the "put as many..." string is as follows (output edited for clarity):

$ echo "put as many spaces as you like!" > alpha.wp34s
$ wp34s_asm.pl -pp alpha.wp34s -o blah
$ cat wp34s_pp.lst
0001 /* */ [alpha]'put' // "put as many spaces as you like!"
0002 /* */ [alpha]'[space]as'
0003 /* */ [alpha]'[space]ma'
0004 /* */ [alpha]'ny[space]'
0005 /* */ [alpha]'spa'
0006 /* */ [alpha]'ces'
0007 /* */ [alpha]'[space]as'
0008 /* */ [alpha]'[space]yo'
0009 /* */ [alpha]'u[space]l'
0010 /* */ [alpha]'ike'
0011 /* */ [alpha] !
0012 /* */ END

If you want to see what is legal for an op-code, you can run the following command to generate a (BIG!) table of what is valid:

$ wp34s_asm.pl -syntax syntax.tbl

The output will be in the file "syntax.tbl". It may still have some inconsistencies with regard to the [alpha] stuff but it is getting better.

BTW: I don't detect any noticeable slow-down in the tool chain due to the aliases. It could be that this is due to the speed of your relatively ancient Win-98 machine. :-)


#13

Thanks for this detailled explanation, Neil.

The inconsistency between [<->] and [->] (needing a space for the 1st but not for the 2nd) has already been explained by Pauli, and it's not the fault of the assembler. In fact it would even be more logical to put a space before the indirection (i.e. STO [->]X like it works for the alias STO ->X), because this [->] rather belongs to the argument than to the command.

My wish had just been that the assembler would be a bit more tolerant about extra spaces, so it would also accept STO [->]X (or even STO [->] X). But with your method of creating a table of all possible commands I guess this simply won't be possible.

Quote:
BTW: I don't detect any noticeable slow-down in the tool chain due to the aliases. It could be that this is due to the speed of your relatively ancient Win-98 machine. :-)

Well, not only "it could be", but definitely "it is" my old Win98 machine! ;-)

Although the WP34s emulator doesn't run at all on this old notebook, I'm still writing (and compiling) most programs on it. And if I tell you the CPU of this 12 years old notebook (a 400MHz Celeron), you'll understand why I noticed this slow-down.

Before these aliases it took about 5 sec. for a usual compile (just 3 of my programs), after implementing the aliases it has been 15-16 sec., and the biggest shock for me was when you added the 4 possible aliases for [->], then it took so long (31-32 sec.) that I already thought the assembler had crashed. :-(

Of course with your nowadays 'monster machines' (8 cores/3 GHz) you won't notice a difference between 1 or 2 sec. ;-)

Franz


#14

I may be able to explain the [alpha]'a b' problem. A single space just isn't recognized as a valid character, except for the case ' ' which I newly introduced for convenience. It sounds like a good idea to implement it as a special case in the assembler.

Why the slow down? Every alias is just added as an independent entry to the look-up tables. For each possible argument of a command like STO, all possible entries are generated. Adding multiple aliases just adds tons of entries to the lookup table which slows down the assembly notably on slower systems.


Possibly Related Threads...
Thread Author Replies Views Last Post
  WP-34S assembler & constants Marcel Samek 8 304 06-27-2013, 12:27 PM
Last Post: Marcel Samek
  Patch for wp34s assembler Marcel Samek 0 105 06-26-2013, 05:35 PM
Last Post: Marcel Samek
  Simple? programming question [WP34S] Shawn Gibson 3 219 03-15-2013, 11:56 AM
Last Post: Didier Lachieze
  [wp34s] xtal question jerome ibanes 9 393 02-05-2013, 05:35 PM
Last Post: Massimo Gnerucci (Italy)
  [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 156 10-04-2012, 04:59 PM
Last Post: Paul Dale
  HP 71b Assembler Michael Fehlhammer 2 153 09-06-2012, 08:20 AM
Last Post: Michael Fehlhammer
  more question regarding complex operations using complex number on wp34s wildpig 22 650 09-02-2012, 12:54 PM
Last Post: Walter B
  WP34S solver question Reth 22 837 07-13-2012, 06:55 PM
Last Post: Paul Dale
  WP34s Flash Question rgray 18 547 06-19-2012, 03:20 AM
Last Post: Cristian Arezzini
  Another stupid WP34S question Geoff Quickfall 2 158 06-16-2012, 11:21 PM
Last Post: Geoff Quickfall

Forum Jump: