On Sun, 22 Apr 2018 14:16:06 +0100, Gareth's Downstairs Computer
declaimed the following:
>
>The sort of ambiguities that I seek are the two different ways
>of adding R3 to R2 ...
>
>ADD R2,R2,R3
>
>or
>
>Add R2,R3,R2
>
Unless there's a significant timing difference I'd probably pick the
first -- as mentally I still think of 2-argument operations and the first
looks closer to "add r3 to r2".
But unless you are adding a lot of register optimization to variable
allocations, a high-level statement like
varA = varA + varB
is going to turn into (pseudo-code, I'm not going to dig up an ARM
instruction table)
LD r2,varA
LD r3,varB
ADD r2,r2,r3
STO r2,varA
whilst
varA = varB + varA
might become
LD r2,varB
LD r3,varA
ADD r3,r2,r3
STO r3,varA
just due to the order of assigning free registers to the variables of the
expression first, and only later handling the saving of the result.
OR, using an extra register which you dedicate as an accumulator
LD r2,varX
LD r3,varY
ADD r1,r2,r3
STO r1,varX
(for chained calculations you'd then repeat the "accumulator" as the first
source)
>
>OK, can't compile completely as there has to be some symbol table
>info somewhere so that a variable defined as, eg, CurrentArrayIndex
>does not list back as V32 :-)
>
Hence why early BASIC only supported variable names of the form:
[A..Z][|0..9], along with data type suffixes (originally -- no
suffix->numeric, $->string; later adding codes for integer, float, double).
Only 26*11 => 286 variable names maximum *4 (type codes) => 1144
possible combinations; easily regenerated from a simple numeric index. Only
takes 11-bits to encode the entire variable space, leaving 5 bits to encode
other indicators (use one bit to indicate byte-code with rest indexing the
keyword/operator table)... Oh -- a bit to indicate Array, but as I recall,
Arrays still used the core variable name space.
Use one bit to indicate "line number" and you have 32K lines to
identify -- that's a pretty large program in those days. But the only way
you're going to encode line numbers into the object file is going to
require either a tag-on symbol table or some wasteful
BR PC+2
DATA
(branch program counter relative to jump over the line number itself)
Many years ago there was a book "Implementing BASICs" available (along
with one for "Threaded Interpreted Languages") -- but Amazon searches find
nothing for either subject.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|