VirtualBox

source: vbox/trunk/src/VBox/Devices/BiosCommonCode/__U4M.asm@ 81876

Last change on this file since 81876 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1; $Id: __U4M.asm 76553 2019-01-01 01:45:53Z vboxsync $
2;; @file
3; Compiler support routines.
4;
5
6;
7; Copyright (C) 2012-2019 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18
19;*******************************************************************************
20;* Exported Symbols *
21;*******************************************************************************
22public __U4M
23
24 .8086
25
26_TEXT segment public 'CODE' use16
27 assume cs:_TEXT
28
29;;
30; 32-bit unsigned multiplication.
31;
32; @param dx:ax Factor 1.
33; @param cx:bx Factor 2.
34; @returns dx:ax Result.
35;
36__U4M:
37 pushf
38if VBOX_BIOS_CPU ge 80386
39 .386
40 push eax
41 push edx
42 push ecx
43
44 rol eax, 16
45 mov ax, dx
46 ror eax, 16
47 xor edx, edx
48
49 shr ecx, 16
50 mov cx, bx
51
52 mul ecx ; eax * ecx -> edx:eax
53
54 pop ecx
55
56 pop edx
57 ror eax, 16
58 mov dx, ax
59 add sp, 2
60 pop ax
61 rol eax, 16
62 .8086
63
64else
65 push si ; high result
66 push di ; low result
67
68 ;
69 ; dx:ax * cx:bx =
70 ;-----------------------
71 ; ax*bx
72 ; + dx*bx ; only lower 16 bits relevant.
73 ; + ax*cx ; ditto
74 ; +dx*cx ; not relevant
75 ; -------------
76 ; = dx:ax
77 ;
78
79 push ax ; stash the low factor 1 part for the 3rd multiplication.
80 mov di, dx ; stash the high factor 1 part for the 2nd multiplication.
81
82 ; multiply the two low factor "digits": ax * bx
83 mul bx
84 mov si, dx
85 xchg di, ax ; save low result and loads high factor 1 into ax for the next step
86
87 ; Multiply the low right "digit" by the high left one and add it to the high result part
88 mul bx
89 add si, ax
90
91 ; Multiply the high right "digit" by the low left on and add it ot the high result part.
92 pop ax
93 mul cx
94 add si, ax
95
96 ; Load the result.
97 mov dx, si
98 mov ax, di
99
100 pop di
101 pop si
102endif
103 popf
104 ret
105
106
107_TEXT ends
108 end
109
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette