z88dk forums

z80 Development Kit

You are not logged in.

#1 2008-09-07 09:05:09

Dylan Smith
Guest

[Z88dk-users] Assembler pre-processor directives?

Hi all,

I've written a couple of libraries, and I essentially need two versions of
the library - depending on where they are being run.

Essentially, if the code is running in the Spectrum's main RAM, it must
cause a ROM to be paged to make the call to the right ROM. But if the code
is running from another page within the ROM, it shouldn't do the
page/unpage operation.

What I think will be most efficient is doing the equivalent of a C ifdef,
and generating two library binaries, and the program is linked to the
right version of the library, depending on whether it's to run from main
RAM or not. Essentially what I want to do in the ASM file is this:

#ifdef MAINRAM
ld hl, SOCKET
call HLCALL     ; use paging mechanism
#else
call SOCKET     ; the ROM is already paged in, do not use pager
#endif

and in the makefile, build two libraries, one with the equivalent of doing
-DMAINRAM as a command line argument to the C compiler, and the other
not. But I want to do it with the z88dk's assembler (since the entire
library is in asm) rather than with the C compiler.

Is this possible?

Cheers.

--
Dylan Smith, Port St Mary, Isle of Man    | Code fast, crash young and
Flying: http://www.alioth.net/flying      | leave a beautiful core.
FFE/Elite Universe: http://www.alioth.net |             -- JK (#afe)



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php? … &url=/

 

#2 2008-09-08 10:19:41

dom
Administrator
Registered: 2007-07-15
Posts: 745
Website

Re: [Z88dk-users] Assembler pre-processor directives?

What I think will be most efficient is doing the equivalent of a C ifdef,
and generating two library binaries, and the program is linked to the
right version of the library, depending on whether it's to run from main
RAM or not. Essentially what I want to do in the ASM file is this:

#ifdef MAINRAM
ld hl, SOCKET
call HLCALL     ; use paging mechanism
#else
call SOCKET     ; the ROM is already paged in, do not use pager
#endif

Sure, you can use:

IF MAINRAM
..
ELSE
..
ENDIF

and z80asm -DMAINRAM  Conditionals are used quite extensively by the crt0 code so there's plenty of examples in there as to how it can be done.



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php? … &url=/

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson