[comp.sys.apple] Binary II Format understanding

bird@ihlpf.ATT.COM (Walters) (05/19/88)

I disassembled some code to see how it worked. I have everything
pretty well understood except for the following:

The following code fragment is testing to see if there are any more
sub files in a BINARY II file. If byte 127 of the header is zero
there are no more. Follow along to the point where my confusion sets in (or
at least where I think it sets in).

A164: AD 00 AA  434           LDA   RD_BUFF2+127
A167: F0 52     435           BEQ   NOMOR      ;No files to follow, so done
A169: 20 00 BF  436           JSR   MLI	       ;Put byte position of
A16C: CF        437           DFB   GET_MARK   ; current mark into
A16D: EA A7     438           DA    GMRK_PRM   ; GMRK_POS
A16F: 90 03     439           BCC   FNDNXT
A171: 4C 09 A0  440           JMP   MLI_ERR

This routine is computing the next header position in the file by
adding the length of this sub file to its length.

A174: AD EC A7  442  FNDNXT   LDA   GMRK_POS    ;Low of get mark
A177: 18        443           CLC
A178: 6D 95 A9  444           ADC   RD_BUFF2+20 ;Low of EOF
A17B: 8D F1 A7  445           STA   SMRK_POS
A17E: AD ED A7  446           LDA   GMRK_POS+1  ;Middle of get mark
A181: 6D 96 A9  447           ADC   RD_BUFF2+21 ;Middle of EOF
A184: 8D F2 A7  448           STA   SMRK_POS+1
A187: AD EE A7  449           LDA   GMRK_POS+2  ;High of get mark
A18A: 6D 97 A9  450           ADC   RD_BUFF2+22 ;High of EOF
A18D: 8D F3 A7  451           STA   SMRK_POS+2

HERE IS THE PART I DO NOT UNDERSTAND - HELP PLEASE

I haven't got a clue as to what this code is doing. It has to be
doing something about an error the above put in to the low byte.
The rest is simply moving carrys forward to the next byte.
However, what is so magic about $7F and the low byte being zero
that makes it ok?? The EOR is right up there in mystery land also.

A190: AD F1 A7  458           LDA   SMRK_POS
A193: 29 7F     459           AND   #$7F
A195: F0 16     460           BEQ   MRKOK
A197: 49 7F     461           EOR   #$7F
A199: 18        462           CLC
A19A: 6D F1 A7  463           ADC   SMRK_POS
A19D: 8D F1 A7  464           STA   SMRK_POS
A1A0: EE F1 A7  465           INC   SMRK_POS
A1A3: D0 08     466           BNE   MRKOK
                467
A1A5: EE F2 A7  468           INC   SMRK_POS+1 ;Move carry to here
A1A8: D0 03     469           BNE   MRKOK
                470
A1AA: EE F3 A7  471           INC   SMRK_POS+2 ;And to here if needed
                472
A1AD: 20 00 BF  473  MRKOK    JSR   MLI        ;Set mark to next header
A1B0: CE        474           DFB   SET_MARK
A1B1: EF A7     475           DA    SMRK_PRM
A1B3: 90 03     476           BCC   GOJMP      ;Do a long jump
A1B5: 4C 09 A0  477           JMP   MLI_ERR
                478
A1B8: 4C 60 A0  479  GOJMP    JMP   NXTHDR


				Joe Walters
				(312) 415-5356
				ihnp4!ihlpf!bird
-- 
				Joe Walters ihnp4!ihlpf!bird
				IHP 1F-240 (312) 416-5356