Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Code Block
themeEclipse
titleCRC_FILE, Iterate CRC-32 on complete RAM file (from file pointer until EOF), using OS_Mv
OZ GN_Crc - RST 20H, DEFW $7C09

IN:
    A = CRC_FILE (1)
    HL = pointer to file buffer (local memory) 
    BC = buffer size
    DE = 0, Initialize CRC-32 with FFFFFFFFh
    DE > 0, (local) pointer to initial 4-byte CRC-32
    IX = file handle of open file (using GN_Opf)

OUT, if call successful:
    Fc = 0,
    DEBC = CRC-32

OUT, if call failed:
    Fc = 1,
	A = RC_BAD ($04) - bad argument
    A = RC_xxx (file & handle related errors)

Registers changed after return:
    ......HL/IXIY same
    AFBCDE../.... different
Code Block
themeEclipse
titleIterate CRC-32 partially on RAM file (from file pointer onwards), using OS_Gb
OZ GN_Crc - RST 20H, DEFW $7C09

IN:
    A = CRC_PARTFILEBYTE (2)
    HL = max bytes to read for this partial scan, or -1 for rest of file
    DEBC = Initial CRC-32 or input from result of previous partial CRC-32 scan
    IX = file handle of open file (using GN_Opf)

OUT, if call successful:
    Fc = 0
    DEBC = partial CRC-32 result (DE = high-word, BC = low-word), to be used for next scan iteration 

    Fc = 1, A _RC_Eof
    DEBC = final CRC-32 result (DE = high-word, BC = low-word) 

OUT, if call failed:
    Fc = 1,
	A = RC_BAD ($04) - bad argument
    A = RC_xxx (file & handle related errors)

Registers changed after return:
    ......HL/IXIY same
    AFBCDE../.... different


Code Block
themeEclipse
titleIterate CRC-32 partially (buffered) on RAM file (from file pointer onwards), using OS_Mv
OZ GN_Crc - RST 20H, DEFW $7C09

IN:
    A = CRC_PARTFILEBUF (3)
    HL = pointer to file buffer (local memory), 
    BC = buffer size 
    DE = 0, Initialize CRC-32 with FFFFFFFFh
    DE > 0, (local) pointer to 4-byte CRC-32 (initial CRC-32 or input from result of previous partial scan)
    IX = file handle of open file (using GN_Opf)

OUT, if call successful:
    Fc = 0
    DEBC = partial CRC-32 result (DE = high-word, BC = low-word), to be used for next scan iteration

    Fc = 1, A _RC_Eof
    DEBC = final CRC-32 result (DE = high-word, BC = low-word) 

OUT, if call failed:
    Fc = 1,
	A = RC_BAD ($04) - bad argument
    A = RC_xxx (file & handle related errors)

Registers changed after return:
    ......HL/IXIY same
    AFBCDE../.... different


Code Block
themeEclipse
titleIterate CRC-32 on complete File Entry (File Card)
OZ GN_Crc - RST 20H, DEFW $7C09

IN:
    A = CRC_EPFILE (4)
    BHL = pointer to file entry
    DE = 0, Initialize CRC-32 with FFFFFFFFh
    DE > 0, (local) pointer to initial 4-byte CRC-32

OUT, if call successful:
    Fc = 0,
    DEBC = CRC-32
OUT, if call failed:
    Fc = 1,
	A = RC_BAD ($04) - bad argument
    A = RC_xxx (file card related errors)

 Registers changed after return:
    ......HL/IXIY same
    AFBCDE../.... different


Code Block
themeEclipse
titleIterate CRC-32 partially on File Entry (File Card)
OZ GN_Crc - RST 20H, DEFW $7C09

IN:
    A = CRC_PARTEPFILE (5)

    Initial call:
    BHL = pointer to File Entry
    DE = max. size of bytes to read per partial scan
    IX = pointer to local memory (allocated in application/popdown workspace, 12 bytes):
    (IX + 0,23) : 24bit offset: toInitial fileCRC-32 entryor imageinput (setfrom toresult 0of onprevious inital call), low-byte, high-byte orderpartial CRC-32 scan
     (IX + 34,46)   : max. bytes to read per partial scanReserved for 24bit file pointer (initialized after first call)
    (IX + 57,89)   : InitialReserved CRC-32for orsize inputof fromfile resultentry of(initialized previousafter partial CRC-32 scanfirst call)
  OUT, if call(IX successful:
    Fc = 0
    (IX + 0,2) : 24bit offset updated for next partial scan
    (IX + 5,8) : partial CRC-32 result, low-byte, high-byte order+ 10,11) : Reserved for max. bytes to read per partial scan

    Subsequent calls:
    BHL = 0 (this is returned automatically after initial call to this method)
    IX Fc = 1pointer to updated local memory Aof = RC_Eof (complete file scanned)CRC-32 variables (12 bytes):

 OUT:
    (IXBHL += 50,8) always
