News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

easy for experts...

Started by xandaz, December 03, 2020, 03:21:55 AM

Previous topic - Next topic

xandaz

    I'm used to convert both memory reigsters to hex and binary but when it comes to decimal things become a little more dificult. Can someone land a hand? Thanks

jj2007


xandaz

   sorry for this but i'm not used to use macros that much. would it be something like this?
invoke SetWindowText,hStatic,WM_SETTEXT,0, str$(eax)

   is this the way you do it? Thanks

xandaz

   it gives error can't find  crt__itow. what the hell i'm i doing wrong?

jj2007

Instead of numerous include statements, use only one:

include \masm32\include\masm32rt.inc

.data
HelloW$ db "Hello World", 0

.code
start:
  print str$(eax), " is the current value of eax"
  exit

end start


Have a look at masm32rt.inc, it's a very interesting file.

TimoVJL

Check SetDlgItemInt() function.
BOOL WINAPI SetDlgItemInt(
  _In_  HWND hDlg,
  _In_  int nIDDlgItem,
  _In_  UINT uValue,
  _In_  BOOL bSigned
);

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemint
May the source be with you

Vortex

wsprintf example :

.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\masm32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\masm32.lib

.data

format1     db '%u',0

.data?

buffer      db 32 dup(?)

.code

start:

    mov     eax,1234

    invoke  wsprintf,ADDR buffer,ADDR format1,eax
    invoke  StdOut,ADDR buffer

    invoke  ExitProcess,0

END start

avcaballero

Two examples I made long ago. The first one is quite simple and write down a unsigned word number, from 65535 to 1, the second one writes signed numbers from -65535 to 65534, a bit more elaborated but easy too. First one with fasm sintax, the second with nasm. Both in DOS format.

hutch--

xandaz,

Include the following line AFTER all of the include files and get the functionality of all of the macros.

      include \masm32\macros\macros.asm         ; masm32 macro file


jj2007

Quote from: jj2007 on December 03, 2020, 05:03:27 AM
Instead of numerous include statements, use only one:

include \masm32\include\masm32rt.in

That includes even macros.asm :cool:

(it slows down assembly to have so many includes included; on my Core i5 by about 0.05 seconds)

xandaz

   Thanks very much guys. You've been exceedingly helpful. I'll bare that in my heart.  :thumbsup:

Vortex

dwtoa from masm32.lib :


Quotedwtoa proc public uses esi edi dwValue:DWORD, lpBuffer:DWORD

Description

dwtoa convert a DWORD value to an ascii string.

Parameters

1. dwValue The DWORD value to convert.
2. lpBuffer The address of the buffer to put the converted DWORD into.

Return Value

There is no return value.

Comments

The buffer for the converted value should be large enough to hold the string including the terminating zero.

jj2007

Quote from: Vortex on December 03, 2020, 07:10:41 PM
dwtoa from masm32.lib :

\masm32\macros\macros.asm (included with masm32rt.inc):

    str$ MACRO DDvalue
      LOCAL rvstring
      .data
        rvstring db 20 dup (0)
        align 4
      .code
      invoke dwtoa,DDvalue,ADDR rvstring
      EXITM <ADDR rvstring>
    ENDM

xandaz


xandaz

   Hi there. I was wondering what macro should i use with str$() to add the word line in the precedence of of the line number. thanks in advance  :thumbsup: