|
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: »D2BYTE.MAC«
└─⟦01b5c9619⟧ Bits:30005906 Microsoft Multiplan v1.05 og HELP └─ ⟦this⟧ »D2BYTE.MAC«
; ; ; Title Two-dimensional byte array indexing ; Name: D2BYTE ; ; ; Purpose: Given the base address of a byte 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 byte; ; ; Entry: Top of stack ; Low byte of return address, ; High byte of return address, ; Low byte of second subscript (column element), ; High byte of second subscript (column leement), ; Low byte of first subscript size, in bytes, ; High byte of first subscript size, in bytes, ; Low byte of first subscript (row element), ; High byte of first subscript (row element), ; Low address of array base address, ; High address of array base address, ; NOTE: ; The first subscript size is lenght of a row ; in bytes. ; ; Exit: Register H = High byte of element address ; Register L = Low byte of element address ; ; Registers used: AF,BC,DE,HL ; ; Time: Approximately 1100 cycles ; ; Size: Program 44 bytes ; Data 4 bytes ; ; ; D2BYTE: ;Save return address pop hl ld (retadr),hl ;Get second subscript pop hl ld (ss2),hl ;Get size of first subscript (row 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 multiplier = 0 add hl,bc ;Add multiplicand to partical product mlp1: add hl,hl ;Shift partical product dec a jr nz,mlp ;Continue through 15 bits ;Do last add if msb of multiplicand is 1 or d ;Sign flag = msb of multiplier jp p,mlp2 add hl,bc ;Add in multiplicand if sign = 1 ;Add in secong 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 for return address ss2: ds 2 ;Temporary for second subscript «eof»