:
final CRC-32 result, low-byte, high-byte order

OUT, if call failed:
    Fc = 1,
	A = RC_BAD ($04) - bad argument
    A = RC_xxx (file card related errors)

 Registers changed after return:
    ..BCDEHL/IXIY same
    AF....../.... different

Related calls

None.

Notes

GN_Crc was implemented in OZ V4.5. It is used by the integrated EazyLink popdown to validate uploaded file content. FlashStore also uses it to display the checksum of a File Entry to be fetched to RAM. GN_Crc will be used more in future OZ developments.

 

If this system call is used in stand-alone applications, it is necessary to validate which OZ version the application is running on:

Code Block
include "fileio.def"  Fc = 0
    (IX + 0,3)   : partial CRC-32 result, low-byte, high-byte order
    (IX + 4,6)   : 24bit file pointer updated for next partial scan
    (IX + 7,9)   : Remaining file size updated for next partial scan
    (IX + 10,11) : max. bytes to read per partial scan = DE (initial input)

    Fc = 1
    A = RC_Eof (complete file scanned)
    (IX + 0,3)   : final CRC-32 result, low-byte, high-byte order;

    Fc = 1
    A = RC_xxx (System error occurred - file entry corrupt, not found, etc.)

Registers changed on return:
    ......../IXIY same
    AFBCDEHL/.... different


Related calls

None.

Notes

GN_Crc was implemented in OZ V4.5. It is used by the integrated EazyLink popdown to validate uploaded file content. FlashStore also uses it to display the checksum of a File Entry to be fetched to RAM. GN_Crc will be used more in future OZ developments.

 

If this system call is used in stand-alone applications, it is necessary to validate which OZ version the application is running on:

Code Block
include "fileio.def"

      ld   a,FA_PTR
      ld   ix,ffffh
      ld   de,0          ; result in DEBC
      oz   OS_Frm
      ld   a,44h         ; OZ versions are embedded as hexnibbles in C register.
      cp   c
      jr   nc, not_ozv45 ; Check for OZ V4.5 failed (44h-45h gives Fc = 1)

 

 

Code Block
titleExample for CRC - 32 on memory contents
include "crc32.def"
      ld   a,CRC_MEMA
      ld   hl,crctext
      ld   bc,crctext_end - crctext
      ld   de,0
      oz   GN_Crc
      ; CRC–32 returned is 0x414FA339 (DE = 0x414F, BC = 0xA339)

.crctext       
      defm "The quick brown fox jumps over the lazy dog"
.crctext_end               
Code Block
themeEclipse
titleExample for CRC - 32 on open RAM file using a buffer
include "crc32.def"
include "fileio.def"

DEFC FileBufferSize = 1280
DEFVARS $2000                          ; "popdown" workspace from 2000H onwards
        FileBuffer ds.b FileBufferSize ; buffer for file I/O
ENDDEF

        LD   A, OP_IN
        LD   BC,128
        LD   HL,filename               ; pointer to local filename
        LD   D,H
        LD   E,L
        OZ   GN_Opf 
        JR   C,not_available

        ld   a, CRC_FILE
        ld   hl,FileBuffer             ; use buffer
        ld   a,FA_PTRbc,FileBufferSize            ld 
 ix,ffffh       ld   de,0          ; result in DEBC            ; Use FFFFFFFFh as initial Crc-32
        oz   OS_FrmGN_Crc             ld   a,44h    ; get CRC-32 of Open ;file OZ versions are embedded as hexnibbles in C register.(with buffer), returned in DEBC
        oz  cp GN_Cl  c       jr   nc, not_ozv45 ; Check for OZ V4.5 failed (44h-45h gives; Fcclose =file
1)
 
Code Block
 code
theme
Eclipse
titleExample for CRC - 32 on memory contentson open RAM file without buffer (slowest)
include "crc32.def"
include "fileio.def"
 include "error.def"

       ld LD   aA,CRC_MEMA OP_IN
        ldLD   hlBC,crctext128
      ld  LD bc,crctext_end - crctextHL,filename       ld   de,0     ; pointer ozto local filename
GN_Crc       ; CRC–32LD returned is 0x414FA339D,H
(DE = 0x414F, BC = 0xA339)  .crctext LD   E,L
        OZ defm "The quickGN_Opf brown
