### Author Topic: .FOR built in JWasm  (Read 57624 times)

#### habran

• Member
• Posts: 1226
##### .FOR built in JWasm
« on: July 03, 2012, 11:38:29 PM »
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:
Code: [Select]
` .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)
« Last Edit: April 21, 2013, 06:10:38 AM by habran »
Cod-Father

#### Vortex

• Member
• Posts: 2582
##### Re: .FOR build in JWasm
« Reply #1 on: July 04, 2012, 03:37:19 AM »
Hi habran,

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

#### habran

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #2 on: July 04, 2012, 05:53:40 AM »
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 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

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #3 on: July 04, 2012, 10:34:08 PM »
I new it Vortex, no chance at all
Cod-Father

#### qWord

• Member
• Posts: 1476
• The base type of a type is the type itself
##### Re: .FOR build in JWasm
« Reply #4 on: July 04, 2012, 10:48:33 PM »
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

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #5 on: July 04, 2012, 11:31:22 PM »
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

• Member
• Posts: 1476
• The base type of a type is the type itself
##### Re: .FOR build in JWasm
« Reply #6 on: July 05, 2012, 12:16:39 AM »
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:
Code: [Select]
` "block lable" macro block {begin/branch/end} {"block lable"} {options} {arguments} LOCALSYM {block-local symbols} LOCAL {macro locals} {...} EXITM {<>} endm`examples:

Code: [Select]
` ".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

• Member
• Posts: 2582
##### Re: .FOR build in JWasm
« Reply #7 on: July 05, 2012, 05:10:12 AM »
The plug-in system is another nice idea. If I am not wrong, Hutch proposed the plug-in feature too.

#### habran

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #8 on: July 05, 2012, 05:52:00 AM »
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

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #9 on: July 05, 2012, 05:58:38 AM »
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

• Member
• Posts: 2582
##### Re: .FOR build in JWasm
« Reply #10 on: July 05, 2012, 06:08:12 AM »
Hi habran,

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

#### qWord

• Member
• Posts: 1476
• The base type of a type is the type itself
##### Re: .FOR build in JWasm
« Reply #11 on: July 05, 2012, 06:27:02 AM »
you 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

• Member
• Posts: 1226
##### Re: .FOR build in JWasm
« Reply #12 on: July 05, 2012, 06:36:55 AM »
qWord:
Quote
For-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

• Member
• Posts: 11546
• Assembler is fun ;-)
##### Re: .FOR build in JWasm
« Reply #13 on: July 05, 2012, 05:25:48 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

Code: [Select]
`include \masm32\include\masm32rt.incversion = 0 ; both 0 and 1 produce the same errorchr\$ MACRO TheArgs:VARARGLOCAL 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>ENDMright MACRO EXITM <wrong()>ENDM.codestart: inkey chr\$("right()")  ; ML output: right(), Jwasm output: wrong() exitend start`

#### johnsa

• Member
• Posts: 844
##### Re: .FOR build in JWasm
« Reply #14 on: July 05, 2012, 05:52:39 PM »
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.