News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

.FOR built in JWasm

Started by habran, July 03, 2012, 11:38:29 PM

Previous topic - Next topic

habran

here is a C source code and binaries of JWasm v2.08a with build in .for and .endfor C-like hll
the only difference is ';' is replaced with '¦' which is character 0A6h or 166
to type it hold ALT down and type 221 and than release ALT
initializers and counters:
=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
condition opperators:
==,!=,> ,< ,>=,<=,&&,||,& ,!,ZERO?,CARRY?,SIGN?,PARITY?,OVERFLOW?

E.G.  eax+=10   ebx <<= 16 (shl) ecx >>= 8 (shr)
here is how it can be used:

.for ( hWnd=lParam,edx=88,ecx=4¦eax != 24 && hWnd > lParam || ebx <= 20 || ebx >= 3¦eax=23,edx=24,ebx++)
  nop
.endfor
;forever loop
.for (¦¦)
.break .if eax
.endfor

I have fixed some more bugs I found

I have changed it to JWasm 2.10
The folder contains JWasm32 and JWasm64 and changed and improved sources
binaries need at least Windows version 6
(Japheth)
Cod-Father

Vortex

Hi habran,

Did you discuss this feature with Japheth? Maybe, he could add it to the next release of Jwasm.

habran

Vortex, I don't believe that japhet will do that because he did not say nothing about other improvements I did before
However, I will send him this now
I am very grateful to japheth for making such a good assembler and I understand that he has his own plans and ideas about his work
I am not concerned about this because if he doesn't do that I will
I am not using the new v2.07 because it is missing features I put in, because I program x64
to me my version v2.06e works fine
let see what will he say
Cod-Father

habran

I new it Vortex, no chance at all
Cod-Father

qWord

It is more realistic to start a discussion about extending the macro system, thus it is possible to implement such HLL features as macros. Even this is not simply, because the extension should be as universally as possible.
Another option would some kind of plug-in system.
MREAL macros - when you need floating point arithmetic while assembling!

habran

Hi qWord

I tried but it is useless to try to persuade Japhet to change his mind

I will still work to improve this source code and even if none wants to  use it I will

I find it useful to have such hll features in assembly programming because they are more readable and efficient

best regards
Cod-Father

qWord

habran,

your approach is simply to specific - you cannot expect that he adds this, especially because it's syntax breaks with the existing one.

I also thought about an extension of the MACRO-Directive, which would cover your .for-loop:
"block lable" macro block {begin/branch/end} {"block lable"} {options} {arguments}
LOCALSYM {block-local symbols}
LOCAL {macro locals}
{...}
EXITM {<>}
endm

examples:

".for" macro block begin args:LINE
LOCALSYM lbl_being,lbl_end,line
line TEXTEQU <args>
jmp BLOCKLBL end
lbl_begin:
endm

".break" macro block branch ".for"
jmp lbl_end
endm

".endf" macro block end ".for"
{...}
jxx lbl_begin
lbl_end:
endm

".switch" macro block begin val:req
LOCALSYM value
value TEXTEQU val
endm

".case" macro block branch ".switch" num:req
cmp value,num
jne BLOCKLBL next
{...}
jmp BLOCKLBL end
endm

".endsw" macro block end ".switch"
{...}
endm


qWord
MREAL macros - when you need floating point arithmetic while assembling!

Vortex

The plug-in system is another nice idea. If I am not wrong, Hutch proposed the plug-in feature too.

habran

qWord, I already wrote macros which work fine but I can not use "<,!,>,/,&" operators
you suggested me to build it in JWasm and I did it

Vortex, is it possible to ad plug-in to JWasm?
Cod-Father

habran

I think I will stick with this version
for me it works fine and I think that it is totally legal to change source as long as I publish my changes
if anybody is interested to use it welcome, if not, it is OK with me

thanks guys
Cod-Father

Vortex

Hi habran,

To say the truth, I don't know if it's possible.  I liked the idea.

qWord

Quote from: habran on July 05, 2012, 05:52:00 AMyou suggested me to build it in JWasm and I did it
No, it didn't suggest it.
MREAL macros - when you need floating point arithmetic while assembling!

habran

qWord:
QuoteFor-loops are fine and I've also had the idea to create such a macro, but finial I end up that the resulting syntax doesn't look as nice as in C. Currently I can only see a change if it is directly implemented in the assembler:  jWasm.
For your macros, I see the problem of the used none-ASCII-characters (<<,>>), which are only visible, if the editor use the correct code page.
Cod-Father

jj2007

Quote from: qWord on July 04, 2012, 10:48:33 PM
Another option would some kind of plug-in system.

Or a preprocessor. Anyway, I am ambiguous about such improvements. JWasm is a success because it is a) compatible with Masm, b) a bit faster and c) promises to be the only 64-bit assembler that has a Masm-compatible macro engine. By adding new features, one moves away from a huge code and user base. For example, I use JWasm by default, and it has happened to me that I introduced "bugs" that worked fine in JWasm but not in Masm.

There are also still a number of unresolved issues, such as this nice one :biggrin:

include \masm32\include\masm32rt.inc

version = 0 ; both 0 and 1 produce the same error

chr$ MACRO TheArgs:VARARG
LOCAL NewString, arg, TheString
if version
% TheString CATSTR <TheArgs> ; works fine without % but sometimes you need it...
else
arg equ <TheArgs>
TheString CATSTR arg
endif
  .DATA
NewString db TheString, 0
  .CODE
EXITM <OFFSET NewString>
ENDM

right MACRO
EXITM <wrong()>
ENDM

.code
start:
inkey chr$("right()")  ; ML output: right(), Jwasm output: wrong()
exit

end start

johnsa

I still hold that the only 2 key things missing from jwasm is the invoke stack fix that habran made and CodeView8 symbolic debug info.
If I can't debug my code.. there's no point...

More than that I would say adding enum and an option to align a struct allocation on stack would be nice to haves, but i can live without it.

I've been slowed down on my assembler at the moment, and i was kind of hoping jwasm 2.07 would give me a reason not to continue for now.. but alas still no CV8 and no correct stack usage.. who knows HOW long this could take to have implemented in jwasm...

The only other alternative would be a pre-processor module in jwasm to export a "dumbed" down .ASM file that can be assembled by ML64 post processing of HLL/INVOKE etc... to get the CV8 back.