home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!network.ucsd.edu!galaxy!ucrengr!blaisdel
- From: blaisdel@ucrengr.ucr.edu (james blaisdell)
- Newsgroups: rec.games.programmer
- Subject: Re: speedup PutBlock
- Message-ID: <24034@galaxy.ucr.edu>
- Date: 18 Nov 92 23:57:09 GMT
- Sender: news@galaxy.ucr.edu
- Organization: University of California, Riverside
- Lines: 38
- Nntp-Posting-Host: ucrengr
-
- >> > mov ax, 320 <<<-- change this to mov bx, y
- >> > mul y ; AX = y * 320 <<<-- and this to add bx, bx
- >> then set ds, si for the table lookup by: lds si, table
-
- >> then load ax with screen addr by mov ax, ds:[si+bx]
-
- >The way I usually do these things is:
-
- > mov ah, y
- > sub al, al
- > mov bx, ax
- > shr bx, 1
- > shr bx, 1
- > add ax, bx
-
- >I remember comparing that with the table method, and this was faster,
- >although I may be wrong. It probably also depends on what machine you're
- >using.
-
- Actually what you have written above won't even work. The AX needs
- to be shifted four times right, before being added to the BX. Also
- what if y is greater than 256?
-
- the following code should work, if you want to use shifts and y<256:
-
- mov ah, y
- sub al, al
- mov bx, ax
- shr bx, 1
- shr bx, 1
- mov ax, bx
- shr ax, 1
- shr ax, 1
- add bx, ax
-
- however the table lookup is much more flexible and faster, the only
- possible argument against the table look up is that it requires 400 bytes
-
-