Re: [cc65] Apple2 file io - here: memory management questions

From: jim <jsymolon011comcast.net>
Date: 2004-07-30 15:16:42
Oliver Schmidt wrote:

>Hi,
>  
>
>>>1. scenario: DOS 3.3 : $800 - $9600
>>>      
>>>
>><snip> I assume most people using 3.3 would be here.  Might be another
>>target (.cfg) though.
>>    
>>
>
>I'm afraid I don't get you right. The current Apple2 default .cfg file is
>just for this scenario.
>  
>
Sorry,  I've been looking at my config file that I've changed to make 
the ProDOS coding easier.

>>Out of that 29.5K, I allocate 8K for static buffers.  Overkill ? Maybe.
>>    
>>
>
>To be honest: In my opinion certainly _YES_ ! BTW: How do you make sure for
>static buffers that they are aligned on page bounaries? Or do you the
>"sub-alignment" with an addition 255 bytes I mentioned briefly?
>
>  
>
I use the .align, example:
;-----------------------------------------------------------------------------
        .data
; ------------------------------------------------------------------------
; ProDOS needs 1K buffer per open - max 8 files
; ------------------------------------------------------------------------
        .align 256
_prodos_buff1:    .res    1024

I was thinking that the base library (filetab) only provides 8 slots 
with the first 3 taken up by the STDIO.  It would be possible to reduce 
the ProDOS file buffer count to 5.

What would be a reasonable number of starting buffers ?  I was thinking 
at least 3 (in, out, data) with a possibility of 1 more for loading code 
overlays.

>>Which leaves 21.5K for a text program.  Someone who wants to use
>>hires will lose another 8 - 16K for ~22K total or 13.5K program - buffers.
>>    
>>
>
>I explictly didn't mention hires as it makes things more complicated / worse
>but - at least in my opinion - doesn't invalidate what I wrote.
>
>Generally I believe that for successful usage of hires we really need a more
>flexible linker. From my experience cc65 Apple2 programs tend to have lot's
>of code and relatively little data. So using $0800-$2000 just for heap/stack
>isn't enough. The CODE segment has to be able to be splitted across several
>memory areas. Therefore I think hires is kind of out-of-reach for our
>current discusion...
>
>  
>
Would it be possible to ".org" a  8K block of "code" into $2000 ?  
Example: code starts at $800 and continues up.  As part of a HIRES 
library there is a section in the .code block that .orgs at $2000 for 
$2000 ?

Off the top of my head ...
.code
.org $2000
.res  $2000

>>>- The application has to call a special quit API on exit. The called quit
>>>routine will then allow the user to load the next application (for
>>>      
>>>
>example
>  
>
>>>the command interpreter).
>>>      
>>>
>
>  
>
>>The crt0.s is per library - there really is nothing stopping us from
>>adding a jsr to a __filecleanup which can close files and "quit" instead
>>of a "JMP RESTOR" or back to basic.  The DOS 3.3 cleanup would be back
>>to basic.
>>    
>>
>
>1. The crt0.s is per target. If Ullrich gives us the option of several file
>i/o libraries to be used for a single target they'll share crt0.s.
>  
>
I was under the assumption that Ullirch did not want to add more targets.

>2. In 2.10 there's no JMP RESTOR there anymore, it's now jmp DOSWARM. Surely
>this is semantically identical, but it makes things much harder to discuss
>if not talking about the same thing with the same words. It would be really
>great if you could step up to at least 2.10 or even better a recent
>snapshot.
>
>  
>
>>    jsr __closeallfiles
>>    
>>
>
>Sorry, I don't understand this line with more context and/or hints. Is this
>you current code? Is this a proposal? In the text above you mention a
>__filecleanup, is this supposed to be the same with a different name?
>
>  
>
Sorry, yes - same functionality.

>>Problem: What if developers don't want a DOS link ? A nodos directory
>>with __dos_quit ?
>>    
>>
>
>Sorry, but I simply don't know what a "DOS link" is :-(
>  
>
Sorry,  what if developers do not want to use DOS (no file capability)?  
They want to re-claim the memory used by the DOS library for more data 
or bigger code.  By coding a dos_quit function and not linking any DOS 
library the linker will output an error.

There's a couple of ideas floating through ...

basic file structure:
Apple2
    common functions (joystick ...)
    ...
    pdos8(dir) -> custom crt0.s for prodos & other functions (read, 
write, open, ...)
    dos33(dir) -> custom crt0.s for dos33 & functions (read, write, 
open, ...)
    nodos(dir) -> the old crt0.s

The problem with this is that the developer will always have to link in 
another library.  More complexity for builds, and it could get ugly for 
the other machines in the II line.   At least the IIGS should be another 
target.

>  
>
>>I need to read up on the config file again.  I was thinking of:
>>    RAMLOW: start=$800, size=$17FF;
>>    RAM: start = $2000, size = $7600, file = %O;
>>    HIRES1: start = $2000, size = $1FFF;
>>    HIRES2: start = $4000, size = $1FFF;
>>    RAMHIGH: start = $6000, size = $3600; # $9600 begin prodos
>>    
>>
>
>How do you want to make use of RAMLOW?
>
>  
>
.bss and or .data ?

>>HIRES1 & 2 could be "DATA"
>>    
>>
>
>I don't understand this statement:
>
>1. If the linker is to place the startup code at $2000, there can't be
>something else at the same time.
>2. The "DATA" segment is for initialized writable data items. What has this
>to do with hires?
>  
>
I was thinking of HIRES splash screens and forgot that there has to be 
at least 3 bytes of code at the beginning.

>  
>
>>Loader - hrrmmm...  load into HIRES1, run from RAMLOW ?  I'm not sure
>>how this will work -yet.
>>    
>>
>
>I guess you missed the following from my last posting:
>
>"It would have a custom startup code relocating the loader from $2000 to
>let's say $B000.
>This area would then wiped out later by the BSS, heap or stack of the main
>executable."
>
>The loader doesn't run from $0800, it runs from $B000 (or something like
>that).
>  
>
With the context that the .CODE can't be split - that make sense; to put 
the loader up at $B000 than $800.

>  
>
>>>Setting up a RESET handler for closing files
>>>      
>>>
>
>  
>
>>Again - the crt0.s can be modifed to call "quit" .
>>    
>>
>
>1. Again, the crt0.s is by default shared between the DOS 3.3 and ProDOS 8
>libraries.
>2. As I wrote: If we want the RESET handler only for ProDOS 8 the difference
>is going to be more than just calling quit instead of jumping to doswarm.
>
>
>  
>
>> I need to understand
>>"condes" better.
>>    
>>
>
>The 2.10 Apple2 C library makes use of it in very simple manners making up
>usable examples.
>  
>

I've been looking at the code.

The things to do list:
       Get a test suite finished.
       move the code into the subdirectories and create make files

>  
>
>>Great stuff !  Gives me a lot to consider.
>>    
>>
>
>Thanks for the positive feedback.
>
>Oliver
>
>  
>
Jim

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Jul 30 15:17:20 2004

This archive was generated by hypermail 2.1.8 : 2004-07-30 15:17:29 CEST