name ('compar') title This is the Pattern matching module. .z80 .tfcond .comment ~ ********************************************************************************** ********************************************************************************** ********** ******** **** **** *********** ******** *********** *********** ********** ***** ***** ************ ********** ************ *** *** *** ************ *** *** *** *** *** *** *** *** *** ************ *** *** *** *** *** *** *** *** *** *** **** *** *** *** *** *** *** *** *** *** *** *** ** *** ************ *** *** ************ *** *** *** *** *** *********** ************ *********** *** *** *** *** *** *** ************ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *********** ********** *** *** *** *** *** *** *** ********** ******** *** *** *** *** *** *** *** ********************************************************************************** ********************************************************************************** C O M P A R E . M A C Version 1.00 Creation Date: 11 January 1983 MODULE: 0.11 Date Last Revised: 12 January 1983 Find the Pattern String within the destination module Edit History: 11 Jan 83 - Created by Mike Pinkston (out of desperation). 12 Jan 83 - Debugged completely (hopefully). ~ subttl Global/External points of entry and reference page 60 GLOBAL SETMEM EXTERNAL ATHLNG, ATHSTR, TOPAGE, MESAG8 subttl Set the CBIOS's memory size string bytes page SETMEM:: LD DE,MESAG8## ; Set the Source Pointer to the start of the Pattern String. LD HL,(ATHSTR##) ; Set the Destination Pointer to the start of the module. LD BC,(ATHLNG##) ; Set the Module Length Count to the length of the module. XOR A ; Set the Exit Flag to False. LD (Exit.Flag),A ; Do.While.1: ; Do While (the Exit Flag is False) LD A,(Exit.Flag) ; OR A ; JP NZ,Enddo.while.1 ; If.1: ; If (the Module Length Count = 0), LD A,B ; OR C ; JR NZ,Endif.1 ; Then.1: ; Then CPL ; Set the Exit Flag to True. LD (Exit.Flag),A ; JR Do.While.1 ; Loop. Endif.1: ; Endif (the Module Length Count = 0). LD A,(DE) ; Get the byte from the Source Pointer. CP (HL) ; Compare to the Destination Pointer's byte. INC HL ; Increment the Destination Pointer. DEC BC ; Decrement the Module Length Count. If.2: ; If (the bytes are equal), JR NZ,Endif.2 ; Then.2: ; Then PUSH HL ; Save the Destination Pointer. INC DE ; Increment the Source Pointer. Do.Until.1: ; Do Until (the bytes aren't equal) LD A,(DE) ; Get the Source Pointer byte. CP (HL) ; Compare it with the Destination Pointer byte. INC DE ; Increment the Source Pointer. INC HL ; Increment the Destination Pointer. JR Z,Do.Until.1 ; Enddo.until.1: ; Enddo until (the bytes aren't equal) POP HL ; Restore the Destination Pointer. If.3: ; If (the Source Pointer's byte = '$'), CP '$' ; JR NZ,Else.3 ; Then.3: ; Then DEC HL ; Decrement the Destination Pointer by 3. DEC HL ; DEC HL ; LD A,(TOPAGE##) ; Get the Top Page of memory byte value. RRCA ; Divide it by 4, discarding the remainder. RRCA ; AND 03FH ; If.4: ; If (the value = 0), JR NZ,Endif.4 ; Then.4: ; Then LD A,040H ; Set value to 64. Endif.4: ; Endif (the value = 0). LD (HL),02FH ; Set Destination Pointer byte to -1. Do.Until.2: ; Do Until (value is less than 10) SUB 10 ; Subtract 10 from the value. INC (HL) ; Increment the Destination Pointer byte. JR NC,Do.Until.2 ; Enddo.until.2: ; Enddo until (value is less than 10) ADD A,03AH ; Convert remainder to ASCII decimal. INC HL ; Increment the Destination Pointer. LD (HL),A ; Set the Destination Pointer byte to the converted remainder. LD A,0FFH ; Set the Exit Flag to true. LD (Exit.Flag),A ; Else.3: ; Else LD DE,MESAG8## ; Set the Source Pointer to start of the Pattern String. Endif.3: ; Endif (the Source Pointer's byte = '$'). Endif.2: ; Endif (the bytes are equal). JP Do.While.1 ; Enddo.while.1: ; Enddo while (the Exit Flag is False). RET ; Return to calling module. Exit.Flag: ; Logical flag to signal end of processing. DEFB 00 END