Write Directive

Here follow some instructions to implement the WRITE directive.

Supporting the directive itself

I (madram) will take care of that (parsing, displaying, assembly routine).

To be implemented: save_chunks

tl;dr; Routine that output the assembled chunks in order.

Since Orgams FF, the code is cached. The routine shall take the cached chunks and send them to a generic IO routine.
The only gotchas:
- The chunks are given in assembling order, not memory order. They must be sorted (well, one easier solution, which doesn't take much additional memory, is to iterate several times until all the zone to be written is covered).
- When chunks aren't contiguous (happens with multiple ORGs or SKIP directive), we have to pad with what is currently in memory.
- [optional] In case of overlapping chunks, we just put them sequentially and issue a warning.

You can use 9000-90FF for your own buffer/variables.
There is already one variable (jump_to_save) used by boilerplate code.
You may not use EX AF,AF or EXX.

; In: HL = Start 
;     BC = Size
;     IX = Output routine, which itself takes:
           ; HL = Start (use curently connected bank) 
           ; BC = Size
; Out: Carry if ok
        ; NC otherwise, A = error code (typically returned by output routine IX)
; All registers can be trashed, but it must remains firmware-friendly.  

; Note: DISC_OUT_OPEN & co are handled by the caller.
      ; This is a generic IO agnostic routine.

Available routines

; In: IY = routine called at each chunk, which will be passed:
             ; BC  Destination Bk (N/A except when padding) 
             ; DE  Destination address
             ; HL  Start of contiguous chunk data to ouput  
             ;  A   Size (0 < size < &100)
; Out:  Carry if ok
        ; NC otherwise, A = error code (typically returned by output routine IX)
      ; All other registers trashed.
; This is the routine to use for "padding memory"
; IN :  BC = bk to connect (B = 7f typically  C = C0, C4..C7, CC..CF etc)
; Out: Bk is connected
     ; All registers preserved



  • writetst.o: Tests save_chunks against different scenarios. This is the file to execute.
  • testlib.o : Helpers for test. You shouldn't have to touch that
  • cocopy.o : Helpers. You shouldn't have to touch that
  • write.o : The source to update! Contains (almost) functional code and boilerplate.
Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License