News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help me Plz new to asm

Started by kyo, June 13, 2006, 08:33:18 PM

Previous topic - Next topic

kyo

Hello all i am new to asm i am trying to make a calculator in masm32 using rad id  i failed to perform +-*/ operation and unable to handle datas(variables) please complete following code

here if eax==1014 ;/ btnpressed 1014 to 17 needs code in order to work further i have tried several times to complete it but i failed to make complete working program full rad source code is attached with msg .


.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

include ProjectCal.inc
include macros.asm

.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax

    invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL

invoke ExitProcess,0

;########################################################################

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
invoke SendMessage,hWin,WM_SETTEXT,0,SADD("Assembly Language Calculator.")
invoke SetWindowLong,FUNC(GetDlgItem,hWin,1001),GWL_WNDPROC,addr EditWndProc
        mov OldWndProc,eax
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
and eax,0FFFFh
.if edx==BN_CLICKED
.if eax==1002 ;1clocked
;invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("1"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1003 ;2clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("2"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1004 ;3clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("3"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1005 ;4clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("4"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1006 ;5clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("5"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1007 ;6clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("6"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1008 ;7clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("7"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1009 ;8clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("8"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1010 ;9clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("9"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1011 ;10clocked
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke StrCatBuff, addr Text_Buff,SADD("0"),256
invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff
.endif
.if eax==1014 ;/ btnpressed
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
;mov eax,Text_Buff
;mov Text_Buff2,eax
;invoke StrToInt,addr Text_Buff2
;invoke SetWindowText,FUNC(GetDlgItem,hWin,1001), addr Text_Buff2
invoke
.endif
.if eax==1015 ;* btnpressed
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke
.endif
.if eax==1016 ;+ btnpressed
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke
.endif
.if eax==1017 ;- btnpressed
invoke GetWindowText ,FUNC(GetDlgItem,hWin,1001),addr Text_Buff,255
invoke
.endif

.endif

.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp
EditWndProc PROC hEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
    .if uMsg==WM_CHAR
        mov eax,wParam
        .if (al>="0" && al<="9") 
            invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam
            ret
        .endif
    .elseif uMsg==WM_KEYUP
        mov eax,wParam
        .if ah==VK_A
        .else
            invoke CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
            ret
        .endif
    .else
        invoke CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
        ret
    .endif
    xor eax,eax
    ret
EditWndProc endp
end start


I just added the code tags so that your code was easier to read.



[attachment deleted by admin]

no-one

I think you should add a button for the number 7.  Do you dislike 7?

Paul

kyo

Quote from: no-one on June 14, 2006, 12:09:52 PM
I think you should add a button for the number 7.  Do you dislike 7?

Paul

sorry i just added i forgot that one but i have described some other problem.

Ossa

Hi there,

try using the GetDlgItemInt function to get the value from the textbox as a number and then do operations on it. You will need to store the previous result and the previous operation and then do operations on them when a new operator is used. I also didn't notice an "equals" button - it will be needed to see the final result.

Ossa
Website (very old): ossa.the-wot.co.uk

ToutEnMasm

Hello,
have a look on the site of ewayne.
http://asmedit.massmind.org/files/EWCalc.zip
                           ToutEnMasm

Casper

Casper says...

This is the only Calculator that I use.  He did a better job with the layout than Ewayne did.  It may me more complicated than your needs as it is scientific but it will give you some ideas.

[attachment deleted by admin]

kyo

Thanks guys for such a good help.Now i am  learning from both of these application. :U