I am trying to convert the text output tutorial but I am having trouble. I believe it has something to do with the macro that is used in the source. I am not to familiar with HLA macros.

 

program Textdemo;

#include ("..\include\win.inc")
#include ("..\include\kernel32.hhf")
#include ("..\include\user32.hhf")
#include ("..\include\gdi32.hhf")

#asm

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

#endasm

readonly

ClassName : string := "SimpleWinClass";
AppName : string := "Our First Window";
TestString : string := "Win32 assembly is great and easy!";
FontName : string := "script";

static

hInstance : dword := 0;
CommandLine : string;



macro RGB( red, green, blue );

xor( eax, eax );
mov( blue, ah );
shl( 8, eax );
mov( green, ah );
mov( red, al );

endmacro;

procedure WinMain ( hInst : dword; hPrevInst : dword; CmdLine : dword; CmdShow : dword ); @forward;
procedure WndProc ( lParam:dword; wParam:dword; uMsg:dword; hwnd:dword );@forward;

procedure WinMain ( hInst : dword; hPrevInst : dword; CmdLine : dword; CmdShow : dword );

var

wc : WNDCLASSEX;
msg : MSG;
hwnd : dword;

begin WinMain;

pushad();
mov ( @size( WNDCLASSEX ), wc.cbSize );
mov ( CS_HREDRAW | CS_VREDRAW , wc.style );
mov ( &WndProc, wc.lpfnWndProc );
mov ( 0, wc.cbClsExtra );
mov ( 0, wc.cbWndExtra );
mov ( hInstance, wc.hInstance );
LoadIcon ( 0, IDI_APPLICATION );
mov ( eax, wc.hIconSm );
mov ( eax, wc.hIcon );
LoadCursor ( 0, IDC_ARROW );
mov ( eax, wc.hCursor );
mov ( COLOR_WINDOW + 1 , wc.hbrBackground );
mov ( ClassName, wc.lpszClassName );
mov ( 0, wc.lpszMenuName );

RegisterClassEx ( lea ( wc, eax ));

CreateWindowEx
(
0,
ClassName,
AppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,
0,
hInstance,
0
);

mov ( eax, hwnd );

ShowWindow ( hwnd, SW_SHOWNORMAL );
UpdateWindow ( hwnd );

lea ( msg, edi );

while ( GetMessage ( edi , 0, 0, 0 ) <> 0 ) do

TranslateMessage ( edi ) ;
DispatchMessage ( edi );

endwhile;

mov ( msg.wParam, eax );
popad();

end WinMain;

procedure WndProc ( lParam:dword; wParam:dword; uMsg:dword; hwnd:dword );
@nodisplay;
var
hdc : dword;
ps : PAINTSTRUCT;
hfont : dword;

begin WndProc;

if ( uMsg = WM_DESTROY ) then

PostQuitMessage ( NULL );

elseif ( uMsg = WM_PAINT ) then

pushad();

lea ( rect, edi );
lea ( ps, esi );

BeginPaint( hwnd, esi );
mov ( eax, hdc );

CreateFont ( 24,16,0,0,400,0,0,0,OEM_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,DEFAULT_PITCH | FF_SCRIPT,
FontName );

SelectObject ( hdc, eax );

mov ( eax, hfont );

RGB ( 200,200,50 );

SetTextColor ( hdc ,eax );

RGB ( 0,0,255 );

SetBkColor ( hdc,eax );
TextOut ( hdc,0,0,TestString,@size(TestString));
SelectObject( hdc, hfont );
EndPaint ( hWnd, esi );

popad();

else

DefWindowProc ( hwnd, uMsg, wParam, lParam );
exit WndProc ;

endif;

xor ( eax, eax );

end WndProc;

begin Textdemo;

GetModuleHandle ( 0 );
mov ( eax, hInstance );
GetCommandLine();
mov ( eax, CommandLine );
WinMain ( hInstance, 0, CommandLine, SW_SHOWNORMAL );
ExitProcess ( NULL );

end Textdemo;



When I compile these are the errors I get

Error in file "text.hla" at line 29 :
Expected ':', encountered 'RGB'
(Possible undefined ID).
Near: << RGB >>

Error in file "text.hla" at line 29 :
Undefined symbol.
Near: << RGB >>

Error in file "text.hla" at line 39 :
Expected ';', encountered ')'.
Near: << ) >>

Error in file "text.hla" at line 137 :
Expected ':', encountered '('
(Possible undefined ID 'RGB').
Near: << ( >>
Posted on 2003-04-16 07:21:14 by Odyssey
Hi Odyssey,

just try this macro with "#" signs:


#macro RGB( red, green, blue );

xor( eax, eax );
mov( blue, ah );
shl( 8, eax );
mov( green, ah );
mov( red, al );

#endmacro;
Posted on 2003-04-16 16:05:33 by Green Joe
Hi Odyssey,

There were several minor errors in your translation of Itz tutorial that prevent it compile successfully.
I did some small revisions and now it's OK.
Posted on 2003-04-16 20:22:44 by Green Joe
Thanks Green Joe. i appreciate the help. Only problem is I don't get to terminate the other bugs myself.
Posted on 2003-04-16 23:02:26 by Odyssey