📄 ewcalc.asm
字号:
title Assembler Calculator
comment '======================================================|'
comment '* EWCalc v1.0 *'
comment '* Copyright (r) Ewayne L. Wagner, All Rights Reserved.*'
comment '* Unless you can improve on the program and send me *'
comment '* the changes. yooper@kalamazoo.net *'
comment '======================================================|'
.586
.model flat, STDCALL
option casemap :none ; case sensitive
include \MASM32\include\WINDOWS.inc
include \MASM32\include\USER32.inc
include \MASM32\include\KERNEL32.inc
include \MASM32\include\GDI32.inc
include \MASM32\include\COMCTL32.inc
; include \MASM32\include\DSPMACRO.asm
includelib \MASM32\LIB\USER32.lib
includelib \MASM32\LIB\KERNEL32.lib
includelib \MASM32\LIB\GDI32.lib
includelib \MASM32\LIB\COMCTL32.lib
MOVmd MACRO Var1, Var2
push Var2
pop Var1
ENDM
.data
FontName db 'Courier New',0
FontNamep db 'Courier',0
FontName1 db 'Times New Roman',0
FmtA db '%lu',0 ; output as ascii string
FmtH db '%lX',0 ; output as hex UC
PLBuff db 50 dup(?),0
PRBuff db 50 dup(?),0
HLBuff db 50 dup(?),0
HRBuff db 50 dup(?),0
LBuff db 50 dup(?),0
RBuff db 50 dup(?),0
ConvH db 120 dup(?),0
ConvI db 120 dup(?),0
ConvO db 120 dup(?),0
Buff db 120 dup(?),0
Clear db 50 dup(' '),0
Zeros db 64 dup('0'),0
AppName db 'ASM CALCULATOR',0
class db 'Calculator',0
TB02class db 'TB01',0
ToolClass db 'ToolbarWindow32',0
ErrorMsg db '** The output is out of range ** ',0
szPaste db 'Your Paste Selection Is Out Of'
db 0Dh,0Ah
db 'Range For The Base Setting!',0
TB db ' Calculator v1.0 Written in Assembler',0
Info db 38 dup(' ')
db 'Most of the functions are self explanatory.'
db 0Dh,0Ah,0Dh,0Ah
db 'There Are Three Two Step Functions.'
db 0Dh,0Ah
db '(1). X**n Enter the base number click the X**n button enter the exponent click =.'
db 0Dh,0Ah
db '(2). HYP Enter the X number click the HYP button enter the Y number click =.'
db 0Dh,0Ah
db '(3). % Enter the first number click the X button enter the second number click %.'
db 0Dh,0Ah
db 'Or Enter the first number click the +,-,x or div button enter the % number click % click =.',0
EditPT db 'EDIT',0
Butt db 'BUTTON',0
Stat db 'STATIC',0
ButtT1 db 'Push',0
float db 'Floating Point',0
arc db 'Arc',0
BackS db 'Back Space',0
CE db 'CE',0
CLR db 'C',0
DegT db 'Deg',0
RadT db 'Rad',0
DecT db 'Dec',0
HexT db 'Hex',0
OctT db 'Oct',0
BinT db 'Bin',0
Pi db '3.141592653589793238',0 ;4626433832795',0
Period db '.',0
Zero db '0',0
One db '1',0
M db 'M',0
S db '-',0
PO db '+',0
SO db '-',0
MO db 'x',0
DO db '/',0
EO db '=',0
operator db ?
Work dd 0
CW WORD 10
CWRound WORD 037fh
CWNoRound WORD 0f7fh
RNum10 REAL10 ?
RWrk10 REAL10 ?
RMem10 REAL10 ?
RDeg10 REAL10 0.01745329252
RRad10 REAL10 57.2957795130
Temp10 REAL10 ?
QW dq 0
; dwords (1 - 4 Intergers) (5 - 8 Decimals)
; (9 = Num of intergers) (10 = Num of decimals)
; (11 = Num of leading zeros) (12 = Minus)
A dd 0,0,0,0,0,0,0,0
B dd 0,0,0,0,0,0,0,0
D dd 0,0,0,0,0,0,0,0,0,0,0,0
R dd 0,0,0,0,0,0,0,0,0,0,0,0
R1 dd 0,0,0,0
R2 dd 0,0,0,0
R3 dd 0,0,0,0
R4 dd 0,0,0,0,0,0,0,0
R5 dd 0,0,0,0,0,0,0,0,0,0
PT dd 0,0,0,0,0,0,0,0,0,0,0,0
MEM dd 0,0,0,0,0,0,0,0,0,0,0,0
Sav dd 0,0,0,0,0,0,0,0,0,0,0,0
RH dd 0,0,0,0,0,0,0,0,0,0,0,0
Modulo dd 0
HeadC dd 00ff0000h
TextC dd 00000000h
BackGC dd 00b1987ch
hInst dd 0
hSave dd 0
hWnd dd 0
hMenu dd 0
hAccel dd 0
hFont dd 0
hDspF dd 0
CommandLine dd 0
hEDC dd 0
hEdit dd 0
hDspl dd 0
hFloat dd 0
hArc dd 0
hMem dd 0
hBkSp dd 0
hOpr dd 0
hCE dd 0
hCLR dd 0
hDeg dd 0
hRad dd 0
hDec dd 0
hHex dd 0
hOct dd 0
hBin dd 0
hTB01 dd 0
hTB02 dd 0
hTB03 dd 0
hTB04 dd 0
hTB05 dd 0
SubEdit dd 0
SubTool dd 0
sebx dd 0
sedi dd 0
sesi dd 0
Float dd 0
First dd 0
sw1 dd 0
sw2 dd 0
Min dd 0
Key dd 0
HPress dd 0
NPress dd 0
RPress dd 0
BPress dd 0
Branch dd 0
Len dd 0
HLen dd 0
w1 dd 0
w2 dd 0
XP dd 0
YP dd 0
cnt dd 0
ArcOn dd 0
NoFix dd 0
cpy dd 0
Row dd 0
Col dd 0
Pos dd 0
DecPos dd 0
DP dd 0
FPLZ dd 0
PassDec dd 0
I dd 0
N dd 0
T dd 1
W dd 0
Base dd 10
HBase dd 0
PrevBase dd 0
IDI_ICON1 EQU 101
IDR_MENU1 EQU 102
IDB_BUT07 EQU 207
IDB_BUT08 EQU 208
IDB_BUT09 EQU 209
IDB_BUTADD EQU 218
IDB_BUTSQ EQU 223
IDB_BUT04 EQU 204
IDB_BUT05 EQU 205
IDB_BUT06 EQU 206
IDB_BUTSUB EQU 219
IDB_BUTPCT EQU 224
IDB_BUT01 EQU 201
IDB_BUT02 EQU 202
IDB_BUT03 EQU 203
IDB_BUTMUL EQU 220
IDB_BUTPOW EQU 225
IDB_BUT00 EQU 200
IDB_BUTPER EQU 216
IDB_BUTEQ EQU 222
IDB_BUTDIV EQU 221
IDB_BUTPM EQU 217
IDB_BUTA EQU 210
IDB_BUTB EQU 211
IDB_BUTC EQU 212
IDB_BUTD EQU 213
IDB_BUTE EQU 214
IDB_BUTF EQU 215
IDB_BUTMC EQU 226
IDB_BUTMR EQU 227
IDB_BUTMS EQU 228
IDB_BUTMP EQU 229
IDB_BUTMM EQU 230
IDB_BUTHYP EQU 231
IDB_BUTREC EQU 232
IDB_BUTXN EQU 233
IDB_BUTPI EQU 234
IDB_BUTSIN EQU 235
IDB_BUTCOS EQU 236
IDB_BUTTAN EQU 237
IDB_BUTCSC EQU 238
IDB_BUTSEC EQU 239
IDB_BUTCOT EQU 240
IDB_BUTLOG EQU 241
IDB_BUT2X EQU 242
IDB_BUT10X EQU 243
IDB_BUTEX EQU 244
B1 EQU 500
IDD_INFO EQU 1999
IDD_ABOUT EQU 2000
IDD_CALC EQU 2102
IDM_CLOSE EQU 6003
IDM_CUT EQU 6004
IDM_COPY EQU 6005
IDM_PASTE EQU 6006
IDM_INFO EQU 6026
IDM_ABOUT EQU 6027
IDT_TOOLBAR1 EQU 301
IDT_TOOLBAR2 EQU 302
IDT_TOOLBAR3 EQU 303
IDT_TOOLBAR4 EQU 304
IDT_TOOLBAR5 EQU 305
IDT dd IDT_TOOLBAR1,IDT_TOOLBAR2,IDT_TOOLBAR3,IDT_TOOLBAR4,IDT_TOOLBAR5
wsprintfA PROTO C :DWORD,:VARARG
wsprintf equ <wsprintfA>
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
WinProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
EditProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
ToolbarProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
CLRMW PROTO :DWORD, :DWORD
CopyMW PROTO :DWORD, :DWORD, :DWORD
CompMW PROTO :DWORD, :DWORD, :DWORD
MOVem PROTO :DWORD, :DWORD
wc WNDCLASS <?>
msg MSG <?>
lf LOGFONT <?>
include Edit1.asm
.code
start:
call InitCommonControls ;Initialize the common ctrl lib
INVOKE GetModuleHandle, 0
mov hInst,eax ;hInstance is same as HMODULE
INVOKE GetCommandLine
mov CommandLine, eax
INVOKE WinMain, hInst, NULL, CommandLine, SW_SHOWDEFAULT
INVOKE ExitProcess, msg.wParam
;=========================================================================|
; WinMain Procedure |
;=========================================================================|
WinMain PROC hinst:DWORD, hPrevInst:DWORD, CmdLine:DWORD, CmdShow:DWORD
;**********************
;* Initialize the WndClass structure and register the class name
;**********************
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_GLOBALCLASS
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
mov eax,hInst
mov wc.hInstance,eax
INVOKE LoadIcon, eax, IDI_ICON1
mov wc.hIcon,eax
INVOKE LoadCursor, 0, IDC_ARROW
mov wc.hCursor,eax
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName, 0
mov wc.lpszClassName, offset class
INVOKE RegisterClass, offset wc
INVOKE LoadMenu, hInst, IDR_MENU1
mov hMenu, eax
INVOKE CreateWindowEx,0,ADDR class,ADDR TB,
WS_OVERLAPPED or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX,
200,68,460,262,NULL,hMenu,hinst,NULL ;450
mov hWnd,eax
INVOKE ShowWindow, hWnd,SW_SHOWNORMAL
INVOKE UpdateWindow, hWnd
INVOKE SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_SHOWWINDOW
INVOKE LoadAccelerators, hInst, 2007
mov hAccel, eax
BeginLoop:
INVOKE GetMessage, offset msg, 0, 0, 0
cmp eax,0
je EndLoop
INVOKE TranslateAccelerator, hWnd, hAccel, offset msg
cmp eax, 0
jne BeginLoop
INVOKE TranslateMessage, offset msg
INVOKE DispatchMessage, offset msg
jmp BeginLoop
EndLoop:
RET
WinMain ENDP
;=========================================================================|
; WinProc Procedure |
;=========================================================================|
WndProc PROC uses ebx edi esi, hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
mov eax,wmsg
cmp eax,WM_CREATE
je wmcreate
cmp eax,WM_COMMAND
je wmcommand
cmp eax,WM_CLOSE
je wmdestroy
cmp eax,WM_NOTIFY
je wmnotify
.if wmsg == WM_KEYDOWN
INVOKE SetFocus, hEdit
.endif
jmp defwndproc
wmcommand:
mov eax,wparam
cwde ; Only low word contains command
cmp eax,IDM_CLOSE
je wmdestroy
cmp eax,IDM_CUT
je idmcut
cmp eax,IDM_COPY
je idmcopy
cmp eax,IDM_PASTE
je idmpaste
cmp eax,IDM_INFO
je idminfo
cmp eax,IDM_ABOUT
je idmabout
cmp eax, 1
je wmbs
cmp eax, 2
je wmce
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -