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

  1. Turbo Assembler     Version 4.0        05/26/95 02:23:32        Page 1
  2. wline.asm
  3.  
  4.  
  5.  
  6.       1
  7.       2                     ; this    function draws a line from from    xs to xe using 16 bit dat movement
  8.       3
  9.       4
  10.       5        0000             .MODEL    MEDIUM               ; use medium memory model C function names
  11.       6
  12.       7        0000             .CODE                 ; begin the code segment
  13.       8
  14.       9                     .386
  15.      10
  16.      11                     PUBLIC    _Triangle_16Line      ; export function name to linker
  17.      12
  18.      13
  19.      14        0000             _Triangle_16Line PROC
  20.      15
  21.      16                     ARG dest:DWORD, xs:WORD, xe:WORD, color:WORD
  22.      17
  23.      18
  24.      19        0000             begin:
  25.      20
  26.      21        0000  55                 push bp               ; create    stack frame
  27.      22        0001  8B EC                 mov bp,sp
  28.      23
  29.      24        0003  57                 push di               ; save this guy
  30.      25
  31.      26
  32.      27        0004  C4 7E    06             les di,dest           ; point es:di to    start of line
  33.      28        0007  03 7E    0A             add di,xs
  34.      29
  35.      30        000A  8B 4E    0E             mov cx, color           ; cx = color | color << 8
  36.      31        000D  8A E9                 mov ch,cl
  37.      32
  38.      33        000F             process_left_end:
  39.      34
  40.      35        000F  8B 46    0A             mov ax,xs               ; ax=xs & 0x01
  41.      36        0012  25 0001             and ax,01h
  42.      37
  43.      38        0015             test_l1:
  44.      39
  45.      40        0015  3D 0001             cmp ax,1               ; if (ax==1)
  46.      41        0018  75 08    90 90             jne process_right_end
  47.      42
  48.      43        001C  26: 88 0D             mov es:[di], cl           ; plot pixel
  49.      44        001F  FF 46    0A             inc xs               ; xs++
  50.      45
  51.      46        0022             process_right_end:
  52.      47
  53.      48        0022  C4 7E    06             les di,dest           ; point es:di to    start of line
  54.      49        0025  03 7E    0C             add di,xe
  55.      50
  56.      51        0028  8B 46    0C             mov ax,xe               ; ax=xs & 0x01
  57.      52        002B  25 0001             and ax,01h
  58.      53
  59.      54        002E             test_r0:               ; if (ax==0)
  60.      55
  61.      56        002E  3D 0000             cmp ax,0
  62.      57        0031  75 08    90 90             jne process_middle
  63. Turbo Assembler     Version 4.0        05/26/95 02:23:32        Page 2
  64. wline.asm
  65.  
  66.  
  67.  
  68.      58
  69.      59        0035  26: 88 0D             mov es:[di],cl           ; plot pixel
  70.      60
  71.      61        0038  FF 4E    0C             dec xe               ; xe-=1
  72.      62
  73.      63        003B             process_middle:
  74.      64
  75.      65
  76.      66        003B  C4 7E    06             les di,dest           ; point es:di to    start of line
  77.      67        003E  03 7E    0A             add di,xs
  78.      68
  79.      69        0041  FC                 cld               ; clear the direction of    movement
  80.      70
  81.      71        0042  8B C1                 mov ax, cx               ; move the color    data into eax
  82.      72
  83.      73        0044  8B 4E    0C             mov cx,xe               ; compute number    of words to move  (xe-xs+1)/2
  84.      74        0047  2B 4E    0A             sub cx,xs
  85.      75        004A  41                 inc cx
  86.      76        004B  D1 E9                 shr cx,1               ; divide    by 2
  87.      77
  88.      78        004D  F3> AB             rep stosw               ; fill the region with data
  89.      79
  90.      80
  91.      81        004F  5F                 pop di               ; restore di
  92.      82        0050  5D                 pop bp               ; fixup stack
  93.      83
  94.      84        0051  CB                 ret               ; return    to caller
  95.      85
  96.      86        0052             _Triangle_16Line ENDP
  97.      87
  98.      88                     END
  99. Turbo Assembler     Version 4.0        05/26/95 02:23:32        Page 3
  100. Symbol Table
  101.  
  102.  
  103.  
  104.  
  105. Symbol Name              Type     Value
  106.  
  107. ??date                  Text     "05/26/95"
  108. ??filename              Text     "wline      "
  109. ??time                  Text     "02:23:32"
  110. ??version              Number 0400
  111. @32Bit                  Text     0
  112. @CodeSize              Text     1
  113. @Cpu                  Text     0F0FH
  114. @DataSize              Text     0
  115. @FileName              Text     wline
  116. @Interface              Text     00h
  117. @Model                  Text     4
  118. @WordSize              Text     4
  119. @code                  Text     wline_TEXT
  120. @curseg                  Text     wline_TEXT
  121. @data                  Text     DGROUP
  122. @stack                  Text     DGROUP
  123. _Triangle_16Line          Far     wline_TEXT:0000
  124. begin                  Near     wline_TEXT:0000
  125. color                  Number [DGROUP:BP+000E]
  126. dest                  Number [DGROUP:BP+0006]
  127. process_left_end          Near     wline_TEXT:000F
  128. process_middle              Near     wline_TEXT:003B
  129. process_right_end          Near     wline_TEXT:0022
  130. test_l1                  Near     wline_TEXT:0015
  131. test_r0                  Near     wline_TEXT:002E
  132. xe                  Number [DGROUP:BP+000C]
  133. xs                  Number [DGROUP:BP+000A]
  134.  
  135. Groups & Segments          Bit Size Align  Combine Class
  136.  
  137. DGROUP                  Group
  138.   _DATA                  16  0000 Word      Public  DATA
  139. wline_TEXT              16  0052 Word      Public  CODE
  140.