The MASM Forum

General => The Campus => Topic started by: kesmezar on March 05, 2020, 10:23:58 PM

Title: Adding, subtracting Hex values
Post by: kesmezar on March 05, 2020, 10:23:58 PM
Hello,
I am using RadAsm. How to add two hex values ​​entered in text boxes?
Thank you.

(invoke GetDlgitemText or GetDlgitemInt Or GetDlgitem) Which of these should I use?
and values dd or byte ?

sample; edit1: 11F794B7  edit2: 11F794B7

invoke GetDlgItemText,hWin,hexvaluetext1,offset value1   error?
Title: Re: Adding, subtracting Hex values
Post by: jj2007 on March 06, 2020, 01:40:12 AM
With GetDlgItemText (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdlgitemtexta), you only get a text representation of the number. You will have to convert it, either with your own algo, or with a predefined macro or C runtime routine etc. There are many ways to do that (example (http://masm32.com/board/index.php?topic=6483.msg91837#msg91837)) - search the forum for convert number string
Title: Re: Adding, subtracting Hex values
Post by: Vortex on March 07, 2020, 04:39:49 AM
Quote from: kesmezar on March 05, 2020, 10:23:58 PM
How to add two hex values ​​entered in text boxes?

Hello,

Reading \masm32\help\masmlib.chm :

Quotehtodw

htodw proc uses ebx ecx edi edx esi String:DWORD

Description

htodw receives as its parameter, the address of a zero terminated string containing hex characters and returns the value as a DWORD in eax.

Parameter

1. String The address of the zero terminated string to be converted.

Return Value

The DWORD value is returned in eax.

Comments

It is the users responsibility to ensure that there are no non-hexadecimal characters in the string of numbers.