MP-Test
- From: nospam@xxxxxxxxxxxx (Spam Killer)
- Date: Sat, 28 Jan 2006 17:38:44 GMT
; As it is pretty hard to test the output of routines with such a
; large range, could some of you guys/gals give it a try by typing in
; some numbers in the upper text-box, hit OK, compare with the lower,
; and tell me if any wrong number comes out. The input-box
; automatically scrolls down when the bottom is reached. The highest
; possible number is 2^{16384} - 1. Thanks in advance!
TITLE data
[IDC_EDIT 100] [IDC_INPUT 101] [IDC_OK 200] [IDC_OVERFLOW 500]
[<8 number: d$ 512] [y: d$ 0 #512]
[<8 copy: d$ 0 #513] [tmp: d$ 0 #570]
[input: b$ ? #5_128] [output: b$ ? #5_128]
[overflow: b$ "Overflow!", 0] [empty: b$ " ", 0]
[Dialog: D$ 090CE08C0 0 U$ 04 0 0 0189 0100 0 '' 0
'Multiple Precision Conversion' 0 08 'Fixedsys' 0]
[Control0000: D$ 050A02044 0 U$ 06 078 017C 073 064 0FFFF 081 '' 0 0]
[Control0001: D$ 050000000 0 U$ 0A4 0F0 038 0C 0C8 0FFFF 080
'OK' 0 0]
[Control0002: D$ 050A12044 0 U$ 06 02 017C 073 065 0FFFF 081 '' 0 0]
[Control0003: D$ 050800202 0 U$ 0E2 0F0 027 0C 01F4 0FFFF 082 '' 0 0]
TITLE code
Main: fninit
xor ebx ebx
call 'user32.DialogBoxIndirectParamA', ebx, Dialog,
ebx,
DialogProc, ebx
ExitProg: call 'kernel32.GetLastError'
call 'kernel32.ExitProcess', eax
align 16
subrt asc2mpi:
push eax ebp
mov d$esi 1, d$esi+4 0
mov ebp 1_000_000_000
xor edx edx | div d${d$ 9} | mov ecx eax
test edx edx | jz L1>
call getdigits | mov d$esi+4 edi
L1: test ecx ecx | jz L3>
L2: mov edx 9 | call getdigits | call smul1 | jc L3>
L4: dec ecx | jnz L2
L3: pop ebp eax
ret
ends asc2mpi
align 16
subrt getdigits:
xor edi edi
L2: mov al b$ebx | inc ebx | and eax 0f
lea edi d$edi*4+edi | lea edi d$edi*2+eax
dec edx | jnz L2
ret
ends getdigits
align 16
subrt smul1:
push eax ecx edx esi
mov ecx d$esi | lea esi d$esi+ecx*4+4
neg ecx | jz S2>
S1: mov eax d$esi+ecx*4 | mul ebp
add eax edi | mov edi edx | adc edi 0
mov d$esi+ecx*4 eax
inc ecx | jnz S1
test edi edi | jz S2>
mov esi d$esp, ecx d$esi | inc ecx
cmp ecx 513 | cmc | jc S2>
mov d$esi+ecx*4 edi, d$esi ecx
S2: pop esi edx ecx eax
ret
ends smul1
align 16
subrt mpi2asc:
cmp d$esi 513 | cmc | jc S9>>
push eax ebx ecx edx esi ebp
mov ecx d$esi, edi copy | inc ecx | rep movsd
mov ebx 1_000_000_000, esi copy | xor edi edi
S1: mov ecx d$esi | xor edx edx, ebp ebp
S2: mov eax d$esi+ecx*4 | div ebx | mov d$esi+ecx*4 eax
or ebp eax | jnz S6> | dec d$esi
S6: dec ecx | jnz S2
mov d$tmp+edi*4 edx | inc edi | test ebp ebp | jnz S1
lea esi d$edi-1 | mov edi output, eax d$tmp+esi*4
call dword2mem | jmp S5>
S3: mov edx d$tmp+esi*4, eax 1_000_000_000 | div eax
mov ecx (-9)
S4: mul d${d$ 10} | or dl 030 | mov b$edi dl | inc edi
inc ecx | jnz S4
S5: dec esi | jns S3 | mov b$edi 0, edi output | clc
pop ebp esi edx ecx ebx eax
S9: ret
ends mpi2asc
align 16
subrt dword2mem:
xor ecx ecx
S1: xor edx edx | div d${d$ 10}| push edx | inc ecx
test eax eax | jnz S1
S2: pop edx | or dl 030 | mov b$edi dl | inc edi
dec ecx | jnz S2
ret
ends dword2mem
align 16
proc DialogProc: ; Tag Dialog 10
arguments @hwndDlg @uMsg @wParam @lParam
uses ebx esi edi
mov eax d@uMsg
P2: cmp eax &WM_COMMAND | jne P3>>
mov eax d@wParam, edx eax | shr edx 16
cmp dx &BN_CLICKED | jne L9>>
L6: cmp ax IDC_OK | jne L9>>
call 'user32.SetDlgItemTextA', d@hwndDlg,
IDC_OVERFLOW, empty
call 'user32.GetDlgItemTextA', d@hwndDlg, IDC_INPUT,
input, 5_000
cmp eax 1 | jc L9> | cmp eax 4_933 | ja L5>
mov ebx input, esi number | call asc2mpi | jnc L4>
L5: call 'user32.SetDlgItemTextA', d@hwndDlg,
IDC_OVERFLOW, overflow
jmp L8>
L4: call mpi2asc | jc L5
call 'user32.SetDlgItemTextA', d@hwndDlg, IDC_EDIT, edi
jmp L8>
P3: cmp eax &WM_CLOSE | jne L9>
L1: call 'user32.EndDialog', d@hwndDlg, 0
L8: mov eax &TRUE | jmp P9>
L9: mov eax &FALSE
EndP
TITLE macros
[subrt | #1] [ends | nope]
[push | push #1 | #+1] [pop | pop #1 | #+1] [mov | mov #1 #2 | #+2]
[inc | inc #1 | #+1] [dec | dec #1 | #+1] [xor | xor #1 #2 | #+2]
[call | push #L>2 | call #1]
[Proc | &1=0 | &2=0 | &3= | #1 | push ebp | mov ebp esp]
[Arguments | {#1 Arg#x} | #+1 | &1=SizeOf#x]
[Argument | {#1 Arg#x} | #+1 | &1=SizeOf#x]
[Uses | push #1>L | &3=pop #L>1]
[EndP | P9: | &3 | mov esp ebp | pop ebp | ret &1]
[Arg1 ebp+8 Arg2 ebp+12 Arg3 ebp+16 Arg4 ebp+20 Arg5 ebp+24
Arg6 ebp+28 Arg7 ebp+32 Arg8 ebp+36 Arg9 ebp+40 Arg10
ebp+44]
[SizeOf1 4 SizeOf2 8 SizeOf3 12 SizeOf4 16 SizeOf5 20
SizeOf6 24 SizeOf7 28 SizeOf8 32 SizeOf9 36 SizeOf10 40]
.
- Prev by Date: Re: Two Click disassembly/reassembly
- Next by Date: It has been done before
- Previous by thread: Re: Hello all
- Next by thread: It has been done before
- Index(es):
Relevant Pages
|