Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!ganymede!terre.DMI.USherb.CA!sd05 From: sd05@terre.DMI.USherb.CA (Sylvain Tremblay / Eric Trepanier) Newsgroups: comp.sys.cbm Subject: Re: HELP: Assembly - Address Maintenance for code overlaying Message-ID: <1990Dec18.044311.17168@DMI.USherb.CA> Date: 18 Dec 90 04:43:11 GMT References: <2373.27637c31@iccgcc.decnet.ab.com> Sender: usenet@DMI.USherb.CA (Pour courrier Usenet) Organization: Universite de Sherbrooke, Quebec Lines: 72 Nntp-Posting-Host: terre.dmi.usherb.ca In article <2373.27637c31@iccgcc.decnet.ab.com> lockemer@iccgcc.decnet.ab.com writes: >I am writing a program in assembly which will need to load different sections >of code into the same areas of memory. These sections will have multiple >routines in them. Does anyone have any suggestions/tricks/tips on how to >access the routines from the main code (such as using labels somehow) so that >I do not have to manually keep track of where each routine ends up any time it >is reassembled? I am writing this on a 128 using MERLIN 128. A related >question is how do I do the same thing if I want to have routines in other >bank configurations? Thanks... > >Todd Lockemer Merlin is great for this kind of stuff! The best way to do it is to put your main "chunck" of source listing in a file named something like "main_code". Then you write a different source code section for each overlay module. These files could be "overlay_code.x" where x = 1,2,3,4,... Each of the files would start with a ORG XXXX statement and end with a SAV statement. Then you would have one "project" file which would simply include all the files required for assembly. This project file would look like this: > use "macros.l" > use "symbols.l" > use "main_code.s" > use "overlay_code_1.s" > use "overlay_code_2.s" > use "overlay_code_3.s" The macros.l file is your macro library, the symbols.l file is your symbol library and the main code would look like this: > org $2000 ; Start address of main module > ... > jsr GetOverlay1 ; Bring in Overlay 1 module in memory > jsr Function1 ; Call a function from overlay 1 > ... > jsr GetOverlay2 ; Bring in Overlay 2 module in memory > jsr Function2 ; Call a function from overlay 2 > ... > jsr GetOverlay3 ; Bring in Overlay 3 module in memory > jsr Function3 ; Call a function from overlay 3 > ... > sav "main_code" Finally, each overlay code would look like this: > org $4000 ; Overlay modules start address > ... >FunctionX ... ; Function (1,2,3) start address > rts > sav "overlay_code_X" Ideally, these overlay modules would be copied in a REU and swapped in an out of it for maximum speed! It can be done very easilly. The "GetOverlayX" routine wouldn't need more than 20 instructions or so. The best way to jump to routines located in different memory banks is through the JMPFAR and JSRFAR routines from the Kernal. If you have the C128 Programmer's Reference Guide or the C128 Internals book from Abacus, you've got all the information you need to use these simple routines. Hope this was helpful! Eric Trepanier -- +-----------------------------------------------------------------///------+ | Sylvain Tremblay INTERNET: sd05@terre.USherb.CA __ /// /| | | Eric Trepanier CIS: 71640,666 \\\/// # | | | Sherbrooke, Qc, Can TEL: (819) 820-0976 \XX/ _|_ |