Author Topic: Resource compiler for console applications  (Read 17713 times)

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #15 on: October 25, 2012, 12:08:30 AM »
By the way, I liked your discussion of the expansion problem, and would support the warning option, especially since the workaround is very straightforward:
Quote
The main argument is this: Masm’s behaviour is wrong.
Not a nice thing to bring into this snakepit of MASM fanatics jj :biggrin:

The problem in my view is all the exceptions made there, and if you continue along that path you will end up with more problems later. There is also a hidden opportunity in there, but it is complicated: I better stick to the basic ;)

I tried to follow the download link, but the page seems to be missing or blocked.

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Resource compiler for console applications
« Reply #16 on: October 25, 2012, 12:21:22 AM »
You are right that Masm's behaviour is "wrong", but where to draw the line? JWasm's strong points are full Masm32 compatibility plus more speed and macros for Win64. Adding features is risky with regard to the userbase.

OTOH, checking if a multiline macro is called after an .elseif seems not too difficult. A warning would really be helpful. Who needs it can use -WX aka "Treat all warnings as errors" ;-)

> I tried to follow the download link, but the page seems to be missing or blocked.
Not blocked for me, I just clicked the link in your message.

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #17 on: October 25, 2012, 01:43:32 AM »
You have to do it without breaking this compatibility: labelling it as a bug. But then, it is a part of the MASM design, so there.

> I tried to follow the download link, but the page seems to be missing or blocked.
include \masm32\MasmBasic\MasmBasic.inc   ; download

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Resource compiler for console applications
« Reply #18 on: October 25, 2012, 02:15:05 AM »
> You have to do it without breaking this compatibility: labelling it as a bug
You know that some software depends on bugs functioning properly  :icon_mrgreen:

I thought you meant the SourceFourge link...

MB is online at http://masm32.com/board/index.php?topic=94.0 and active: MasmBasic014Oct12.zip (362.15 kB - downloaded 23 times.)

