qdosmsq:traps:trap_3:rhdr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

qdosmsq:traps:trap_3:rhdr [2009/02/17 11:47] (current)
george.gwilt created
Line 1: Line 1:
 +====== FS_HEADR/​IOF_RHDR ======
 +
 +This trap reads a file header.
 +
 +^Call Parameters^^Return Parameters^^
 +|D0.B|$47|D0.L|Error code.|
 +|D1.L| |D1.W|Length of header read.|
 +|D2.L|Buffer length |D2.L|Preserved.|
 +|D3.W|Timeout|D3.L|Preserved.|
 +|A0.L|Channel ID |A0.L|Preserved.|
 +|A1.L|Pointer to buffer|A1.L|Updated.|
 +
 +===== Errors =====
 +
 +|ERR_NC|Not complete.|
 +|ERR_NO|Channel not found.|
 +|ERR_BO|Buffer full.|
 +
 +
 +===== Notes =====
 +  * All registers not shown above are not used on entry and are preserved on exit.
 +  *The length of header is 64 bytes for a directory driver and 15 bytes for other device drivers.
 +  *After the buffer has been read A1.L points to one after the last character read.
 +  *The form of header is shown below.
 +  *The file type (byte 5) is 0 for data files, 1 for executable files, 2 for relocatable files and 255 for subdirectories.
 +
 +=== File Header ===
 +^Address^Length^Contents^
 +|$00|long|File length|
 +|$04|byte|File access set to 0 in QDOS v1.03|
 +|$05|byte|File type|
 +|$06|long|Size of data space for executable files|
 +|$0A|long|Unused|
 +=== Additionally for Directory Drivers ===
 +^Address^Length^Contents^
 +|$0E|word|Length of filename|
 +|$10|36 bytes|Filename|
 +|$34|long|Update date|
 +|$38|word|Version number|
 +|$3A|word|Reserved|
 +|$3C|long|Backup date|
 +   
 +
 +===== Example =====
 +The example below shows how to read the header of an executable file and put its length into D2.L.
 +
 +<​code>​
 +Read_h ​ lea     ​-64(a7),​a7 ​     ; Space on the stack for the header.
 +        movea.l a7,a1           ; Point to the space.
 +        moveq   #​64,​d2 ​         ; Length of buffer.
 +        moveq   #​-1,​d3 ​         ; Timeout.
 +        moveq   #​$47,​d0 ​        ; FS_HEADR
 +        trap    #3              ; Read the header.
 +        tst.l   ​d0 ​             ; OK? . .
 +        bne     ​error ​          ; . . no!
 +        movea.l a7,a1           ; Reset A1
 +        subq.b ​ #​1,​5(a1) ​       ; Check for executable file
 +        bne     ​error ​          ; OOPS!
 +        move.l ​ (a1),​d2 ​        ; Set file length in D2
 +        lea     ​64(a7),​a7 ​      ; Tidy stack
 +
 + ; We could now load the file into memory. ​   ​
 +</​code>​
 +
 +
 +
  
  • qdosmsq/traps/trap_3/rhdr.txt
  • Last modified: 2009/02/17 11:47
  • by george.gwilt