VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS-new/support.asm@ 41668

Last change on this file since 41668 was 41654, checked in by vboxsync, 13 years ago

BIOS: Do not save registers which do not need to be saved.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1; $Id: support.asm 41654 2012-06-11 15:15:09Z vboxsync $
2;; @file
3; Compiler support routines.
4;
5
6;
7; Copyright (C) 2012 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 __U4D
23public __I4D
24public __U4M
25public _fmemset_
26public _fmemcpy_
27
28
29
30 .386p
31
32_TEXT segment public 'CODE' use16
33 assume cs:_TEXT
34
35
36;;
37; 32-bit unsigned division.
38;
39; @param dx:ax Dividend.
40; @param cx:bx Divisor.
41; @returns dx:ax Quotient.
42; cx:bx Reminder.
43;
44__U4D:
45 pushf
46 push eax
47 push edx
48 push ecx
49
50 rol eax, 16
51 mov ax, dx
52 ror eax, 16
53 xor edx, edx
54
55 shr ecx, 16
56 mov cx, bx
57
58 div ecx ; eax:edx / ecx -> eax=quotient, edx=reminder.
59
60 mov bx, dx
61 pop ecx
62 shr edx, 16
63 mov cx, dx
64
65 pop edx
66 ror eax, 16
67 mov dx, ax
68 add sp, 2
69 pop ax
70 rol eax, 16
71
72 popf
73 ret
74
75
76;;
77; 32-bit unsigned multiplication.
78;
79; @param dx:ax Factor 1.
80; @param cx:bx Factor 2.
81; @returns dx:ax Result.
82;
83__U4M:
84 pushf
85 push eax
86 push edx
87 push ecx
88
89 rol eax, 16
90 mov ax, dx
91 ror eax, 16
92 xor edx, edx
93
94 shr ecx, 16
95 mov cx, bx
96
97 mul ecx ; eax * ecx -> edx:eax
98
99 pop ecx
100
101 pop edx
102 ror eax, 16
103 mov dx, ax
104 add sp, 2
105 pop ax
106 rol eax, 16
107
108 popf
109 ret
110
111
112;;
113; memset taking a far pointer.
114;
115; cx, es may be modified; di is preserved
116;
117; @returns dx:ax unchanged.
118; @param dx:ax Pointer to the memory.
119; @param bl The fill value.
120; @param cx The number of bytes to fill.
121;
122_fmemset_:
123 push di
124
125 mov es, dx
126 mov di, ax
127 xchg al, bl
128 rep stosb
129 xchg al, bl
130
131 pop di
132 ret
133
134
135;;
136; memset taking far pointers.
137;
138; cx, es may be modified; si, di are preserved
139;
140; @returns dx:ax unchanged.
141; @param dx:ax Pointer to the destination memory.
142; @param cx:bx Pointer to the source memory.
143; @param sp+2 The number of bytes to copy (dw).
144;
145_fmemcpy_:
146 push bp
147 mov bp, sp
148 push di
149 push ds
150 push si
151
152 mov es, dx
153 mov di, ax
154 mov ds, cx
155 mov si, bx
156 mov cx, [bp + 4]
157 rep movsb
158
159 pop si
160 pop ds
161 pop di
162 leave
163 ret
164
165
166_TEXT ends
167 end
168
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