fox jumps over the lazy dog" .crctext_end  JR   C,not_available

        
Code Block
themeEclipse
titleExample for CRC - 32 on open RAM file using a buffer
include "crc32.def"
include "fileio.def"

DEFC FileBufferSize = 1280
DEFVARS $2000   ld   a, CRC_PARTFILEBYTE
        ld   hl,1024                   ; read 1024 bytes ;at "popdown"a workspacetime from 2000H onwardsfile
        ld   bc,$ffff
  FileBuffer ds.b FileBufferSize ; buffer for fileld I/O ENDDEF d,b
        LDld   Ae,c OP_IN         LD   BC,128         LD ; Use HL,filenameFFFFFFFFh as initial Crc-32

.scan_file
        oz  ; pointerGN_Crc to local filename         LD   D,H     ; get CRC-32 of LDOpen file  E,L(no buffer)
        OZjr   GN_Opf c,check_eof
        JRpush bc
 C,not_available       push de
 ld   a, CRC_FILE   push hl

   ld   hl,FileBuffer  call do_task

        ;pop use bufferhl
        ldpop  de
bc,FileBufferSize        pop  bc
        jr   ldscan_file

 de,0.check_eof
        oz   GN_Cl          ; Use FFFFFFFFh as initial Crc-32       ; close ozfile
  GN_Crc      cp   Rc_eof
        ret  ;z get CRC-32 of Open file (with buffer), returned in DEBC         oz   GN_Cl   ; CRC-32 completed, return DEBC to caller
        scf   ; close file 
Code Block
themeEclipse
titleExample for CRC - 32 on open RAM file without buffer (slowest)
include "crc32.def" include "fileio.def" include "error.def"          LD   A, OP_IN    ; other error occurred - LDsignal Fc = BC1,128 A = RC_xxx
      LD   HL,filename  ret
Code Block
titleExample for CRC - 32 on File Entry in File Card
include "crc32.def"
include "eprom.def"

        ld   ;c,2 pointer to local filename         LD  
D,H        ld LD   Ede,Lepfilename         OZ   GN_Opf ; search for filename in filea area of slot JR2
  C,not_available

        ld   a, CRCEP_PARTFILEBYTE
        ld   hl,1024Find
        oz   OS_Epr        ; read 1024 bytes at a time from file     
   ld   bc,$ffff  ret  c     ld   d,b         ld   e,c     ; file area not there
        ret  nz   ;  Use FFFFFFFFh as initial Crc-32  .scan_file         oz   GN_Crc  ; file entry not found

        ld   a, CRC_EPFILE
; get CRC-32 of Open file (no buffer) ld   de,0     jr   c,check_eof         push bc    ; Use FFFFFFFFh as initial pushCrc-32
de        oz push hl GN_Crc         call do_task          pop; get hlCRC-32 of File Entry returned in DEBC
Code Block
titleExample for CRC - 32 on partial File Entry in File Card
include "crc32.def"
popinclude "eprom.def"
de
DEFVARS $2000       pop  bc         jr   scan_file  .check_eof   ; "popdown" workspace from 2000H onwards
oz   GN_Cl     FE_CRC32VARS ds.b 12 
ENDDEF

        ld  ; closec,2 file         cp   Rc_eof  
      ret  zld   de,epfilename             ;     search for filename in ;filea CRC-32 completed, return DEBC to callerarea of slot 2
        ld  scf a, EP_Find
        oz   OS_Epr              ; other error occurred - signal Fc =
1, A = RC_xxx     ret  c  ret
Code Block
titleExample for CRC - 32 on File Entry in File Card
include "crc32.def" include "eprom.def"          ld   c,2       ; file area not there
        ret  nz  ld    de,epfilename             ; search for filename in filea; areafile ofentry slotnot 2found

       ld ld   a, EPCRC_FindPARTEPFILE
        ld oz  ix, OSFE_EprCRC32VARS          ; variable space for partial GN_Crc
        ld   de,1024      ret  c           ; Scan max. 1024 bytes per loop iteration, initial Crc-32 is FFFFFFFFh
.crc32_fe_loop
  ; file area not there  oz   GN_Crc    ret  nz              ; get partial CRC-32 of File Entry in BHL (or ;BHL file= entry0 notfor foundnext partial block)
       ld  jr a, CRC_EPFILE c, final_crc32
      ld  ...
de,0        call do_task
        ...
   ; Use FFFFFFFFh as initial Crc-32jr   crc32_fe_loop
.final_crc
    oz   GN_Crc ; CRC-32 is available in (IX+0)
        call display_crc32
   ; get CRC-32 of File Entry returnedret
in DEBC