source: xtideuniversalbios/trunk/Assembly_Library/Src/Util/Math.asm@ 194

Last change on this file since 194 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
File size: 1.5 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for register operations.
3
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; Math_DivQWatSSBPbyCX
10; Parameters:
11; [SS:BP]: 64-bit unsigned divident
12; CX: 16-bit unsigned divisor
13; Returns:
14; [SS:BP]: 64-bit unsigned quotient
15; DX: 16-bit unsigned remainder
16; Corrupts registers:
17; AX
18;--------------------------------------------------------------------
19%ifndef EXCLUDE_FROM_XTIDECFG ; Not used in XTIDECFG
20ALIGN JUMP_ALIGN
21Math_DivQWatSSBPbyCX:
22 xor dx, dx
23 mov ax, [bp+6] ; Load highest divident WORD to DX:AX
24 div cx
25 mov [bp+6], ax ; Store quotient
26
27 mov ax, [bp+4]
28 div cx
29 mov [bp+4], ax
30
31 mov ax, [bp+2]
32 div cx
33 mov [bp+2], ax
34
35 mov ax, [bp]
36 div cx
37 mov [bp], ax
38 ret
39%endif
40
41
42;--------------------------------------------------------------------
43; Math_DivDXAXbyCX
44; Parameters:
45; DX:AX: 32-bit unsigned divident
46; CX: 16-bit unsigned divisor
47; Returns:
48; DX:AX: 32-bit unsigned quotient
49; BX: 16-bit unsigned remainder
50; Corrupts registers:
51; Nothing
52;--------------------------------------------------------------------
53%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
54ALIGN JUMP_ALIGN
55Math_DivDXAXbyCX: ; This is currently unused (dead code)
56 xor bx, bx
57 xchg bx, ax
58 xchg dx, ax
59 div cx
60 xchg ax, bx
61 div cx
62 xchg dx, bx
63 ret
64%endif
Note: See TracBrowser for help on using the repository browser.