Re: [cc65] Atari tgi update

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-11-11 17:18:56
On Wed, Nov 11, 2009 at 07:46:29AM -0800, Fatih Ayg√ľn wrote:
> I agree in principle. But, for atari, lack of memory points to a very specific (and probably
> common) problem, the fact that the user forgot to set __RESERVED_MEMORY__ when
> linking. A separate code for NO_IOCB can save some people hours of debugging. What
> about a platform dependent error code? tgi_geterror can return something like
> TGI_ERROR_PLATFORM and tgi_getplatformspecificerror can return the appropriate platform
> specific error code, which are already a part of the library.

I have to admit that I hate the idea of having platform specific error codes
in TGI. If every single platform defines its own error codes, how is a
programmer supposed to handle that, when writing portable programs? It will
also increase code size for the program itself, which needs to check for every
platform dependent error code. It will increase code size for the library,
which must map all these error codes to strings.

When loading the drivers, there's a lot that may go wrong. The device may not
present, the library may be out of file descriptors, the driver may not be on
disk, there may not be enough memory to load the driver or whatever. All this
maps to TGI_ERR_CANNOT_LOAD - and has not been a problem until now. So I'm
sure the "saves hours of debugging" argument is greatly exaggerated.

Using a platform dependent error function just complicates things and adds
another return value that has to be checked. How bloated will we want the API
to be? The Atari is already the platform that generates the biggest
executables, and I don't want to make this the general policy:

-----------------------------------------------------------------------------
uz@trixie:~/src/cc65/test$ cat test.c
int main ()
{
    return 0;
}

uz@trixie:~/src/cc65/test$ for sys in apple2 atari atmos c128 c16 c64 plus4
vic20; do make -s SYS=$sys clean all; echo -en "$sys:\t"; ls -l test; done
apple2: -rw-r--r-- 1 uz uz 480 2009-11-11 17:14 test
atari:  -rw-r--r-- 1 uz uz 553 2009-11-11 17:14 test
atmos:  -rw-r--r-- 1 uz uz 230 2009-11-11 17:14 test
c128:   -rw-r--r-- 1 uz uz 346 2009-11-11 17:14 test
c16:    -rw-r--r-- 1 uz uz 322 2009-11-11 17:14 test
c64:    -rw-r--r-- 1 uz uz 331 2009-11-11 17:14 test
plus4:  -rw-r--r-- 1 uz uz 359 2009-11-11 17:14 test
vic20:  -rw-r--r-- 1 uz uz 313 2009-11-11 17:14 test

uz@trixie:~/src/cc65/test$ cat test.c
#include <stdio.h>

int main ()
{
    printf ("Hello world!\n");
    return 0;
}

uz@trixie:~/src/cc65/test$ for sys in apple2 atari atmos c128 c16 c64 plus4
vic20; do make -s SYS=$sys clean all; echo -en "$sys:\t"; ls -l test; done
apple2: -rw-r--r-- 1 uz uz 2956 2009-11-11 17:14 test
atari:  -rw-r--r-- 1 uz uz 3273 2009-11-11 17:14 test
atmos:  -rw-r--r-- 1 uz uz 2478 2009-11-11 17:14 test
c128:   -rw-r--r-- 1 uz uz 2699 2009-11-11 17:14 test
c16:    -rw-r--r-- 1 uz uz 2675 2009-11-11 17:14 test
c64:    -rw-r--r-- 1 uz uz 2684 2009-11-11 17:14 test
plus4:  -rw-r--r-- 1 uz uz 2759 2009-11-11 17:14 test
vic20:  -rw-r--r-- 1 uz uz 2666 2009-11-11 17:14 test
-----------------------------------------------------------------------------

> Unfortunately I get "Constant expression expected" when I try to use normal constants
> with .if directive. I would love to be able to use normal constants if it's feasible and reasonable to
> let the .if and similar directives could use them. I hate defines too :)

Within local scopes, you must use the global namespace designator (::) to
explicitly address symbols in the global namespace. In a local scope, when a
symbol is referenced that wasn't defined in that scope before, the assembler
cannot decide at that point if a local definition will follow, or if the
global symbol should be used. It has to delay that decision until end of
assembly. For operations that control code generation, like .res, .if or
similar, delaying the decision is not possible so the assembler expects an
expression that resolves to something constant at that point of assembly. If
you explictly specify that you want the symbol from the global namespace using
::symbol, the error message will go away.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Nov 11 17:19:04 2009

This archive was generated by hypermail 2.1.8 : 2009-11-11 17:19:07 CET