source: xtideuniversalbios/trunk/Assembly_Library/Inc/Math.inc @ 41

Last change on this file since 41 was 41, checked in by aitotat, 14 years ago

Initial commit for Assembly Library.

File size: 1.5 KB
Line 
1; File name     :   Math.inc
2; Project name  :   Assembly Library
3; Created date  :   12.8.2010
4; Last update   :   12.8.2010
5; Author        :   Tomi Tilli
6; Description   :   Math related macros.
7%ifndef MATH_INC
8%define MATH_INC
9
10FALSE       EQU     0
11TRUE        EQU     1
12
13
14;--------------------------------------------------------------------
15; MIN_U     Unsigned comparison
16; MIN_S     Signed comparison
17;   Parameters:
18;       %1:     Operand 1
19;       %2:     Operand 2
20;   Returns:
21;       %1:     Lesser operand
22;   Corrupts registers:
23;       Nothing
24;--------------------------------------------------------------------
25%macro MIN_U 2
26    cmp     %1, %2              ; Is %1 smaller?
27    jb      %%Return            ;  If so, return
28    mov     %1, %2              ; Copy %2 to %1
29ALIGN JUMP_ALIGN
30%%Return:
31%endmacro
32
33%macro MIN_S 2
34    cmp     %1, %2              ; Is %1 smaller?
35    jl      %%Return            ;  If so, return
36    mov     %1, %2              ; Copy %2 to %1
37ALIGN JUMP_ALIGN
38%%Return:
39%endmacro
40
41
42;--------------------------------------------------------------------
43; MAX_U     Unsigned comparison
44; MAX_S     Signed comparison
45;   Parameters:
46;       %1:     Operand 1
47;       %2:     Operand 2
48;   Returns:
49;       %1:     Lesser operand
50;   Corrupts registers:
51;       Nothing
52;--------------------------------------------------------------------
53%macro MAX_U 2
54    cmp     %1, %2              ; Is %1 greater?
55    ja      %%Return            ;  If so, return
56    mov     %1, %2              ; Copy %2 to %1
57ALIGN JUMP_ALIGN
58%%Return:
59%endmacro
60
61%macro MAX_S 2
62    cmp     %1, %2              ; Is %1 greater?
63    jg      %%Return            ;  If so, return
64    mov     %1, %2              ; Copy %2 to %1
65ALIGN JUMP_ALIGN
66%%Return:
67%endmacro
68
69
70%endif ; MATH_INC
Note: See TracBrowser for help on using the repository browser.