So who could block a Masm page? AV? Provider? But then, you obviously can post here. I hope the crappy AV brigade has not blocked MasmBasic specifically... :(

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #19 on: October 25, 2012, 03:13:09 AM »
seems to work now, so now it’s installed.

> You know that some software depends on bugs functioning properly
hence the problem, so the warning message must come first

I compiled the sample, it produced a 3 447 641 byte .lst file, so there is definitely something under the hood :lol:

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Resource compiler for console applications
« Reply #20 on: October 25, 2012, 03:31:41 AM »
I compiled the sample, it produced a 3 447 641 byte .lst file

Which sample?

I just noticed that the "Simple window" template produces 380k of listing when putting .listall under the include line; however, when assembly option /Fl is specified, it jumps indeed to over 3MB. My testbed arrives at over 10MB of listing with /Fl set. Not exactly MasmBasic's fault, however: A simple MsgBox with masm32rt.inc only also produces 8MB with .listall before the include line...

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #21 on: October 25, 2012, 04:20:39 AM »
include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  Let esi="This is a stupid test"
  .if Instr_(esi, "stuupid")
     PrintLine "stuupid found"
  .elseif Instr_(esi, "test")
     PrintLine "test found"
  .endif
  Inkey "Found something??", CrLf$
  .if Instr_(esi, "stuupid")
     PrintLine "stuupid found"
  .else
     .if Instr_(esi, "test")
          PrintLine "test found"
     .endif
  .endif
  Inkey "better??"
  Exit
end start

dedndave

  • Member
  • *****
  • Posts: 8734
  • Still using Abacus 2.0
    • DednDave
Re: Resource compiler for console applications
« Reply #22 on: October 25, 2012, 06:16:55 AM »
if you use /Fl, you may also want to use .XCREF in the source - it makes a big difference   :biggrin:
of course, it also helps to use .NOLIST and .LIST around the includes

japheth

  • Guest
Re: Resource compiler for console applications
« Reply #23 on: October 25, 2012, 07:56:06 PM »
OTOH, checking if a multiline macro is called after an .elseif seems not too difficult.

That's indeed very good news! Since it is obviously a child's play, could you please tell me how to do it? With detailed source code, if you don't mind!

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Resource compiler for console applications
« Reply #24 on: October 25, 2012, 09:22:20 PM »
OTOH, checking if a multiline macro is called after an .elseif seems not too difficult.

That's indeed very good news! Since it is obviously a child's play, could you please tell me how to do it? With detailed source code, if you don't mind!

It's not child's play, of course, but IMHO a pretty basic exercise (sorry, can't help you with C code....):

include \masm32\MasmBasic\MasmBasic.inc   ; download
.data
MacTable   dd m1, m2, 0   ; see CreateMacTable
m1   dd 100   ; line count of macro
   db "Instr_", 0
m2   dd 1
   db "Instr1", 0

   SetGlobals posL, mac$
   Init
   SetGlobals
   Recall "TestElseIfDummyCode.asm", L$()
   ; call CreateMacTable      ; JWasm certainly has something like this, right?
   For_ ct=0 To eax-1
      mov edi, L$(ct)
      .if Instr_(edi, ".elseif", 1)
         add edx, 7
         mov posL, edx
         .if Instr_(edx, edi, "(")
            sub edx, posL
            Let mac$=Trim$(Mid$(edi, posL, edx))
            mov esi, offset MacTable
            .While 1
               lodsd
               .Break .if !eax
               mov ecx, [eax]
               add eax, DWORD
               .if !StringsDiffer(eax, mac$)
                  .if ecx>1
                     PrintLine "WARNING: ", mac$, " should not be used after .elseif!!"
                  .else
                     PrintLine "Congrats, using ", mac$, " is OK"
                  .endif
               .endif
            .Endw
         .endif
      .endif
   Next

   Inkey "ok"
   Exit
end start

TestElseIf.asm:

include \masm32\MasmBasic\MasmBasic.inc   ; download

Instr1 MACRO spos, src, match   ; a one-liner
  EXITM <ecx==12345678h>
ENDM
  Init
  mov ecx, 12345678h
  Let esi="This is a stupid test"
  .if Instr_(esi, "stuupid")
   PrintLine "stuupid found"
  .elseif Instr_(esi, "test")   ; useless, will expand before the jump label
   PrintLine "test found"
  .elseif Instr1(esi, "test")   ; will expand at the jump label
   PrintLine "Instr1 found it: ", Hex$(ecx)
  .endif
  Inkey CrLf$, "Found something??", CrLf$
  Exit
end start
« Last Edit: October 25, 2012, 10:56:18 PM by jj2007 »

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #25 on: October 26, 2012, 04:53:09 AM »
The resource editor now works, but the old version seems to be the better choice. The compiler will convert the files to OMF 32-bit format, so this will do for now.

I made an experimental IDE version for compiling the .asm, but this is 16-bit stuff. The library included is OMF (coff libs are to big). This means you need wmake, wlink and jwasm to build them.

I dump the files in the masm32 directory and tried to compile some of the samples there. Seems to work, but currently unstable stuff!

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #26 on: October 26, 2012, 04:55:32 AM »
The setup for tools is Alt-F1:
Quote
[ShiftF1]
asm=err jwasm -I%doszip%\include -Fl -Sg -Zd
[ShiftF2]
asm=err jwasm -I%doszip%\include -Fl -Sg -Zd -D__l__
[ShiftF3]
asm=err ml -c -I%doszip%\include -Zi
[ShiftF4]
asm=makeit.bat
[ShiftF5]
asm=rcedit


nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #27 on: October 26, 2012, 04:56:42 AM »
Using Shift-F1 to compile:

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Resource compiler for console applications
« Reply #28 on: October 26, 2012, 05:01:48 AM »
NULL is defined in windows.inc.
Well Microsoft, here’s another nice mess you’ve gotten us into.

nidud

  • Member
  • *****
  • Posts: 1371
    • https://github.com/nidud/asmc
Re: Resource compiler for console applications
« Reply #29 on: October 26, 2012, 07:32:58 AM »
NULL is defined in windows.inc.
Yes, so it works  :biggrin: