; ************************************************************************** ; FILE:MATH.INC ; FUNCTION: MATH MACROS INCLUDE FILE ; AUTHOR: SEAN M. KESSLER ;**************************************************************************** round MACRO mov edx,eax ; move value into edx register and edx,0000FFFFh ; get remainder into edx register shr eax,10h ; get whole number to eax register cmp edx,7FFFh ; if remainder > 32767, increment eax db 7Eh ; the next two bytes comprise "jle +2" (ie) db 01h ; jump passed the increment esx insruction inc eax ; increment value in eax ENDM absolute MACRO varOne LOCAL @@return cmp varOne,00h ; check varOne with zero jge @@return ; if it's greater than or equal then return neg varOne ; otherwise make it positive @@return: ENDM multiply MACRO varOne,varTwo mov eax,varOne ; move varOne into eax register mov edx,varTwo ; move varTwo into edx register imul eax,edx ; perform multiply, result to eax ENDM mulshort MACRO varOne,varTwo ; multiply r/m16->eax mov ax,varOne ; move varOne into ax register mov dx,varTwo ; move varTwo into dx register and eax,0FFFFh ; clear out high word of eax register and edx,0FFFFh ; clear out high word of edx register imul eax,edx ; perform multiply, result to eax ENDM divide MACRO varOne,varTwo ; divide MACRO varOne,varTwo mov eax,varOne ; move varOne into eax register mov ebx,varTwo ; move varTwo into ebx register cdq ; convert doubleword in eax to quadword at edx:eax idiv ebx ; divide eax/ebx result to eax, remainder to edx ENDM divshort MACRO varOne,varTwo ; divide r/m16->eax mov ax,varOne ; move varOne into ax register mov bx,varTwo ; move varTwo into bx register and eax,0FFFFh ; clear out high word of eax register and ebx,0FFFFh ; clear out high word of ebx register cdq ; convert doubleword in eax to quadword at edx:eax idiv ebx ; divide eax/ebx result to eax, remainder to edx ENDM