Re: Source codes (3)

From: Spiro Trikaliotis <ml-cbmhackers_at_trikaliotis.net>
Date: Fri, 2 Jan 2015 23:17:38 +0100
Message-ID: <20150102221738.GG4746@hermes.local.trikaliotis.net>
Hi Ruud,

* On Thu, Jan 01, 2015 at 11:59:54AM +0100 Ruud@Baltissen.org wrote:
 
> A simple branche:
> 
> .if Version=4				; 1540
> ;				      1540
> ;
> ;	This source code generates the ROM for the 1540 in the address
> .el
> ;				      1541
> ;
> ;	This source code generates the ROM for the 1541 in the address
> .ei

For ca65:

.if Version=4
.else
.endif

> A branch with more than one value:
> 
> .if Version=5 | Version=6 | Version=7

For ca65:
.if (Version=5) .OR (Version=6) .OR (Version=7)

similarly, .AND

(I am not sure if the paranthesis are needed; I am using them always in
preprocessors, as I have been bitten too many times with different ones.
Here, the conditionals are similar to a preprocessor from my point of
view.)

 
> A nested one:
> 
> .if Version=7				; JiffyDOS 6.01
> .tz 'JIFFYDOS 5.0 1541'
> .el
> .if Version=4				; 1540
> .tz 'CBM DOS V2.6 V170'
> .el
> .tz 'CBM DOS V2.6 1541'
> .ei
> .ei

For ca65, this can be done easier with ".elseif" instead of nesting
".else" and ".if":

.if Version=7
...
.elseif Version=4
...
.else
...
.endif

In this particular case, though, I would define a string RESET_STRING as
"JIFFYDOS 5.0 1541", "CBM DOS V2.6 V170", or "CBM DOS V2.6 1541" in the
headers, and just issue the string here instead of using conditionals.
(I have not done this consequently in my sources, but I am working to
rework that part)

That's because at some point, you end with something like:

.if CompileDrive >= DRIVE_1571CR
        htasc_floppy_error      "CBM DOS V3.1 1571"
.elseif CompileDrive >= DRIVE_1571
        htasc_floppy_error      "CBM DOS V3.0 1571"
.elseif CompileDrive >= DRIVE_1570
        htasc_floppy_error      "CBM DOS V3.0 1570"
.elseif CompileDrive >= DRIVE_1541
        htasc_floppy_error      "CBM DOS V2.6 1541"
.elseif CompileDrive >= DRIVE_1540
        htasc_floppy_error      "CBM DOS V2.6 V170"
.else
        htasc_floppy_error      "CBM DOS V2.6 2031"
.endif

Note the ">="; otherwise, I would have had to add even more cases or add
them with .OR statements

Regards,
Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/

       Message was sent through the cbm-hackers mailing list
Received on 2015-01-03 00:00:03

Archive generated by hypermail 2.2.0.