
;MACROS by Ron Thomas
;---------------------------------------------------------------------------
LOWORD	MACRO bigword		;; Retrieves the low word from double word argument

	mov	eax,bigword
	and	eax,0FFFFh	;; Get low word 
	ENDM

HIWORD	MACRO bigword  		;; Retrieves the high word from double word 

	mov	eax,bigword
	shr	eax,16		;; Shift 16 for high word to set to high word
				
	ENDM

return MACRO arg
        mov eax, arg
        ret
      ENDM

M2M	MACRO   arg1, arg2
	
	push	arg2
	pop	arg1

	ENDM
	
RGB	MACRO red, green, blue	;; Get composite number from red green and blue bytes 

	mov	al,blue			;; ,,,blue	
	shl	eax,8			;; ,,blue,

	add	al,green		;; ,,blue,green
	shl	eax,8			;; ,blue,green,
	add	al,red			;; ,blue,green,red
	and	eax,0FFFFFFh		;; Mask out top byte to complete COLORREF dword 

	ENDM

MAX	MACRO   word1, word2	;; Return the maximum of 2 integers in eax

	mov	ecx,word2	
	mov	eax,word1

	.IF	eax < ecx
	   mov	eax,word2	;; Set word2 as max
	.ENDIF

	ENDM

MIN	MACRO	word1, word2	;; Return the minimum of 2 integers in eax

	mov	ecx,word2
	mov	eax,word1

	.IF	eax > ecx
	   mov	eax,word2	;; Set word2 as min
	.ENDIF

	ENDM
;---------------------------------------------------------------------------

