News:

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

Converting MASM String functions

Started by FlySky, October 23, 2010, 09:47:56 AM

Previous topic - Next topic

FlySky

Hey guys,

Syntax of GoASM is slightly different than the syntax from MASM and I am converting some of the string converting functions from MASM to GoASM.

Now I came across something interesting which I don't see any converting functions for?:

Let's say I am having a Editbox, in this box I type the value 123456 or 1A3456 what I playing with is the conversion of this string which I am reading using
GetDlgItemTextA and saved to a buffer to convert that in a DWORD value just like the string is being shown.
So 123456 I want to convert to a DWORD value in eax which holds 123456. Did I miss any of the functions? Using atodw it converts 123456 to it's hexadecimal presentation and threats the string
as a decimal value.

rags

From atodw.asm:

  ; ----------------------------------------
  ; Convert decimal string into dword value
  ; return value in eax
  ; ----------------------------------------

Quote
Using atodw it converts 123456 to it's hexadecimal presentation and threats the string
as a decimal value.
I am not sure of what you mean by converting to its hex presentation,
but it DOES convert the string into a dword value.
God made Man, but the monkey applied the glue -DEVO

FlySky

Hey rags,

Yes it converts but it converts to 1E240 hex (DWORD value in EAX). I need the string to stay 123456 as being a DWORD 00123456. I am probably missing something here  :red

jj2007

atodw expects decimal input. MasmBasic's mov eax, Val("123456h") does the job, and there are certainly some CRT functions, too, but don't forget to append the h before using the function.

MsgBox 0, Cat$("The value: "+Hex$(Val(Win$(hEdit)))+"h"), "Ascii to hex conversion:", MB_OK

Output if editbox contains the string 12345678h:
The value: 12345678h

FlySky

I am not sure if I understand you jj2007.

But it looks like you are using the macro's from MASM32 ? the Masm32/m32lib directory is not having any functions to convert it?

ramguru


FlySky

Ramguru that is doing the trick thanks.

I translated htodw to support GoASM. Will wrap up a file with all translations I made so far if anyone is interested.

jj2007

Quote from: FlySky on October 23, 2010, 01:48:19 PM
I am not sure if I understand you jj2007.

But it looks like you are using the macro's from MASM32 ? the Masm32/m32lib directory is not having any functions to convert it?

I am a lazy guy and therefore use mov eax, Val(string) - an allround converter. But ramguru is perfectly right, htodw is part of Masm32 and perfectly suited to perform the conversion.

jcfuller

I thought the masm32 license forbade you from using any part (including macros) with another assembler??

James

jj2007

Quote from: jcfuller on October 23, 2010, 05:15:41 PM
I thought the masm32 license forbade you from using any part (including macros) with another assembler??

James


James,

Not sure what you mean here. MasmBasic is simply a library, and perfectly compatible with the whole Masm32 package, i.e. you can use e.g. htodw and Val() side by side. And it assembles with ML.exe, version 6.15 or higher, and Jwasm. The way you put it, it would seem that the license forbids to use the Masm32 library with another assembler, e.g. JWasm - but even that interpretation looks odd, as many here peacefully (and apparently with Hutch's consensus) use JWasm for assembling Masm32 code.

jcfuller

I was talking about Assemblers not your MasmBasic.
I may be wrong in my interpretation but I don't think so.
The Masm32 package is for use with Microsoft compilers only.

James

dedndave

nahhhhh
Hutch doesn't care which assembler you use   :bg
just don't kipe his code and call it your own - lol

jj2007

Quote from: jcfuller on October 23, 2010, 08:59:43 PM
The Masm32 package is for use with Microsoft compilers only.

AFAIK Hutch got a license to redistribute ml.exe version 6.14 with the Masm32 package. That doesn't affect how you use the other parts of Masm32, i.e. the libraries.

jcfuller

My old brain scrambling things again. It was #4 that I was banging up against:

4. You cannot use the MASM32 Project to write software for Non-Microsoft Operating Systems.

James


dedndave

that restriction primarily applies to the microsoft assembler
much of the code would not work under other operating systems
as long as you don't break the rules for the assembler, you are probably ok
Hutch's main rule is - don't steal his code and put your name on it   :bg