The MASM Forum Archive 2004 to 2012

Specialised Projects => Assembler/Compiler Technology => Topic started by: japheth on August 26, 2009, 04:46:35 PM

Title: JWasm version v2.0 now really beta
Post by: japheth on August 26, 2009, 04:46:35 PM

Hello,

JWasm v2 beta was announced 14 days ago, but in the meantime another feature has been implemented: symbolic debugging info is now created, that is, cmdline options -Zd and -Zi are supported.

So JWasm now is - really - beta and the new features are:

-  64bit support for COFF and ELF ( -win64 and -elf64 )
-  Win64 SEH support
-  .SAFESEH supported for Win32
-  symbolic debugging info for OMF and COFF

Title: Re: JWasm version v2.0 now really beta
Post by: Jimg on August 27, 2009, 01:26:36 PM
I've been waiting impatiently for better debug support, thank you.

Unfortunately, I'm getting the following problem when I link-

F:\masm32\BIN\ML /c /coff /Cp /Zi /Zd /I"F:\masm32\INCLUDE" "F:\JWasm\urltest\UrlTest.asm"

JWasm v2.00pre, Aug 24 2009, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

F:\JWasm\urltest\UrlTest.asm: 38 lines, 3 passes, 141 ms, 0 warnings, 0 errors

F:\masm32\BIN\Link @"F:\JWasm\urltest\link.war"

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /INCREMENTAL:NO "/LIBPATH:F:\masm32\LIB" "F:\JWasm\urltest\UrlTest.obj" "/OUT:F:\JWasm\urltest\UrlTest.exe"
UrlTest.obj : warning LNK4200: corrupt line number information in object file; ignored


It's only a warning, but it keep the program from running automatically.

Again, unfortunately, it includes my ugly printx macro, and I can't seem to pin down the problem.

The stripped down main code looks like-
include Printx.inc
.list
Program:
    invoke ExitProcess,0
    ret
   
WndProc Proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
    .if uMsg==WM_COMMAND
        .if wParam==2010
        .endif
    .elseif uMsg==WM_CREATE
        printx addr xbuff, /,"lParam (return value)=",dd lParam," ",hx lParam,/,"wParam (flag)=",dd wParam
        msgx
    .endif
    ret
WndProc EndP

End Program

if I comment out the .if wParam==2010/.endif, it works, so I think it's something internally getting confused due the messy macro.

No problem if in regular mode, only in debug.




Title: Re: JWasm version v2.0 now really beta
Post by: japheth on August 28, 2009, 06:19:40 AM

JWasm wrote line number debug info for lines inside macros. This confused the linker a lot.

Now macro lines are filtered and it works better, but I'll have to find out how to write a line number debug info for the macro invokation itself.
Title: Re: JWasm version v2.0 now really beta
Post by: dedndave on August 28, 2009, 10:25:31 AM
i was just playing with that in MASM
the @Line directive (equate to be more correct) gives the line the macro is called from, no matter where it appears in the macro
as it turns out, that was what i really wanted
if you want to know where to go in the source file - you want it to point to the line where the macro was called
Title: Re: JWasm version v2.0 now really beta
Post by: drizz on August 29, 2009, 05:24:04 PM
first of all thank you for all the work you have done making jwasm a TOP ASSEMBLER!

one thing about x64 code...
you use "and rsp,-16" in your samples, and correct me if im wrong, but if the proc uses "uses reg1 reg2" wouldn't this make the order of registers that are popped in epilogue wrong (assuming rsp was not aligned after prologue) ?
Shouldn't the stack be aligned automatically by including extra  with add rsp,-8 if neccessary ?

Title: Re: JWasm version v2.0 now really beta
Post by: japheth on August 30, 2009, 05:19:03 PM

Hello,

a new version was uploaded. It should fix the printx problem.

There was also indeed a problem with the @Line symbol, which returned the macro line no inside macros.

Quote
you use "and rsp,-16" in your samples, and correct me if im wrong, but if the proc uses "uses reg1 reg2" wouldn't this make the order of registers that are popped in epilogue wrong (assuming rsp was not aligned after prologue) ?

True. However, I used this "and rsp,-16" in 1 sample only, and in this sample "uses ..." isn't used.

Quote
Shouldn't the stack be aligned automatically by including extra  with add rsp,-8 if neccessary ?

