home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / rec / games / programm / 4738 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.4 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!network.ucsd.edu!galaxy!ucrengr!blaisdel
  2. From: blaisdel@ucrengr.ucr.edu (james blaisdell)
  3. Newsgroups: rec.games.programmer
  4. Subject: Re: speedup PutBlock
  5. Message-ID: <24034@galaxy.ucr.edu>
  6. Date: 18 Nov 92 23:57:09 GMT
  7. Sender: news@galaxy.ucr.edu
  8. Organization: University of California, Riverside
  9. Lines: 38
  10. Nntp-Posting-Host: ucrengr
  11.  
  12. >>  >        mov     ax, 320                 <<<-- change this to mov bx, y
  13. >>  >        mul     y       ; AX = y * 320  <<<-- and this to add bx, bx
  14. >>       then set ds, si for the table lookup by:  lds si, table
  15.  
  16. >>        then load ax with screen addr by          mov ax, ds:[si+bx]
  17.  
  18. >The way I usually do these things is:
  19.  
  20. >    mov    ah, y
  21. >    sub    al, al
  22. >    mov    bx, ax
  23. >    shr    bx, 1
  24. >    shr    bx, 1
  25. >    add    ax, bx
  26.  
  27. >I remember comparing that with the table method, and this was faster,
  28. >although I may be wrong. It probably also depends on what machine you're
  29. >using.
  30.  
  31. Actually what you have written above won't even work.  The AX needs
  32. to be shifted four times right, before being added to the BX.  Also
  33. what if y is greater than 256?  
  34.  
  35. the following code should work, if you want to use shifts and y<256:
  36.  
  37.     mov    ah, y
  38.     sub    al, al
  39.     mov    bx, ax
  40.     shr    bx, 1
  41.     shr    bx, 1
  42.     mov    ax, bx
  43.     shr    ax, 1
  44.     shr    ax, 1
  45.     add    bx, ax    
  46.  
  47. however the table lookup is much more flexible and faster, the only
  48. possible argument against the table look up is that it requires 400 bytes
  49.  
  50.