VirtualBox

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

Last change on this file since 60484 was 60484, checked in by vboxsync, 9 years ago

PCBIOS: split up the support.asm file and implemented 32-bit division for pre-386 targets in C using uint32.h (derived from uint128.h via uint64.h).

  • 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 60484 2016-04-14 09:25:51Z vboxsync $
2;; @file
3; Compiler support routines.
4;
5
6;
7; Copyright (C) 2012-2015 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 bp
66 mov bp, sp
67 push si ; high result
68 push di ; low result
69
70 ;
71 ; dx:ax * cx:bx =
72 ;-----------------------
73 ; ax*bx
74 ; + dx*bx ; only lower 16 bits relevant.
75 ; + ax*cx ; ditto
76 ; +dx*cx ; not relevant
77 ; -------------
78 ; = dx:ax
79 ;
80
81 push ax ; stash the low factor 1 part for the 3rd multiplication.
82 mov di, dx ; stash the high factor 1 part for the 2nd multiplication.
83
84 ; multiply the two low factor "digits": ax * bx
85 mul bx
86 mov si, dx
87 xchg di, ax ; save low result and loads high factor 1 into ax for the next step
88
89 ; Multiply the low right "digit" by the high left one and add it to the high result part
90 mul bx
91 add si, ax
92
93 ; Multiply the high right "digit" by the low left on and add it ot the high result part.
94 pop ax
95 mul cx
96 add si, ax
97
98 ; Load the result.
99 mov dx, si
100 mov ax, di
101
102 pop di
103 pop si
104endif
105 popf
106 ret
107
108
109_TEXT ends
110 end
111
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