|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 1408 (0x580) Types: TextFile Names: »MPDCMP.MAC«
└─⟦01b5c9619⟧ Bits:30005906 Microsoft Multiplan v1.05 og HELP └─ ⟦this⟧ »MPDCMP.MAC«
; ; ; Title Multiple-Precision Decimal Comparison ; Name: MPDCMP ; ; ; ; Purpose: Compare two arrays of decimal bytes and return ; the Carry and zero flags sete or cleared ; ; Entry: Register pair HL = Base address of minuend ; Register pair DE = Base address of subtrahend ; Register B Lenght of operands in bytes ; ; Exit: IF minuend = subtrahend THEN ; C=0,Z=1 ; IF minuend > subtrahend THEN ; C=0,Z=0 ; IF minuend < subtrahend THEN ; C=1,Z=0 ; ; Registers used: AF,BC<DE,HL ; ; Time: 44 cycles per byte that must be examined plus ; 60 cycles owerhead ; ; Size: Program 19 bytes ; ; ; MPDCMP: ;Test lenght of operands, set pointers to msb's ld a,b or a ;Is lenght of arrays = 0 ? ret z ;Yes, Exit with c=0,z=1 ld c,b ;BC = lenght ld b,0 add hl,bc ex de,hl ;DE points to end of minuend add hl,bc ;HL points to end of subtrahend ld b,c ;B = lenght or a ;Clear carry initially ;Subtract bytes, starting with most significant ;Exit with flags set if corresponding bytes not equal loop: dec hl ;Back up to less significant byte dec de ld a,(de) ;Get next byte of minuend sbc a,(hl) ;Subtract byte of subtrahend ret nz ;Retur if not equal with flags ; set djnz loop ;Continue until all bytes compared ret ;Equal, return wiht C=0, Z=1 «eof»