Jump to content
Tuts 4 You

write program in assembly


Rever7eR

Recommended Posts

Hello there !
how to write a program add two numbers and print the result in text box
in order to print the result we can use SetDlgItemText Funtion , the problem is i don't know how to add two numbers ..
what functions we need ?
am using MASM32 , and RadASM IDE
Regards,

Link to comment

suppose we have to add 20 and 15, you must move the numbers into register, call addition and push it

MOV EAX, 20
MOV EBX, 15
ADD EAX,EBX
PUSH EAX

The result is in EAX

bye

Predator

  • Confused 1
Link to comment

here's a good example..

Program to sum two numbers

it kind of depends on what numbers you want to add, base 16(hex) , base 10(normal)...

if it is base 10 you need to convert to hex first add then convert result back to base 10..

 

Edited by Nemo
Link to comment

i want to add two numbers , base 10
can you give me an example of coverting base 10 to hex !
what functions we need to do that ?

Link to comment
2 hours ago, Predator said:

suppose we have to add 20 and 15, you must move the numbers into register, call addition and push it

MOV EAX, 20
MOV EBX, 15
ADD EAX,EBX
PUSH EAX 

The result is in EAX

bye

Predator

my man ! am not working with console applications !
this is simple , 20 + 15 , i want the user to choose those two numbers if you know what i mean
 

Link to comment

invoke GetDlgItemInt,Hwnd,IDC_Edit1,0,FALSE

push eax

invoke GetDlgItemInt,Hwnd,IDC_Edit2,0,FALSE

pop ebx

add ebx,eax

 

result is in EBX just format it and print it out

 

edit:

Remarks

The GetDlgItemInt function retrieves the text of the specified control by sending the control a WM_GETTEXT message. The function translates the retrieved text by stripping any extra spaces at the beginning of the text and then converting the decimal digits. The function stops translating when it reaches the end of the text or encounters a nonnumeric character.

The GetDlgItemInt function returns zero if the translated value is greater than INT_MAX (for signed numbers) or UINT_MAX (for unsigned numbers).

 

 

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdlgitemint

 

Edited by sama
info about GetDlgItemInt
  • Like 1
Link to comment
3 hours ago, sama said:

invoke GetDlgItemInt,Hwnd,IDC_Edit1,0,FALSE

push eax

invoke GetDlgItemInt,Hwnd,IDC_Edit2,0,FALSE

pop ebx

add ebx,eax

 

result is in EBX just format it and print it out

 

edit:

Remarks

The GetDlgItemInt function retrieves the text of the specified control by sending the control a WM_GETTEXT message. The function translates the retrieved text by stripping any extra spaces at the beginning of the text and then converting the decimal digits. The function stops translating when it reaches the end of the text or encounters a nonnumeric character.

The GetDlgItemInt function returns zero if the translated value is greater than INT_MAX (for signed numbers) or UINT_MAX (for unsigned numbers).

 

 


https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdlgitemint

 

thank you so much ! this is helpful

Link to comment

 

On 7/17/2018 at 2:07 PM, abdelhamid said:

my man ! am not working with console applications !
this is simple , 20 + 15 , i want the user to choose those two numbers if you know what i mean
 

Sorry bro, you are right.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...