home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / borland / chap_17 / qline.lst < prev    next >
Encoding:
File List  |  1995-05-25  |  7.9 KB  |  262 lines

  1. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 1
  2. qline.asm
  3.  
  4.  
  5.  
  6.       1
  7.       2                     ; this    function draws a line from xs to xe using 32 bit data movement
  8.       3
  9.       4        0000             .MODEL    MEDIUM,             ; use medium memory model C function names
  10. **Error** qline.asm(4) Missing or illegal language ID
  11.       5
  12.       6        0000             .CODE                 ; begin the code segment
  13.       7
  14.       8                     .386
  15.       9
  16.      10                     PUBLIC    _Triangle_32Line      ; export function name to linker
  17.      11
  18.      12
  19.      13        0000             _Triangle_32Line PROC
  20.      14
  21.      15                     ARG dest:DWORD, xs:WORD, xe:WORD, color:WORD
  22.      16
  23.      17
  24.      18        0000  55                 push bp         ; create stack frame
  25.      19        0001  8B EC                 mov bp,sp
  26.      20
  27.      21        0003  57                 push di         ; save di
  28.      22
  29.      23
  30.      24        0004  C4 7E    06             les di, dest    ; point es:di to start of line
  31.      25        0007  03 7E    0A             add di,xs
  32.      26
  33.      27                     ; process special cases first,    i.e. lines of length 1,2,3 or 4
  34.      28
  35.      29        000A             begin:
  36.      30
  37.      31        000A  8B 46    0C             mov ax,xe         ; ax=xs-xe;
  38.      32        000D  2B 46    0A             sub ax,xs
  39.      33
  40.      34        0010  8B 4E    0E             mov cx, color   ; cx = color | color << 8
  41.      35        0013  8A E9                 mov ch,cl
  42.      36
  43.      37        0015             test_0:
  44.      38
  45.      39        0015  3D 0000             cmp ax,0         ; if (ax==0)
  46.      40        0018  75 06    90 90             jne test_1         ; else goto test_1
  47.      41
  48.      42        001C  26: 88 0D             mov es:[di],cl
  49.      43        001F  CB                 ret
  50.      44
  51.      45
  52.      46        0020             test_1:
  53.      47
  54.      48        0020  3D 0001             cmp ax,1         ; if (ax==1)
  55.      49        0023  75 06    90 90             jne test_2         ; else goto test_2
  56.      50
  57.      51        0027  26: 89 0D             mov es:[di],cx
  58.      52        002A  CB                 ret
  59.      53
  60.      54
  61.      55        002B             test_2:
  62.      56
  63. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 2
  64. qline.asm
  65.  
  66.  
  67.  
  68.      57        002B  3D 0002             cmp ax,2         ; if (ax==2)
  69.      58        002E  75 0C    90 90             jne test_3         ; else goto test_3
  70.      59
  71.      60        0032  26: 89 0D             mov es:[di],cx
  72.      61        0035  83 C7    02             add di,2
  73.      62        0038  26: 88 0D             mov es:[di],cl
  74.      63        003B  CB                 ret
  75.      64
  76.      65
  77.      66        003C             test_3:
  78.      67
  79.      68        003C  3D 0003             cmp ax,3            ; if (ax==0)
  80.      69        003F  75 0C    90 90             jne process_left_end    ; else process left end
  81.      70
  82.      71        0043  26: 89 0D             mov es:[di],cx
  83.      72        0046  83 C7    02             add di,2
  84.      73        0049  26: 89 0D             mov es:[di],cx
  85.      74        004C  CB                 ret
  86.      75
  87.      76        004D             process_left_end:
  88.      77
  89.      78        004D  8B 46    0A             mov ax,xs            ; ax=xs    & 0x03
  90.      79        0050  25 0003             and ax,03h
  91.      80
  92.      81        0053             test_l1:
  93.      82
  94.      83        0053  3D 0001             cmp ax,1            ; if (ax==1)
  95.      84        0056  75 10    90 90             jne test_l2
  96.      85
  97.      86        005A  26: 88 0D             mov es:[di], cl
  98.      87        005D  47                 inc di
  99.      88        005E  26: 89 0D             mov es:[di], cx
  100.      89
  101.      90        0061  83 46    0A 03             add xs,3            ; xs +=3
  102.      91
  103.      92        0065  EB 1F    90             jmp process_right_end
  104.      93
  105.      94        0068             test_l2:            ; if (ax==2)
  106.      95
  107.      96        0068  3D 0002             cmp ax,2
  108.      97        006B  75 0C    90 90             jne test_l3
  109.      98
  110.      99        006F  26: 89 0D             mov es:[di],cx
  111.     100
  112.     101        0072  83 46    0A 02             add xs,2            ; xs+=2
  113.     102
  114.     103        0076  EB 0E    90             jmp process_right_end
  115.     104
  116.     105
  117.     106        0079             test_l3:            ; if (ax==3)
  118.     107
  119.     108        0079  3D 0003             cmp ax,3
  120.     109        007C  75 08    90 90             jne process_right_end
  121.     110
  122.     111        0080  26: 88 0D             mov es:[di],cl
  123.     112
  124.     113        0083  FF 46    0A             inc xs            ; xs+=1
  125. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 3
  126. qline.asm
  127.  
  128.  
  129.  
  130.     114
  131.     115
  132.     116        0086             process_right_end:
  133.     117
  134.     118        0086  C4 7E    06             les di, dest        ; point    es:di to start of line
  135.     119        0089  03 7E    0C             add di,xe
  136.     120
  137.     121        008C  8B 46    0C             mov ax,xe            ; ax=xs    & 0x03
  138.     122        008F  25 0003             and ax,03h
  139.     123
  140.     124        0092             test_r0:            ; if (ax==0)
  141.     125
  142.     126        0092  3D 0000             cmp ax,0
  143.     127        0095  75 0B    90 90             jne test_r1
  144.     128
  145.     129        0099  26: 88 0D             mov es:[di],cl
  146.     130
  147.     131        009C  FF 4E    0C             dec xe            ; xe-=1
  148.     132
  149.     133        009F  EB 27    90             jmp process_middle
  150.     134
  151.     135        00A2             test_r1:            ; if (ax==1)
  152.     136
  153.     137        00A2  3D 0001             cmp ax,1
  154.     138        00A5  75 0D    90 90             jne test_r2
  155.     139
  156.     140        00A9  4F                 dec di
  157.     141        00AA  26: 89 0D             mov es:[di],cx
  158.     142
  159.     143        00AD  83 6E    0C 02             sub xe,2            ; xe-=2
  160.     144
  161.     145        00B1  EB 15    90             jmp process_middle
  162.     146
  163.     147
  164.     148        00B4             test_r2:            ; if (ax==2)
  165.     149
  166.     150        00B4  3D 0002             cmp ax,2
  167.     151        00B7  75 0F    90 90             jne process_middle
  168.     152
  169.     153        00BB  26: 88 0D             mov es:[di],cl
  170.     154        00BE  83 EF    02             sub di,2
  171.     155        00C1  26: 89 0D             mov es:[di],cx
  172.     156
  173.     157        00C4  83 6E    0C 03             sub xe,3            ; xe-=3
  174.     158
  175.     159        00C8             process_middle:
  176.     160
  177.     161
  178.     162        00C8  C4 7E    06             les di,dest        ; point    es:di to start of line
  179.     163        00CB  03 7E    0A             add di,xs
  180.     164
  181.     165        00CE  FC                 cld            ; clear    the direction of movement
  182.     166
  183.     167        00CF  66| 8B C1             mov eax, ecx        ; move the color data into eax
  184.     168        00D2  66| C1 E0 10             shl eax,16
  185.     169        00D6  66| 0B C1             or    eax,ecx
  186.     170
  187. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 4
  188. qline.asm
  189.  
  190.  
  191.  
  192.     171        00D9  8B 4E    0C             mov cx,xe            ; compute number of words to move  (xe-xs+1)/2
  193.     172        00DC  2B 4E    0A             sub cx,xs
  194.     173        00DF  41                 inc cx
  195.     174        00E0  C1 E9    02             shr cx,2            ; divide by 4
  196.     175
  197.     176        00E3  F3> 66| AB             rep stosd            ; fill the region with data
  198.     177
  199.     178        00E6  5F                 pop di            ; restore di
  200.     179        00E7  5D                 pop bp            ; fixup    stack
  201.     180
  202.     181        00E8  CB                 ret            ; return to caller
  203.     182
  204.     183        00E9             Triangle_32Line ENDP
  205. **Error** qline.asm(183) Unmatched ENDP: Triangle_32Line
  206.     184
  207.     185                     END
  208. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 5
  209. Symbol Table
  210.  
  211.  
  212.  
  213.  
  214. Symbol Name              Type     Value
  215.  
  216. ??date                  Text     "05/26/95"
  217. ??filename              Text     "qline      "
  218. ??time                  Text     "02:23:36"
  219. ??version              Number 0400
  220. @32Bit                  Text     0
  221. @CodeSize              Text     1
  222. @Cpu                  Text     0F0FH
  223. @DataSize              Text     0
  224. @FileName              Text     qline
  225. @Model                  Text     4
  226. @WordSize              Text     4
  227. @code                  Text     qline_TEXT
  228. @curseg                  Text     qline_TEXT
  229. @data                  Text     DGROUP
  230. _Triangle_32Line          Far     qline_TEXT:0000
  231. begin                  Near     qline_TEXT:000A
  232. color                  Number [BP+000E]
  233. dest                  Number [BP+0006]
  234. process_left_end          Near     qline_TEXT:004D
  235. process_middle              Near     qline_TEXT:00C8
  236. process_right_end          Near     qline_TEXT:0086
  237. test_0                  Near     qline_TEXT:0015
  238. test_1                  Near     qline_TEXT:0020
  239. test_2                  Near     qline_TEXT:002B
  240. test_3                  Near     qline_TEXT:003C
  241. test_l1                  Near     qline_TEXT:0053
  242. test_l2                  Near     qline_TEXT:0068
  243. test_l3                  Near     qline_TEXT:0079
  244. test_r0                  Near     qline_TEXT:0092
  245. test_r1                  Near     qline_TEXT:00A2
  246. test_r2                  Near     qline_TEXT:00B4
  247. xe                  Number [BP+000C]
  248. xs                  Number [BP+000A]
  249.  
  250. Groups & Segments          Bit Size Align  Combine Class
  251.  
  252. DGROUP                  Group
  253.   _DATA                  16  0000 Word      Public  DATA
  254. qline_TEXT              16  00E9 Word      Public  CODE
  255. Turbo Assembler     Version 4.0        05/26/95 02:23:36        Page 6
  256. Error Summary
  257.  
  258.  
  259.  
  260. **Error** qline.asm(4) Missing or illegal language ID
  261. **Error** qline.asm(183) Unmatched ENDP: Triangle_32Line
  262.