rosecityaccordionclub.com
This Domain is for Sale * Cheap *
To buy this domain name do the following
1. Go To www.GoDaddy.com
2. Click on the DOMAIN AUCTIONS tab
3. Enter the domain name into the search box
4. Click the BUY NOW button next to the domain name
5. GoDaddy takes about 5 days to move the domain to you
Using Machine Language Subroutines For High Speed Vector Mathematics


A number of years ago I worked on a project that required extensive manipulation of digital waveforms; the waveforms were stored in double precision floating point vectors (or arrays if you prefer) rsspect.org We quickly discovered that even when we compiled the programs we were not getting the speed required because of the loops needed to step through the entire vector ambafrance-kwt.org Not having any direct vector oriented operators such as those available in APL we decided to create our own subroutines that we could pass a vector to and have the operation done quickly in machine language.

Of course we gained a lot of speed but did get the downside of being tied to a particular hardware processor without reprogramming the assemble language code sabatinobros.com But shakespeareunderthemoon.com sagartzart.com schwarzconsultingllc.com notice how tight the RESET: loop is (three instructions) used in the sample program below.. shelbykrueger.com sweet!

The floating point format used in BASIC at the time on an 8088 processor used big-endian addressing so, in a sense, the binary representation of the numbers made the "memory words" (16 bits) seem to be backwards... that is why the sign bit, for example, used in the following example is the most significant bit of the 7th byte used for each number (refer to the line: "ADD DI,VLEN-2;point to sign byte"). So the code also has to be modified if a different format for the floating point numbers is used!

The following program gives an example of the subroutine that is passed a double precision vector, X(0) to X(N), and turns it into the absolute value of the vector (i.e. removes all the sign bits and makes all the numbers positive). The subroutine works directly on the passed vector so if a copy of the original is required it is necessary to make the copy before using this subroutine.

© Copyright: MASE Consulting Ltd. All rights reserved. No part of this code may be used for commercial purposes without a formal agreement.

PAGE,132
;VECTOR ABSOLUTE SUBROUTINE

CODESEGSEGMENT
ASSUMECS:CODESEG
PUBLICDABS

;To execute from compiled BASIC use:
;CALL DABS(X(0),X(N))
;then link the two object modules together.

;"X(0)" is the first element of the vector
;"X(N)" is the last element

VLENEQU8;# bytes per element
ELEM1EQU[BP+8];1st element pointer
ELEMNEQU[BP+6];last element pointer
SIGNEQUBYTE PTR [DI];the sign location
length=LAST-DABS;length in bytes of this subroutine

;To execute from interpreted BASIC use:
;CODE$=SPACE$(length)'length from above when code is assembled
;SUB=VARPTR(CODE$):SUB=PEEK(SUB+1)+256*PEEK(SUB+2)
;BLOAD "DABS.MEM",SUB
;DABS=SUB
;CALL DABS(X(0),X(N))'X(0) and X(N) as mentioned above

;To produce a BLOAD file for the interpreter use the linker
;to create a .EXE file that will load high (/H parm)
;Then use debug as follows:
;DEBUG DABS.EXE
;R 'and record CS (code segment) and IP (offset)
;NBASIC 'put "dot COM" after NBASIC
;L
;G 'execute BASIC
;Now that you are in BASIC use:
;DEF SEG = cs 'cs as recorded above after R command
;BSAVE "DABS.MEM",ip,length'ip and length as recorded above
;SYSTEM
;Back to DEBUG now so exit with:
;Q

DABSPROC FAR
PUSH BP;save base pointer
MOV BP,SP;stabilize pointer to stack
MOV AX,ELEMN;Nth element pointer
MOV DI,ELEM1;1st element pointer
SUB AX,DI;number of bytes in vector
XOR DX,DX;zero data register to make doubleword
MOV CX,VLEN;get element length
DIV CX;determine # of elements
INCAX;one more for correct count
MOV CX,AX;copy to count register
ADD DI,VLEN-2;point to sign byte
RESET:
AND SIGN,7FH;reset the sign bit
ADD DI,VLEN;up to next element
LOOP RESET;continue to end

POP BP;restore callers base pointer
RET 4;return and pop input parameters
LAST:
DABSENDP
CODESEGENDS
END

(c) copyright 2010, wadeindustries.com rosecityaccordionclub.com