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
str$()?
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
it gives error can't find crt__itow. what the hell i'm i doing wrong?
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.
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
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
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.
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
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)
Thanks very much guys. You've been exceedingly helpful. I'll bare that in my heart. :thumbsup:
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.
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
Thanks y'all. :thumbsup:
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:
Which "word line"? Post an example.
It goes like this:
.if uMsg==WM_CHAR || uMsg==WM_MOUSEMOVE
invoke SendMessage,hWnd,EM_LINEINDEX,-1,0
invoke SendMessage,hWnd,EM_LINEFROMCHAR,eax,0
inc eax
push eax
invoke SendMessage,hMdi,WM_MDIGETACTIVE,0,0
invoke GetWindowLong,eax,GWL_USERDATA
mov edi,eax
invoke SendMessage,[edi.MdiStruct.hStatic],WM_SETTEXT,0,addr szEmptyString
pop eax
invoke SendMessage,[edi.MdiStruct.hStatic],WM_SETTEXT,0,ustr$(eax)
Just wanted to add the word 'line' to the line number as in WM_SETTEXT,0,ustr$(eax)
Allocate a buffer that is large enough to hold all of the string data you have in mind then use either "cat$()" or the macro "strcat" to join the strings. You will find this data in the help file on the menu "High Level Macro Help". There is a ton of stuff there that you will find really useful.
yeah Hutch...thanks for the help i've been trying WM_SETTEXT,0,cat$(offsset szLine,ustr$(eax)) but it crashes.
Try constructing the string separately then show it in a MessageBox().
ok...i'll try that.
The macro works fine. the problem is that i'm using cat$(offset Buffer,"ln ",ustr$(eax)) and although i've attentiveally set the first character of Buffer to 0 it keeps adding to the string.
working perfectlly. Thanks a lot
Quote from: xandaz on December 04, 2020, 03:12:01 AM
yeah Hutch...thanks for the help i've been trying WM_SETTEXT,0,cat$(offsset szLine,ustr$(eax)) but it crashes.
First arg is the destination buffer, x$ in this example:
Local x$[100]:BYTE
mov ecx, 123
print cat$(addr x$, "Line ", str$(ecx))
In MasmBasic you could use invoke SendMessage,[edi.MdiStruct.hStatic],WM_SETTEXT,0,
Str$("Line %i", eax)
yeah thanks JJ. î got it working thanks to you guys but i have to confess it's kinda slow.