|
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: 2304 (0x900) Types: TextFile Names: »D2WORD.MAC«
└─⟦01b5c9619⟧ Bits:30005906 Microsoft Multiplan v1.05 og HELP └─ ⟦this⟧ »D2WORD.MAC«
; ; ; Title Two-dimensional word array indexing ; Name: D2WORD ; ; ; Purpose: Given the base address of a word array, two ; subscripts 'I','J', and the size of the first ; subscript in bytes, calculate the address of ; AÆI,JÅ. The array is assumed to be stored in ; row major order (AÆ0,0Å, AÆ0,1Å,..., AÆK,LÅ, ; and both dimensions are assumed to begin at ; zero as in the following Pascal declaration: ; A:ARRAYÆ0..2,0..7Å of word; ; ; Entry: Top of stack ; Return address word ; Second subscript (column element) word ; First subscript size in bytes word ; First subscript (row element) word ; Array base address word ; NOTE: ; The first subscript size is lenght of a row ; in words * 2 ; ; Exit: Register HL = Element address ; ; Registers used: AF,BC,DE,HL ; ; Time: Approximately 1100 cycles ; ; Size: Program 45 bytes ; Data 4 bytes ; ; ; D2WORD: ;Save return address pop hl ld (retadr),hl ;Get second subscript, multiply by 2 for word-lenght element pop hl add hl,hl ;* 2 ld (ss2),hl ;Get size of first subscript (orq lenght), first subscript pop de ;Get lenght of row pop bc ;Get first subscript ;Multiply first subscript * row lenght using shift and add ; algorithm, product is in hl ld hl,0 ;Product = 0 ld a,15 ;Count = bit lenght - 1 mlp: sla e ;shift low byte of multiplier rl d ;rotate high byte of multiplier jr nc,mlp1 ;Jump if msb of multipier = 0 add hl,bc ;Add multiplicand to partical product mlp1: add hl,hl ;shift paritcal product dec a jr nz,mlp ;Continue through 15 bits ;Add multiplicand in last time if msb of multiplier is 1 or d ;Sign flag = msb of multiplier jp p,mlp2 add hl,bc ;add in multiplicand if sing = 1 ;Add in second subscript mlp2: ld de,(ss2) add hl,de ;Add base address to form final address pop de ;Get base address of array add hl,de ;Add base to index ;Return to caller ld de,(retadr) ;Restore return address to stack push de ret ;DATA retadr: ds 2 ;Temporary return address ss2: ds 2 ;Temporary return address «eof»