format PE console
include 'C:\Users\NanoBytes\Desktop\Projects\BOLT\bin\Debug\INCLUDE\win32ax.inc'
include 'C:\Users\NanoBytes\Desktop\Projects\BOLT\bin\Debug\INCLUDE\BOLT.inc'
Memory DD ?
Library DD ?
Return DD ?
Index DD ?
proc write_BOLT
mov ebp,esp
mov eax,[ebp+8]
stdcall getString,eax
stdcall print
mov esp,ebp
ret
endp
proc writeLn_BOLT
mov ebp,esp
setString "\n"
call loadString
push eax
mov eax,dword[ebp+8]
pop ebx
stdcall addString,eax,ebx
mov dword[ebp+8],eax
mov eax,dword[ebp+8]
push eax
push ebp
call write_BOLT
pop ebp
add esp,4
mov esp,ebp
ret
endp
proc getChar_BOLT
mov ebp,esp
sub esp,4
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,4
mov dword[ebp+-4],eax
invoke GetProcAddress, [Library], "getchar"
stdcall eax
push eax
call halt
pop eax
cinvoke wsprintf,String,'%c',eax
stdcall loadString
mov [ebp+-4],eax
mov eax,dword[ebp+-4]
mov [Return],eax
mov esp,ebp
mov eax,[Return]
ret
mov esp,ebp
sub esp,4
setString ""
call loadString
add esp,4
ret
endp
proc getText_BOLT
mov ebp,esp
sub esp,4
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,4
mov dword[ebp+-4],eax
invoke GetProcAddress, [Library], "gets"
stdcall eax,String
stdcall loadString
mov [ebp+-4],eax
mov eax,dword[ebp+-4]
mov [Return],eax
mov esp,ebp
mov eax,[Return]
ret
mov esp,ebp
sub esp,4
setString ""
call loadString
add esp,4
ret
endp
proc getNumber_BOLT
mov ebp,esp
sub esp,4
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,4
mov dword[ebp+-4],eax
invoke GetProcAddress, [Library], "gets"
stdcall eax,String
call atof
mov eax,dword[ebp+-4]
fstp qword[eax]
mov eax,[ebp+-4]
fld qword[eax]
cmp al,1
mov esp,ebp
ret
mov esp,ebp
fldz
ret
endp
proc getStroke_BOLT
mov ebp,esp
invoke GetProcAddress, [Library], "_getch"
stdcall eax
mov [Index],eax
fild [Index]
mov esp,ebp
ret
endp
proc factorial_BOLT
mov ebp,esp
sub esp,4
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,4
mov dword[ebp+-4],eax
sub esp,4
setString "1"
call atof
add esp,4
cmp al,1
mov eax,dword[ebp+-4]
fstp qword[eax]
sub esp,8
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,8
mov dword[ebp+-8],eax
sub esp,8
setString "0"
call atof
add esp,8
cmp al,1
mov eax,dword[ebp+-8]
fstp qword[eax]
Label_0:
mov eax,[ebp+-8]
fld qword[eax]
mov eax,[ebp+8]
fld qword[eax]
sub esp,8
setString "1"
call atof
add esp,8
fsubp st1, st0
xor eax,eax
fcomip st1
setne al
fcomp
cmp al,1
cmp al,1
jne Label_3
jmp Label_1
Label_2:
mov eax,dword[ebp+-8]
fld qword[eax]
fld1
faddp st1, st0
mov eax,dword[ebp+-8]
fstp qword[eax]
jmp Label_0
Label_1:
mov eax,[ebp+-8]
fld qword[eax]
sub esp,8
setString "2"
call atof
add esp,8
faddp st1, st0
cmp al,1
mov eax,dword[ebp+-4]
fld qword[eax]
fmulp st1, st0
mov eax,dword[ebp+-4]
fstp qword[eax]
jmp Label_2
Label_3:
mov eax,[ebp+-4]
fld qword[eax]
cmp al,1
mov esp,ebp
ret
mov esp,ebp
fldz
ret
endp
start:
invoke AllocConsole
invoke GetProcessHeap
mov [Memory],eax
invoke LoadLibrary,"MSVCRT.dll"
mov [Library],eax
mov ebp,esp
FSTCW word[esp+2]
or word[esp+2], 0C00h
FLDCW word[esp+2]
invoke GetProcAddress, [Library], "time"
mov ebx,eax
stdcall ebx,0
push eax
invoke GetProcAddress, [Library], "srand"
mov ebx,eax
pop eax
stdcall ebx,eax
invoke GetProcAddress, [Library], "rand"
stdcall eax
setString "Enter the angle you want to find the sine of (deg): "
call loadString
push eax
push ebp
call write_BOLT
pop ebp
add esp,4
sub esp,4
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,4
mov dword[ebp+-4],eax
sub esp,4
push ebp
call getNumber_BOLT
pop ebp
add esp,0
add esp,4
cmp al,1
mov eax,dword[ebp+-4]
fstp qword[eax]
sub esp,8
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,8
mov dword[ebp+-8],eax
mov eax,[ebp+-4]
fld qword[eax]
sub esp,8
setString "0.01745329"
call atof
add esp,8
fmulp st1, st0
cmp al,1
mov eax,dword[ebp+-8]
fstp qword[eax]
sub esp,12
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,12
mov dword[ebp+-12],eax
sub esp,12
setString "0"
call atof
add esp,12
cmp al,1
mov eax,dword[ebp+-12]
fstp qword[eax]
sub esp,16
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,16
mov dword[ebp+-16],eax
sub esp,16
setString "1"
call atof
add esp,16
cmp al,1
mov eax,dword[ebp+-16]
fstp qword[eax]
sub esp,16
setString "7"
call atof
add esp,16
cmp al,1
sub esp,20
invoke HeapAlloc,<invoke GetProcessHeap>,HEAP_ZERO_MEMORY,8
add esp,20
mov dword[ebp+-20],eax
mov eax,dword[ebp+-20]
fld qword[eax]
fld1
faddp st1, st0
mov eax,dword[ebp+-20]
fstp qword[eax]
sub esp,24
fistp dword[esp]
pop eax
mov ecx,eax
Label_4:
push ecx
mov eax,[ebp+-16]
fld qword[eax]
mov eax,[ebp+-8]
fld qword[eax]
mov eax,[ebp+-20]
fld qword[eax]
sub esp,24
setString "2"
call atof
add esp,24
fmulp st1, st0
sub esp,24
call fpow
add esp,24
mov eax,[ebp+-20]
fld qword[eax]
sub esp,24
setString "2"
call atof
add esp,24
fmulp st1, st0
fld1
fxch
@@:
fld1
fcomip st,st1
jae @f
fld st
fld1
fsubp
fxch
fmulp st2,st
jmp @b
@@:
fstp st
fdivp st1, st0
fmulp st1, st0
cmp al,1
mov eax,dword[ebp+-12]
fld qword[eax]
faddp st1, st0
mov eax,dword[ebp+-12]
fstp qword[eax]
sub esp,24
setString "1"
call atof
add esp,24
fchs
cmp al,1
mov eax,dword[ebp+-16]
fld qword[eax]
fmulp st1, st0
mov eax,dword[ebp+-16]
fstp qword[eax]
pop ecx
cmp ecx,1
je Label_5
dec ecx
mov eax,dword[ebp+-20]
fld qword[eax]
fld1
faddp st1, st0
mov eax,dword[ebp+-20]
fstp qword[eax]
jmp Label_4
Label_5:
add esp,24
sub esp,20
sub esp,20
setString "The sine of "
call loadString
add esp,20
push eax
mov eax,[ebp+-4]
fld qword[eax]
cmp al,1
sub esp,20
call ftoa
call loadString
add esp,20
pop ebx
sub esp,20
stdcall addString,ebx,eax
add esp,20
push eax
sub esp,20
setString " degrees is "
call loadString
add esp,20
pop ebx
sub esp,20
stdcall addString,ebx,eax
add esp,20
push eax
mov eax,[ebp+-12]
fld qword[eax]
cmp al,1
sub esp,20
call ftoa
call loadString
add esp,20
pop ebx
sub esp,20
stdcall addString,ebx,eax
add esp,20
push eax
push ebp
call writeLn_BOLT
pop ebp
add esp,4
add esp,20
call halt
invoke FreeLibrary,[Library]
invoke ExitProcess,0
.end start