; File name : Math.inc ; Project name : Assembly Library ; Created date : 12.8.2010 ; Last update : 12.8.2010 ; Author : Tomi Tilli ; Description : Math related macros. %ifndef MATH_INC %define MATH_INC FALSE EQU 0 TRUE EQU 1 ;-------------------------------------------------------------------- ; MIN_U Unsigned comparison ; MIN_S Signed comparison ; Parameters: ; %1: Operand 1 ; %2: Operand 2 ; Returns: ; %1: Lesser operand ; Corrupts registers: ; Nothing ;-------------------------------------------------------------------- %macro MIN_U 2 cmp %1, %2 ; Is %1 smaller? jb %%Return ; If so, return mov %1, %2 ; Copy %2 to %1 ALIGN JUMP_ALIGN %%Return: %endmacro %macro MIN_S 2 cmp %1, %2 ; Is %1 smaller? jl %%Return ; If so, return mov %1, %2 ; Copy %2 to %1 ALIGN JUMP_ALIGN %%Return: %endmacro ;-------------------------------------------------------------------- ; MAX_U Unsigned comparison ; MAX_S Signed comparison ; Parameters: ; %1: Operand 1 ; %2: Operand 2 ; Returns: ; %1: Lesser operand ; Corrupts registers: ; Nothing ;-------------------------------------------------------------------- %macro MAX_U 2 cmp %1, %2 ; Is %1 greater? ja %%Return ; If so, return mov %1, %2 ; Copy %2 to %1 ALIGN JUMP_ALIGN %%Return: %endmacro %macro MAX_S 2 cmp %1, %2 ; Is %1 greater? jg %%Return ; If so, return mov %1, %2 ; Copy %2 to %1 ALIGN JUMP_ALIGN %%Return: %endmacro %endif ; MATH_INC