|
DataMuseum.dkPresents historical artifacts from the history of: Jet Computer Jet80 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Jet Computer Jet80 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 2560 (0xa00) Types: TextFile Names: »DELETE.MAC«
└─⟦01b5c9619⟧ Bits:30005906 Microsoft Multiplan v1.05 og HELP └─ ⟦this⟧ »DELETE.MAC«
; ; ; Title Delete a substring from a string ; Name: Delete ; ; ; Purpose: Delete a substring from a string given a ; starting index and a length ; ; Entry: Register pair HL = base address of string ; Register B = number of bytes to delete ; Register C = starting index into the string ; An index of 1 is the first character ; ; A string is maximum f 255 bytes long plus ; a length byte which precedes it. ; ; Exit: Substring deleted. ; if no errors then ; CARRY := 0 ; else ; begin ; the following conditions cause an ; error with CARRY := 1 ; if (index = 0) or (index > length(string)) ; then do not change string ; if count is too large then ; delete only the characters from ; index to end of string ; end; ; ; Registers used: AF,BC,DE,HL ; ; Time: Approximately 21 * (lenght(strg)-index-count+1) ; plus 224 cycles overhead ; ; Size: Program 58 bytes ; Data 1 byte ; ; ; DELETE: ;Initialize error indicator (delerr) to 0 sub a ld (delerr),a ;Assume no errors ;Check if count and index are both non-zero or b ;Test number of bytes to delete ret z ;Return with CARRY = 0 ( noerrors) if ; 0 bytes to delete ld a,c ;Test starting index or a scf ;Carry := 1; ret z ;Error exit (carry := 1) if ; starting index = 0 ;Check if starting index within string ld a,(hl) ;Get lenght cp c ;Is index within string ? ret c ;No, take error exit ;Be shure enough characters are available ; if not, delete only to end of string ; if index + number of characters - 1 > length(string) then ; number of characters := length(string) - index + 1; ld a,c ;Get index add a,b ;Add number of characters to delete jr c,trunc ;Truncate if sum > 255 ld e,a ;Save sum as starting index for move dec a cp (hl) ;Compare to lenght jr c,cntok ;Jump if enough characters available jr z,trunc ;Truncate but no errors (exactly enough ; characters ld a,0ffh ;Indicate error - not enough characters ld (delerr),a ; available for deletion ;Truncate string - no compacting necessary ; string lenght = index -1 trunc: ld a,c ;String lenght = index - 1 dec a ld (hl),a ld a,(delerr) rra ;Carry = 0 if no errors ret ;Exit ;Delete substring by compacting ; move all characters above deleted area down ;New lenght = old lenght - number of bytes to delete cntok: «eof»