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

  1. Turbo Assembler     Version 4.0        05/26/95 02:24:06        Page 1
  2. fpdiv.asm
  3.  
  4.  
  5.  
  6.       1
  7.       2                     ; this    function uses 64 bit math to divide two    numbers    in 32 bit 16:16
  8.       3                     ; fixed point format
  9.       4
  10.       5        0000             .MODEL    MEDIUM            ; use medium memory    model C    function names
  11.       6
  12.       7                     .386
  13.       8
  14.       9        0000             .CODE                  ;    begin the code segment
  15.      10
  16.      11                     PUBLIC    _FP_Div              ;    export function    name to    linker
  17.      12
  18.      13
  19.      14        0000             _FP_Div PROC
  20.      15
  21.      16                     ARG dividend:DWORD, divisor:DWORD
  22.      17
  23.      18        0000  55                 push bp          ;    create stack frame
  24.      19        0001  8B EC                 mov bp,sp
  25.      20
  26.      21        0003  66| 8B 46 06             mov eax,dividend ;    move dividend into eax
  27.      22        0007  66| 99             cdq          ;    convert    eax into edx:eax using sign extension
  28.      23        0009  66| 0F A4 C2 10         shld edx,eax,16  ;    shift edx:eax 16 bits to the left in so    that
  29.      24                                  ;    result is in fixed point
  30.      25        000E  66| C1 E0 10             sal eax,16          ;    but manually shift eax since shld doesn't change the
  31.      26                                  ;    source register    (pretty    stupid!)
  32.      27
  33.      28        0012  66| F7 7E 0A             idiv divisor     ;    perform    divison
  34.      29
  35.      30        0016  66| 0F A4 C2 10         shld edx,eax,16  ;    move result into dx:ax since it's in eax
  36.      31
  37.      32        001B  5D                 pop bp          ;    fixup stack
  38.      33
  39.      34        001C  CB                 ret          ;    return to caller
  40.      35
  41.      36        001D             _FP_Div ENDP
  42.      37
  43.      38                     END
  44. Turbo Assembler     Version 4.0        05/26/95 02:24:06        Page 2
  45. Symbol Table
  46.  
  47.  
  48.  
  49.  
  50. Symbol Name              Type     Value
  51.  
  52. ??date                  Text     "05/26/95"
  53. ??filename              Text     "fpdiv      "
  54. ??time                  Text     "02:24:05"
  55. ??version              Number 0400
  56. @32Bit                  Text     0
  57. @CodeSize              Text     1
  58. @Cpu                  Text     0F0FH
  59. @DataSize              Text     0
  60. @FileName              Text     fpdiv
  61. @Interface              Text     00h
  62. @Model                  Text     4
  63. @WordSize              Text     2
  64. @code                  Text     fpdiv_TEXT
  65. @curseg                  Text     fpdiv_TEXT
  66. @data                  Text     DGROUP
  67. @stack                  Text     DGROUP
  68. _FP_Div                  Far     fpdiv_TEXT:0000
  69. dividend              Number [DGROUP:BP+0006]
  70. divisor                  Number [DGROUP:BP+000A]
  71.  
  72. Groups & Segments          Bit Size Align  Combine Class
  73.  
  74. DGROUP                  Group
  75.   _DATA                  16  0000 Word      Public  DATA
  76. fpdiv_TEXT              16  001D Word      Public  CODE
  77.