VirtualBox

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

Last change on this file since 90778 was 86686, checked in by vboxsync, 4 years ago

BIOS: Only use the .8086 directive when assembling using WASM; MASM no longer understands it and errors out.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1; $Id: __U4M.asm 86686 2020-10-23 13:13:34Z vboxsync $
2;; @file
3; Compiler support routines.
4;
5
6;
7; Copyright (C) 2012-2020 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; MASM (ML.EXE) is used for PXE and no longer understands the .8086 directive.
25; WASM is used for the BIOS and understands it just fine.
26ifdef __WASM__
27 .8086
28endif
29
30_TEXT segment public 'CODE' use16
31 assume cs:_TEXT
32
33;;
34; 32-bit unsigned multiplication.
35;
36; @param dx:ax Factor 1.
37; @param cx:bx Factor 2.
38; @returns dx:ax Result.
39;
40__U4M:
41 pushf
42if VBOX_BIOS_CPU ge 80386
43 .386
44 push eax
45 push edx
46 push ecx
47
48 rol eax, 16
49 mov ax, dx
50 ror eax, 16
51 xor edx, edx
52
53 shr ecx, 16
54 mov cx, bx
55
56 mul ecx ; eax * ecx -> edx:eax
57
58 pop ecx
59
60 pop edx
61 ror eax, 16
62 mov dx, ax
63 add sp, 2
64 pop ax
65 rol eax, 16
66ifdef __WASM__
67 .8086
68endif
69
70else
71 push si ; high result
72 push di ; low result
73
74 ;
75 ; dx:ax * cx:bx =
76 ;-----------------------
77 ; ax*bx
78 ; + dx*bx ; only lower 16 bits relevant.
79 ; + ax*cx ; ditto
80 ; +dx*cx ; not relevant
81 ; -------------
82 ; = dx:ax
83 ;
84
85 push ax ; stash the low factor 1 part for the 3rd multiplication.
86 mov di, dx ; stash the high factor 1 part for the 2nd multiplication.
87
88 ; multiply the two low factor "digits": ax * bx
89 mul bx
90 mov si, dx
91 xchg di, ax ; save low result and loads high factor 1 into ax for the next step
92
93 ; Multiply the low right "digit" by the high left one and add it to the high result part
94 mul bx
95 add si, ax
96
97 ; Multiply the high right "digit" by the low left on and add it ot the high result part.
98 pop ax
99 mul cx
100 add si, ax
101
102 ; Load the result.
103 mov dx, si
104 mov ax, di
105
106 pop di
107 pop si
108endif
109 popf
110 ret
111
112
113_TEXT ends
114 end
115
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use