mat6013@DMZRZU71.BITNET (08/28/87)
To see why an exchange like
$FD8E: LDA #$8D
BNE ... -> BRA ...
makes high sense look at the following example:
Go into Applesoft mode (prompt ']') and try a "LIST n", 43776a <= n <= 44031b,
a and b are arbitrary strings of at least one digit. What you expect is a
?SYNTAX ERROR because the numbers are far beyond 63999, the allowed maximum;
but A/S will BReaK into the monitor ! This is because a conditional branch is
misused as an unconditional one. The code responsible for this is:
...
$D981: JMP $DEC9 ;signal S/N err
...
$D9F4: CMP #$AB ;GOTO token
BNE $D981 ;should be a BRA (*only*) when coming from $DA1E
;but the line numbers in the range shown above
;break this assumption !
...
$DA0C: LINGET ... ;This is the start of a routine which convertes
;line numbers from the BASIC text (string
;representation with number base 10) to two byte
;binary integers. Allowed range is 0-63999.
...
$DA1E: BCS $D9F4 ;error exit if out of range; high byte of number
;processed so far in accu
Terrible things occur at $D9F4 when the branch "always" is not taken
(especially a PLA with no counterpart and a RTS).
So, whenever a branch is an unconditional one a BRA should be used if
applicable; this makes the code much clearer and saver. (Software Engineering
isn't incompatible with assembly language ...)
Matthias Kapffer
<MAT6013@DMZRZU71.BITNET>