; Static Name Aliases ; TITLE testa.asm NAME testa .386p include callconv.inc EXTRNP _DivMarker,0 _DATA SEGMENT DWORD USE32 PUBLIC 'DATA' public _DivOperand, _DivRegPointer, _DivRegScaler, _ExceptEip, _ExceptEsp _DivOperand dd ? _DivRegPointer dd ? _DivRegScaler dd ? _ExceptEip dd ? _ExceptEsp dd ? public _TestTable, _TestTableCenter _TestTable dd 64 dup (?) _TestTableCenter dd 64 dup (?) _DATA ENDS DivTest macro div,reg,type,labelmod ; public &div&_&type&_®&labelmod - too many labels &div&_&type&_®&labelmod: endm endtest macro call Marker dd 0CCCCCCCCh ; marker for expcetion ; handler to find next test endm REGDiv macro type, reglist irp reg, DivTest div, reg, type, _reg mov eax, 7f7f7f7fh mov edx, eax mov reg, type ptr _DivOperand div reg endtest DivTest idiv, reg, type, _reg mov eax, 7f7f7f7fh mov edx, eax mov reg, type ptr _DivOperand idiv reg endtest endm endm PTRDiv macro typelist irp type, DivTest div, reg, type, _ptr mov edx, _DivOperand ifidni , mov byte ptr _TestTableCenter, dl else ifidni , mov word ptr _TestTableCenter, dx else mov dword ptr _TestTableCenter, edx endif endif mov eax, 7f7f7f7fh mov edx, eax div type ptr _TestTableCenter endtest DivTest idiv, reg, type, _ptr mov edx, _DivOperand ifidni , mov byte ptr _TestTableCenter, dl else ifidni , mov word ptr _TestTableCenter, dx else mov dword ptr _TestTableCenter, edx endif endif mov eax, 7f7f7f7fh mov edx, eax idiv type ptr _TestTableCenter endtest endm endm REGDivP1 macro type, offset, divpointer, labelmod, reglist irp reg, DivTest div, reg, type, labelmod mov eax, divpointer mov edx, _DivOperand ifidni , mov byte ptr [eax + offset], dl else ifidni , mov word ptr [eax + offset], dx else mov dword ptr [eax + offset], edx endif endif mov eax, 7f7f7f7fh mov edx, eax mov reg, divpointer div type ptr [reg + offset] endtest DivTest idiv, reg, type, labelmod mov eax, divpointer mov edx, _DivOperand ifidni , mov byte ptr [eax + offset], dl else ifidni , mov word ptr [eax + offset], dx else mov dword ptr [eax + offset], edx endif endif mov eax, 7f7f7f7fh mov edx, eax mov reg, divpointer idiv type ptr [reg + offset] endtest endm endm REGDivSIB1 macro type, offset, divpointer, labelmod, toscale, scaler, reglist irp reg, DivTest div, reg, type, labelmod push ebx mov eax, divpointer mov edx, _DivOperand mov ebx, _DivRegScaler ifidni , mov byte ptr [ebx * toscale + eax + offset], dl else ifidni , mov word ptr [ebx * toscale + eax + offset], dx else mov dword ptr [ebx * toscale + eax + offset], edx endif endif pop ebx mov eax, 7f7f7f7fh mov edx, eax mov reg, divpointer mov scaler, _DivRegScaler div type ptr [scaler * toscale + reg + offset] endtest DivTest idiv, reg, type, labelmod push ebx mov eax, divpointer mov edx, _DivOperand mov ebx, _DivRegScaler ifidni , mov byte ptr [ebx * toscale + eax + offset], dl else ifidni , mov word ptr [ebx * toscale + eax + offset], dx else mov dword ptr [ebx * toscale + eax + offset], edx endif endif pop ebx mov eax, 7f7f7f7fh mov edx, eax mov reg, divpointer mov scaler, _DivRegScaler idiv type ptr [scaler * toscale + reg + offset] endtest endm endm REGDivP macro typelist, reglist irp type, REGDivP1 type, 0, _DivRegPointer, _d, REGDivP1 type, 1, _DivRegPointer, _p, REGDivP1 type, -1, _DivRegPointer, _m, REGDivP1 type, _TestTableCenter, 0, _rd, REGDivP1 type, _TestTableCenter, 1, _rp, REGDivP1 type, _TestTableCenter, -1, _rm, endm endm REGDivSIB macro typelist, scaler, reglist irp type, REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d, 1, scaler, REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p, 1, scaler, REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m, 1, scaler, REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_rd, 1, scaler, REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_rp, 1, scaler, REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_rm, 1, scaler, ;--- REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d2, 2, scaler, REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p2, 2, scaler, REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m2, 2, scaler, REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r2d, 2, scaler, REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r2p, 2, scaler, REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r2m, 2, scaler, ;--- REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d4, 4, scaler, REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p4, 4, scaler, REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m4, 4, scaler, REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r4d, 4, scaler, REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r4p, 4, scaler, REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r4m, 4, scaler, ;--- REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d8, 8, scaler, REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p8, 8, scaler, REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m8, 8, scaler, REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r8d, 8, scaler, REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r8p, 8, scaler, REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r8m, 8, scaler, endm endm _TEXT SEGMENT DWORD PUBLIC USE32 'CODE' ; Start 32 bit code ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING cPublicProc _TestDiv ; save c runtime registers push ebp push ebx push esi push edi ; prime outer loop with initial exception endtest ; start of div test PTRDiv REGDiv , REGDiv , REGDiv , REGDivP , REGDivP , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , REGDivSIB , , ; end of test pop edi pop esi pop ebx pop ebp stdRET _TestDiv stdENDP _TestDiv cPublicProc Marker pop eax mov _ExceptEip, eax mov _ExceptEsp, esp stdCall _DivMarker int 3 stdENDP Marker _TEXT ENDS END