Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Program to check nested IF's ??

3 views
Skip to first unread message

Old-Timer

unread,
Nov 12, 2005, 9:05:07 PM11/12/05
to

Help......

I have been trying to assemble ZCPR4 (4.0E) which I found on the
Internet.
Im using Al Hawley's ZMAC (ver 1.7 4/9/93) running under MYZ80 (on a
PC).
I was getting an error indicating that more than 8 levels of nested
IF's were used.
I found two places in the Z80 source where ENDIF's were missing from
"IF BANKED"
statements. Now I get a BALANCE error when the program assembles the
"END"
statement, indicating there are more unmatched IF and ENDIF's or
unclosed Macros.

Has anyone got a program that will check or indicate the nesting of
IF's and
Macros within a Z80 source program to check for proper balance.
I remember having one once for checking "{" and "}" within a BDS "C"
program and wondered
if a simular program was available for checking Z80 source code.

Anyone know of such a program ?????
Thanks
Old-Timer (John)

Leor Zolman

unread,
Nov 13, 2005, 9:32:34 AM11/13/05
to

Well, any time I've ever needed something like that, I've just written
it... ;-)
-leor

nos...@nouce.bellatlantic.net

unread,
Nov 13, 2005, 6:25:20 PM11/13/05
to
On 12 Nov 2005 18:05:07 -0800, "Old-Timer" <jdg...@juno.com> wrote:

>
>Help......
>
>I have been trying to assemble ZCPR4 (4.0E) which I found on the
>Internet.
>Im using Al Hawley's ZMAC (ver 1.7 4/9/93) running under MYZ80 (on a
>PC).
>I was getting an error indicating that more than 8 levels of nested
>IF's were used.
>I found two places in the Z80 source where ENDIF's were missing from
>"IF BANKED"
>statements. Now I get a BALANCE error when the program assembles the
>"END"
>statement, indicating there are more unmatched IF and ENDIF's or
>unclosed Macros.

Sounds like the source has had lines either truncated or worse
missing. Ran into some code like that once and it turned out the
source was missing a line every 2000 chars or so rendering it
unuseable.

>Has anyone got a program that will check or indicate the nesting of
>IF's and
>Macros within a Z80 source program to check for proper balance.
>I remember having one once for checking "{" and "}" within a BDS "C"
>program and wondered
>if a simular program was available for checking Z80 source code.
>
>Anyone know of such a program ?????
>Thanks
>Old-Timer (John)

While it's a good programming project to have the computer do it.
However, I've found a well calibrated mark one eyeball and basic
counting skills are enough. Besides once you know that you still
have to fix it without breaking the code.


Allison

Old-Timer

unread,
Nov 15, 2005, 11:02:22 AM11/15/05
to
I started to write a program to do this, but it quickly became very
complicated. I then used my VEDIT editor and combined all the modules
into one 6300 line file. Since most of the IF- ENDIF groups were marked
by their comments, I deleted all the completed groups and most of the
code and comments that were outside of the IF-ENDIF groups.
The end result was one IF BANKED statement that had no matching ENDIF.
I inserted the ENDIF where I thought it should belong and behold the
program assembled. Now I just have a minor problem with the .PRINTX
statements that display the code size and free space at the end of the
assembly.
Thanks...
Old-Timer (John)

pe...@nospam.demon.co.uk

unread,
Nov 15, 2005, 12:02:18 PM11/15/05
to
In article <1132070542....@z14g2000cwz.googlegroups.com>
jdg...@juno.com "Old-Timer" writes:

Damn! I already had a sort-of preprocessor program that I wrote
for conditional compilation of Clipper (summer87) source, and
just today reworked it to handle asm files. I guess you no
longer need it now :-(

Pete (another Old Timer!)
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."

Hal

unread,
Nov 15, 2005, 2:14:15 PM11/15/05
to
On 15 Nov 2005 08:02:22 -0800
"Old-Timer" <jdg...@juno.com> wrote:

> The end result was one IF BANKED statement that had no matching ENDIF.
> I inserted the ENDIF where I thought it should belong and behold the
> program assembled. Now I just have a minor problem with the .PRINTX
> statements that display the code size and free space at the end of the
> assembly.

John, could you please tell me where you had to place this missing
directive so I can see if I had that fixed in a later (4.1) version a
few years ago? TIA.

Hal

Old-Timer

unread,
Nov 15, 2005, 4:20:10 PM11/15/05
to
Pete:
I found it very complicated to try a reason out a computer algorithum
to check the IF-ENDIF matching. I started with one that was oriented
toward a preprocessor in the "C" language. It used #if and #endif, but
always searched for the # sign before the preprocessor statement. Even
if I found there was a mismatch, it would have been very difficult to
determine where the mismatch started and where the ENDIF statement
should be inserted. I guess the human brain is better for looking at
the code and deciding how thing should be.
Im interested in your program. Have you tested it on a complicated
file? The ZCPR4 source program had over 6300 lines and scores of IF's
and ENDIF's.
Old-Timer (John)

pe...@nospam.demon.co.uk

unread,
Nov 16, 2005, 1:51:49 AM11/16/05
to
In article <1132089610....@o13g2000cwo.googlegroups.com>
jdg...@juno.com "Old-Timer" writes:

> Pete:
> I found it very complicated to try a reason out a computer algorithum
> to check the IF-ENDIF matching. I started with one that was oriented
> toward a preprocessor in the "C" language. It used #if and #endif, but
> always searched for the # sign before the preprocessor statement. Even
> if I found there was a mismatch, it would have been very difficult to
> determine where the mismatch started and where the ENDIF statement
> should be inserted. I guess the human brain is better for looking at
> the code and deciding how thing should be.

John:
Even my prog won't do that, but it will report a misplaced ELSE
or ENDIF and a line number (and a missing ENDIF).

> Im interested in your program. Have you tested it on a complicated
> file? The ZCPR4 source program had over 6300 lines and scores of IF's
> and ENDIF's.
> Old-Timer (John)

I just downloaded the source to try it [I found z40esrc.lbr] and
ASMPP fell over in a big heap :-( It needs rather more work to
handle stuff like

IF WHEEL OR WDU OR WPASS OR WPREFIX OR WHLDIR

which like stuff appears all over the source files. I'll have a
go today at beefing it up -- watch this space... (Check the
article headers if you wanr to go to email.)

Pete

0 new messages