It should, but ML64.EXE doesn't, so I think JWasm shouldn't also. Automatic Stack alignment is implemented for frame procs if the OPTION FRAME directive is set.


Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 04, 2009, 06:22:38 PM
This works in ml v9.0 but fails in 2.0:

; JWasm: Error! E071: Operand is expected;  Erase(2)[Tmp_File.asm]: Macro called from Tmp_File.asm(720)
Erase MyA$()


The brackets in opattr seem to be a problem for JWasm:

Erase MACRO arrId
LOCAL oa, is, tmp$
oa = (opattr(arrId)) AND 127
  if oa eq 36
push arrId
  else
  is INSTR <arrId>, <(>
@CatStr(<Dim >, @SubStr(<arrId>, 1, is), <-123>, @SubStr(<arrId>, is+1))
@CatStr(<push >, @SubStr(<arrId>, 1, is), <id>, @SubStr(<arrId>, is+1))
  endif
  call MbArrayErase
ENDM

Title: Re: JWasm version v2.0 now really beta
Post by: BlackVortex on September 05, 2009, 05:06:30 AM
What in the ...

You and your weirdo macros    :cheekygreen:
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on September 05, 2009, 11:37:09 AM
Hi JJ,

Quote from: jj2007 on September 04, 2009, 06:22:38 PM
This works in ml v9.0 but fails in 2.0:

Erase MACRO arrId
LOCAL oa, is, tmp$
oa = (opattr(arrId)) AND 127
  if oa eq 36
push arrId
  else
  is INSTR <arrId>, <(>
@CatStr(<Dim >, @SubStr(<arrId>, 1, is), <-123>, @SubStr(<arrId>, is+1))
@CatStr(<push >, @SubStr(<arrId>, 1, is), <id>, @SubStr(<arrId>, is+1))
  endif
  call MbArrayErase
ENDM



Please tell how this macro is supposed to be invoked! Or even better, supply a valid test case!
Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 05, 2009, 01:27:25 PM
Quote from: japheth on September 05, 2009, 11:37:09 AM
Or even better, supply a valid test case!

I'll do my best :bg
Output in MASM:
String 2: The second string
Erasing My$()
Erase error: NoSuch$() has never been defined
String 2: My$() array erased, sorry


; CONSOLE Assembly
include \masm32\include\masm32rt.inc

Erase MACRO arrId
LOCAL oa, is, tmp$

tmp$ CATSTR <Trying to erase >, <arrId>
% echo tmp$

oa = (opattr(arrId)) AND 127

  if oa eq 38 ;; an offset
  print "Erasing "
print arrId, 13, 10
  else
print "Erase error: "
print chr$("&arrId&"), " has never been defined", 13, 10
  endif
ENDM

My$ MACRO arg
  ifb <arg>
mov Strings, 0
EXITM <offset MyName>
  else
  .if Strings
mov eax, [Strings+4*arg+4]
.else
mov eax, offset Erased
.endif
EXITM <eax>
  endif
ENDM

.data
Strings dd 4, S0, S1, S2, S3
S0 db "Element zero", 0
S1 db "The first string", 0
S2 db "The second string", 0
S3 db "The third string", 0
Erased db "My$() array erased, sorry", 0
MyName db "My$()", 0

.code
start:
print "String 2: "
print My$(2), 13, 10
Erase My$()
Erase NoSuch$()
print "String 2: "
print My$(2), 13, 10
invoke ExitProcess, 0

end start
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on September 07, 2009, 01:28:36 PM

Ok,

OPATTR(NoSuch$())

is accepted now.
Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 07, 2009, 09:22:30 PM
Quote from: japheth on September 07, 2009, 01:28:36 PM

OPATTR(NoSuch$())

is accepted now.


Works like a charm, thanks a lot. It assembles also about 40% faster than Masm - compliments!

One minor difference:
JWASM
Address               Hex dump                       Command
0040287D              .0F86 7F000000                jbe 00402902
...
00402902

MASM
Address               Hex dump                       Command
0040287D              .76 7F                        jbe short 004028FE
...
004028FE


Is it possible that the decision to use a long jmp does not take account that the short jmp is 4 bytes shorter...?

In any case: Kudos for your fantastic work :U
Title: Re: JWasm version v2.0 now really beta
Post by: Jimg on September 08, 2009, 01:42:05 PM
Thank you Japeth.  I no longer have to go back to masm for a debug session.  Much appreciated.  All the problems I have found except one have been fixed.
Now the only time I need to use masm is to get a listing, but I can understand why listing control would be low in your priorities.
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on September 08, 2009, 06:28:07 PM

Good!

There's now also a jwasm.rules included which is meant for MS VS EE integration. I stole this idea from the Yasm project. And even better, I created a Multimedia Show :eek at http://www.japheth.de/JWasm/JWasmVS.html to show how this file is supposed to be used.
Title: Re: JWasm version v2.0 now really beta
Post by: Ficko on September 08, 2009, 08:59:32 PM
Quote from: japheth on September 08, 2009, 06:28:07 PM

Good!

There's now also a jwasm.rules included which is meant for MS VS EE integration. I stole this idea from the Yasm project. And even better, I created a Multimedia Show :eek at http://www.japheth.de/JWasm/JWasmVS.html to show how this file is supposed to be used.

Thanks that's cool! :U

And how can you make some syntax highlighting in VS ?? ::) :bg
Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 15, 2009, 09:01:44 PM
Minor problem: Sometimes an empty echo repeats the previous text:

Quoteecho This line should appear only once
echo

Output:
QuoteThis line should appear only once
This line should appear only once

Even a blank after the empty echo solves this "microbug".
Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 15, 2009, 09:49:00 PM
Here is a slightlly bigger problem (assembles fine under ml).
Quote
include \masm32\include\masm32rt.inc

Dim MACRO NewMac:REQ   ;; with ideas from Greg Falen (http://www.masm32.com/board/index.php?topic=9787.0)
LOCAL isL, isR, MacName$
  isL INSTR <NewMac>, <(>
  isR INSTR <NewMac>, <)>
  if isL
   MacName$ SUBSTR <NewMac>, 1, isL-1
   MacName$ macro arrayElement
      invoke MessageBox, 0, str$(arrayElement), chr$("You asked for element:"), MB_YESNO
      EXITM <eax>
   endm
  endif
ENDM

Problem MACRO arg
LOCAL tmp$, oa, is
  is INSTR <arg>, <=>
  dest SUBSTR <arg>, 1, is-1
  src SUBSTR <arg>, is+1
  oa = opattr(dest)   AND 127
  tmp$ CATSTR <Dest=>, dest, <, source=>, src, <, opat=>, %oa
  % echo tmp$
  ifdifi dest, <eax>
     tmp$ CATSTR <chr$(">, dest, <")>
   invoke MessageBox, 0, tmp$, chr$("Undefined array:"), MB_YESNO
   tmp$ CATSTR <Dim >, dest
   % echo tmp$
   tmp$
  endif
ENDM

.code
start:
   Problem Arr1$(44)="aaa"
   Dim Arr1$(100)
   Dim Arr2$(100)
   Problem Arr2$(55)="bbb"
   invoke ExitProcess, 0

end start

Output:
Tmp_File.asm(40) : Error A2072: Constant operand is expected
Problem(5)[Tmp_File.asm]: Macro called from
  Tmp_File.asm(1852140901): Main line code
Title: Re: JWasm version v2.0 now really beta
Post by: GregL on September 16, 2009, 01:47:01 AM
QuoteAnd how can you make some syntax highlighting in VS ?? Roll Eyes BigGrin

There is always the usertype.dat file.  MASM Syntax Highlighting (http://kipirvine.com/asm/gettingStarted/index.htm#syntax) (Kip Irvine).



japheth,

The symbolic debugging info is a nice improvement and so is the 64-bit support. :thumbu

Title: Re: JWasm version v2.0 now really beta
Post by: japheth on September 17, 2009, 12:59:22 PM
Hi,

> echo This line should appear only once
> echo

fixed.

> Problem Arr1$(44)="aaa"
> Dim Arr1$(100)

The line which causes the problems is your beloved OPATTR:

>  oa = opattr(dest)   AND 127

One issue is that JWasm deliberately behaves slightly differently because it's rather easy to write wrong code with OPATTR - Masm almost never complains. You probably did want to write:

>  oa = (opattr(dest))  AND 127

This code is ok. However, there was another issue - OPATTR combined with the '(' operator - which had to be fixed before JWasm accepted your precious macros.

> The symbolic debugging info is a nice improvement and so is the 64-bit support. ThumbsUp

Thanks! Usable Win64 include files in Masm syntax are still missing, however. I adjusted Win32Inc to work with 64-bit, but since I don't own a 64-bit Windows. it will have to be tested by someone else.

http://www.japheth.de/Win32Inc/Download/Win32Inc200.zip


Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on September 17, 2009, 04:14:03 PM
Quote from: japheth on September 17, 2009, 12:59:22 PM
The line which causes the problems is your beloved OPATTR:

>  oa = opattr(dest)   AND 127

One issue is that JWasm deliberately behaves slightly differently because it's rather easy to write wrong code with OPATTR - Masm almost never complains. You probably did want to write:

>  oa = (opattr(dest))  AND 127

This code is ok. However, there was another issue - OPATTR combined with the '(' operator - which had to be fixed before JWasm accepted your precious macros.


Thanks a lot, Japheth - it works like a charm now.
I had tried double brackets, too. The double brackets issue is counter-intuitive - imho it might be worth a more explicit error message à la "Error XX: You probably meant (opattr(dest))  AND 127
Title: Re: JWasm version v2.0 now really beta
Post by: Jimg on October 10, 2009, 06:15:17 PM
There's a new version out today (10/10/09).  Fixed several things.

In my torture test, I found it fails with this code-

.586
.model flat, stdcall
option casemap:none ; case sensitive

include 1394bus.inc
includelib 1394bus.lib

.code
Program:
ret
End Program

with this error:

Tests.Asm(6) : Error A2193: General Failure


Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 11, 2009, 04:39:47 AM

> Tests.Asm(6) : Error A2193: General Failure

Nice find!

fixed.


Title: JWasm version v2.0 now final
Post by: japheth on October 12, 2009, 03:29:18 PM

v2.0 is final.
Title: Re: JWasm version v2.0 now really beta
Post by: Jimg on October 12, 2009, 04:01:21 PM
The following works in masm but not in jwasm-
.686
.model Flat, Stdcall
option Casemap :None
.code
tst22 proc
ret
tst22 endp
program:
    baseroutine = tst22
    invoke tst22        ; this works
    invoke baseroutine  ; gives Error! E232: INVOKE requires prototype for procedure
    ret
end program


Is this on the to do list for the next version, or do you consider this a bug in masm that shouldn't work and won't be changed?
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 12, 2009, 04:37:59 PM
Quote from: Jimg on October 12, 2009, 04:01:21 PM
The following works in masm but not in jwasm-

...


Is this on the to do list for the next version, or do you consider this a bug in masm that shouldn't work and won't be changed?

Yes  :toothy

Seriously, it's on the todo list ( requires a change of the SYM_PROC handling, see 1. in Doc/fixes.txt ).

However, I'll take a break from JWasm development now.

Title: Re: JWasm version v2.0 now really beta
Post by: Alloy on October 20, 2009, 03:32:31 AM
Thanks japheth for bringing us a free assembler that can emit source level codeview debug info.
Title: Re: JWasm version v2.0 now really beta
Post by: @lx on October 29, 2009, 08:58:29 PM
Hi japeth,
i have a strange bug when running jwasm with the jwasm.rules under VisualStudio 2008. When there are compiler errors, the output is not redirected to the stdout but to a file.err, and VS doesn't know that jwasm failed. Is there someone else having the same problem? I wish i could fully switch to jwasm!

[Edit]who, i just saw that you are taking a break from JWasm, ok, no problem, this is not urgent. With the source, i guess i'm able to patch jwasm!  :wink[/Edit]


Quote from: Ficko on September 08, 2009, 08:59:32 PM
And how can you make some syntax highlighting in VS ?? ::) :bg

hi Ficko, i have developed a x86 ASM syntax highlighter plugin called AsmHighlighter (http://asmhighlighter.codeplex.com) for VS 2008 that may help you (plugins are unfortunately not working for express version).



Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on October 29, 2009, 10:12:51 PM
Quote from: @lx on October 29, 2009, 08:58:29 PM
When there are compiler errors,

... and it seems not to return the error code that a DOS batch file expects. Not a big problem, though.
Title: Re: JWasm version v2.0 now really beta
Post by: Kyle on October 29, 2009, 10:32:45 PM
Quote from: @lx on October 29, 2009, 08:58:29 PM
Hi japeth,
i have a strange bug when running jwasm with the jwasm.rules under VisualStudio 2008. When there are compiler errors, the output is not redirected to the stdout but to a file.err, and VS doesn't know that jwasm failed. Is there someone else having the same problem? I wish i could fully switch to jwasm!

[Edit]who, i just saw that you are taking a break from JWasm, ok, no problem, this is not urgent. With the source, i guess i'm able to patch jwasm!  :wink[/Edit]


Quote from: Ficko on September 08, 2009, 08:59:32 PM
And how can you make some syntax highlighting in VS ?? ::) :bg

hi Ficko, i have developed a x86 ASM syntax highlighter plugin called AsmHighlighter (http://asmhighlighter.codeplex.com) for VS 2008 that may help you (plugins are unfortunately not working for express version).





Wow this is an awesome tool. Props for making it! I've already installed it and I'm passing the link around to friends. You have an awesome project and I hope you get quite a bit of traffic on your site for it.
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 30, 2009, 07:54:10 AM
Quote from: @lx on October 29, 2009, 08:58:29 PM
i have a strange bug when running jwasm with the jwasm.rules under VisualStudio 2008. When there are compiler errors, the output is not redirected to the stdout but to a file.err, and VS doesn't know that jwasm failed. Is there someone else having the same problem? I wish i could fully switch to jwasm!

jwasm writes errors to <file>.ERR, but it additionally writes the errors to stdout. So I don't think this is the problem. You'll have to supply a test case, but please test first that it works with Masm and fails with JWasm!

Quote
You have an awesome project and I hope you get quite a bit of traffic on your site for it.

Thanks! However, JWasm was written mainly for myself and the - few - people who love assembly in Masm-syntax. JWasm isn't sold, and there are no ads on my site, so increasing JWasm-related traffic is not a goal. Also, please don't advertise JWasm to assembly noobies. The last thing I want to do is answering dump noobish questions like "How do I install JWasm? There's no setup.exe!" on SourceForge.


japheth
Title: Re: JWasm version v2.0 now really beta
Post by: @lx on October 30, 2009, 08:57:03 AM
Quote from: japheth on October 30, 2009, 07:54:10 AM
jwasm writes errors to <file>.ERR, but it additionally writes the errors to stdout. So I don't think this is the problem. You'll have to supply a test case, but please test first that it works with Masm and fails with JWasm!
Actually, i'm using masm but whenever i try to switch to jwasm and i have a simple error in the asm file, the errors never go to the stdout, moreover as jj2007 mentioned, the error code is not set so VS doesn't complain on compilation but only when linking (because the obj file is missing)...
Running a dos command prompt, i get the errors to the stdout...
Under VS, i have debug and modified jwasm and i'm getting the errors if i set errout to stderr in errmsg.h (like unix). Although the return errorcode is still not set.
Also, i had to change quite a few things in jwasm to make it working in VC++ 2008... (some local variable are not initialized, the lineis() function has a bug when the length of substr > the length of string). I'll try to give you a recap.
Title: Re: JWasm version v2.0 now really beta
Post by: jj2007 on October 30, 2009, 09:01:02 AM
Quote from: japheth on October 30, 2009, 07:54:10 AM
Thanks! However, JWasm was written mainly for myself and the - few - people who love assembly in Masm-syntax.

It's not only a syntax issue. Only Masm and JWasm have powerful macro facilities. For people who want to code close to the machine but without the clumsiness of coding print "Hello World" in "pure" assembler, JWasm is a precious gift.

Just out of curiosity: Apparently ml64 does no longer support macros; does 64-bit JWasm provide the full macro capability?
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 30, 2009, 09:38:10 AM
Quote from: @lx on October 30, 2009, 08:57:03 AM
Actually, i'm using masm but whenever i try to switch to jwasm and i have a simple error in the asm file, the errors never go to the stdout, moreover as jj2007 mentioned, the error code is not set so VS doesn't complain on compilation but only when linking (because the obj file is missing)...

The error code is set if the number of errors is > 0. If this wouldn't work, then not just VS had problems, but also all [N]MAKE utilities.

Quote
Running a dos command prompt, i get the errors to the stdout...
Under VS, i have debug and modified jwasm and i'm getting the errors if i set errout to stderr in errmsg.h (like unix). Although the return errorcode is still not set.
If you changed the jwasm source privately, then please don't report errors which occur in that version, even if you think that the errors have nothing to do with your changes!
Btw, it's important that the jwasm Win32 version writes errors to stdout, not stderr. That's how Masm does it.

Quote
Also, i had to change quite a few things in jwasm to make it working in VC++ 2008... (some local variable are not initialized, the lineis() function has a bug when the length of substr > the length of string). I'll try to give you a recap.

Ok! Bug reports must be detailed, best is to supply a description with a - small - test case.
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 30, 2009, 12:40:22 PM
Quote from: japheth on October 30, 2009, 09:38:10 AM
Quote from: @lx on October 30, 2009, 08:57:03 AM
Actually, i'm using masm but whenever i try to switch to jwasm and i have a simple error in the asm file, the errors never go to the stdout, moreover as jj2007 mentioned, the error code is not set so VS doesn't complain on compilation but only when linking (because the obj file is missing)...

The error code is set if the number of errors is > 0. If this wouldn't work, then not just VS had problems, but also all [N]MAKE utilities.


JJ made me aware that I'm probably a bit tooooo optimistic concerning the "error code" issue. So I made a test and have to confirm that you're right, there is - or better: was - a bug. It has been fixed in v2.01.

Sorry for rejecting an absolutely valid bug report!

Title: Re: JWasm version v2.0 now really beta
Post by: @lx on October 30, 2009, 02:49:07 PM
Quote from: japheth on October 30, 2009, 12:40:22 PM
JJ made me aware that I'm probably a bit tooooo optimistic concerning the "error code" issue. So I made a test and have to confirm that you're right, there is - or better: was - a bug. It has been fixed in v2.01.
Sorry for rejecting an absolutely valid bug report!
Hi japheth, cool that you can confirm this bug... i have cheched it also, and the parse_cmdline in the main loop was clearing the ModuleInfo.error_count for the previously parsed file...

For the other errors, here is the sample file :


.686P
.XMM
.model flat

TestDeclareMacro macro funcName:req, procParam
CURRENT_FUNCTION textequ <&funcName>
CURRENT_LABEL_START textequ <&funcName&_Start_>
CURRENT_SECTION textequ <_&funcName&_>
CURRENT_SECTION segment byte public 'CODE'
ifb     <procParam>
CURRENT_FUNCTION proc
else
CURRENT_FUNCTION proc procParam
endif
CURRENT_LABEL_START:
endm

TestEndDeclareMacro macro
CURRENT_FUNCTION endp
CURRENT_SECTION ends
endm           

TestDeclareMacro TestAsmFunction, c public
mov eax, 2
blabla
ret
TestEndDeclareMacro
     
end


I'm getting some runtime error (i'm running VC++ 2008 in debug mode, so it's checking buffer overflow and so on, stuff that you won't see in a release mode or sometimes with other compilers...)

The file  macro.c, line 182 : if (qlevel == brlevel) : qlevel used but not initialized. I have modified line 149 to have a correct init : int qlevel = 0;
The file macro.c, line 208 : if( string[len] != '\0' && !isspace( string[len] ) ) {. The parameters are string = "endp", substr = "macro", len = 5. This line is not working and is reading from an unitialized memory : string[len] is undefined  if strlen(substr) > strlen(string).

Cosmetic things : The exe was not working on VC++ 2008 getting a runtime error on :  symbols.c : line 520   strftime( szDate, 9, "%D", now ); line    526   strftime( szTime, 9, "%T", now );
I suspect strftime microsoft to be not compliant. Because D and T are not recognized, i had to add something like :

#ifdef _MSC_VER >= 1300
    strftime( szDate, 9, "%x", now );
#else
    strftime( szDate, 9, "%D", now );
#endif
...
#ifdef _MSC_VER >= 1300
    strftime( szTime, 9, "%X", now );
#else
    strftime( szTime, 9, "%T", now );
#endif


After checking more about the stdout error, in fact errors are effectively going to stdout (Output Windows) but not in the "Error List" window of VC++. ([Edit]MASM doesn't have the problem[/Edit]).  but if you change this two lines in msgdef.h (line 15-21)
: instead of "Warning" use "warning", instead of "Error" use "error", the errors will show up in the "Error List" windows of VC++.

With this simple fix, i'm able to ger errors in the Error List (in the screenshot, with MASM and modified version of Jwasm 2.0) :

(http://img248.imageshack.us/img248/8622/errorlist.png)

Hope that you will be able to integrate this in JWasm 2.01!  :wink






Title: Re: JWasm version v2.0 now really beta
Post by: japheth on October 31, 2009, 04:22:52 AM
Quote from: @lx on October 30, 2009, 02:49:07 PM
The file  macro.c, line 182 : if (qlevel == brlevel) : qlevel used but not initialized. I have modified line 149 to have a correct init : int qlevel = 0;
True but irrelevant IMO, because if qlevel is uninitialized then the value of quote is NULLC; In other words, the worst thing what may happen is that a value is written to a variable which has that value already.

Quote
The file macro.c, line 208 : if( string[len] != '\0' && !isspace( string[len] ) ) {. The parameters are string = "endp", substr = "macro", len = 5. This line is not working and is reading from an unitialized memory : string[len] is undefined  if strlen(substr) > strlen(string).
This is also a somewhat mechanistic analysis. The code works. Agreed, memory might be read from uninitialized locations, but it's ensured that value of len will be small enough to not cause an exception.

Quote
Cosmetic things : The exe was not working on VC++ 2008 getting a runtime error on :  symbols.c : line 520   strftime( szDate, 9, "%D", now ); line    526   strftime( szTime, 9, "%T", now );
I suspect strftime microsoft to be not compliant. Because D and T are not recognized, i had to add something like :

#ifdef _MSC_VER >= 1300
    strftime( szDate, 9, "%x", now );
#else
    strftime( szDate, 9, "%D", now );
#endif
...
#ifdef _MSC_VER >= 1300
    strftime( szTime, 9, "%X", now );
#else
    strftime( szTime, 9, "%T", now );
#endif

Yes, this should be changed. However, %X and %x are flagged as "locale dependent",  so it may be a  better idea to use %d, %m, %H, ... instead.

Quote
After checking more about the stdout error, in fact errors are effectively going to stdout (Output Windows) but not in the "Error List" window of VC++. ([Edit]MASM doesn't have the problem[/Edit]).  but if you change this two lines in msgdef.h (line 15-21)
: instead of "Warning" use "warning", instead of "Error" use "error", the errors will show up in the "Error List" windows of VC++.

With this simple fix, i'm able to ger errors in the Error List (in the screenshot, with MASM and modified version of Jwasm 2.0) :
Ok.
Title: Re: JWasm version v2.0 now really beta
Post by: jcfuller on October 31, 2009, 10:15:31 AM
Are there (or would someone show) examples of dynamic loading and calling of shared libraries (dll,so) with JWASM at run time?
The reason is to offer both console and gui in one program on linux. First check for gtk needed shared libraries and if not available
provided a text only interface
James

Title: Re: JWasm version v2.0 now really beta
Post by: @lx on November 02, 2009, 12:04:09 AM
Hi japeth,
It seems that I have an unexpected result with JWasm here. If you try to reference the field of a nested structure inside another structure you'll get a zero offset.


NestedStruct struct
level db ?
NestedStruct ends

TopStruct struct
member1 NestedStruct <>
member2 NestedStruct <>
member3 NestedStruct <>
TopStruct ends

.code
    mov eax, [esi + TopStruct.member1.level]            ; Generated assembler is : mov eax, [esi]


Can you confirm?

Also, seems that the debug obj file is not working with VS 2008... I'm unable to step in the code generated with jwasm... but I need to investigate a bit more...
Title: Re: JWasm version v2.0 now really beta
Post by: japheth on November 20, 2009, 06:29:56 PM
Quote from: Jimg on October 12, 2009, 04:01:21 PM
The following works in masm but not in jwasm-
.686
.model Flat, Stdcall
option Casemap :None
.code
tst22 proc
ret
tst22 endp
program:
    baseroutine = tst22
    invoke tst22        ; this works
    invoke baseroutine  ; gives Error! E232: INVOKE requires prototype for procedure
    ret
end program


Is this on the to do list for the next version, or do you consider this a bug in masm that shouldn't work and won't be changed?

@Jimg: this has been fixed for v2.01. Please test!