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)
Hi habran,
Did you discuss this feature with Japheth? Maybe, he could add it to the next release of Jwasm.
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
I new it Vortex, no chance at all
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.
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
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
The plug-in system is another nice idea. If I am not wrong, Hutch proposed the plug-in feature too.
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?
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
Hi habran,
To say the truth, I don't know if it's possible. I liked the idea.
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.
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.
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
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.
Extending the macro system or adding some kind of plug-in system does not mean to break with existing code.
A plug-in interface would be the most powerful feature, but it would also require fixing some of jwasm's internal structures. Probably this would make the future development harder.
IMO exiting the macro system is more practical (e.g. advanced sting- and operator evaluation function).
changed to JWasm 2.07
changed to JWasm 2.08
I have updated the attachment at the top and added some more features
If anyone find some errors please let me know
Cat got your tongue? :biggrin:
Hello habran,
Quote from: habran on November 02, 2012, 06:37:30 AM
If anyone find some errors please let me know
I'm running WinXP SP3, and trying to start jwasm.exe from your package opens a message box: JWasm.exe is not a valid Win32 application.
Additionally, the binary references MSVCR110.dll, a dll which I don't have installed.
sorry, it was working fine on my machine
I have attached VS8 build at the top, try that one
please let me know if not OK
however, you have the source code available
thank you for telling me that
habran,
you must link to msvcrt statically.
Project properties -> C++ -> Code generation -> Runtime library
Set it to /MTd for Debug Configuration and /MT for Release.
Greenhorn
here is it
Is nested loop supported?
>Is nested loop supported?
Yes, according to japheth it is unlimited
>you must link to msvcrt statically.
thankyou Greenhorn, I was not aware of that
I have uploaded the new version on the top
It takes more memory
hope now works for everyone
I tried this:
.486
option casemap:none
include \masm32\include\masm32rt.inc
includelib \masm32\lib\masm32.lib
.code
start:
.for (ebx=3¦ebx>=1¦ebx--)
.for(ecx=1¦ecx<=ebx¦ecx++)
print str$(ecx)," "
.endfor
print " ",13,10,0
.endfor
exit
end start
My expected output is:
Quote
1 2 3
1 2
1
But the actual output is:
Quote
1
1
1
Am I doing something wrong here?
Yes, you are calling 'print str$(ecx)," "' which uses ecx register which is volatile register
and it gets trashed
you can use nonvolatile registers or PUSH and POP eg:
.for (ebx=3¦ebx>=1¦ebx--)
.for(ecx=1¦ecx<=ebx¦ecx++)
push ecx
print str$(ecx)," "
pop ecx
.endfor
print " ",13,10,0
.endfor
When you write print str$(ecx)," "
you use these two macros:
print MACRO arg1:REQ,varname:VARARG ;; display zero terminated string
invoke StdOut,reparg(arg1)
IFNB <varname>
invoke StdOut,chr$(varname)
ENDIF
ENDM
; ----------------------------------------------------------
; function position macros that takes a DWORD parameter and
; returns the address of the buffer that holds the result.
; The return format is for use within the INVOKE syntax.
; ----------------------------------------------------------
str$ MACRO DDvalue
LOCAL rvstring
.data
rvstring db 20 dup (0)
align 4
.code
invoke dwtoa,DDvalue,ADDR rvstring
EXITM <ADDR rvstring>
ENDM
as you can see they both call functions that do not preserve volatile registers
Ah thanks. I forget about it once again :redface:
They are already listed in jj's page, anyway:
http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm
no worries mate :biggrin:
ones I'v spent days to find the bug in my source
and all I needed is to finish the function with RET :icon_mrgreen:
now when I start some function first thing I write is RET :lol:
we usually see everything except most obvious things
for example: if your wife is cheating on you, you will be the last one to know it
your neighbors well know that long time before you
best regards
Quote from: anta40 on November 06, 2012, 12:16:35 PM
Am I doing something wrong here?
As Habran already wrote, ecx is the culprit. No problem with MB, but print (lowercase p) and str$ are Masm32 macros. Same if you use Windows or CRT functions like printf etc.
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
For_ ebx=0 To 3
For_ ecx=1 To 4-ebx
Print Str$(ecx), " " ; MasmBasic preserves ecx
Next
Print
Next
Inkey
Exit
end start
thank you jj2007
QuotePrint Str$(ecx), " " ; MasmBasic preserves ecx
does it mean it does this?:
push ecx
print str$(ecx)," "
pop ecx
Quote from: habran on November 06, 2012, 06:41:24 PM
does it mean it does this?:
push ecx
print str$(ecx)," "
pop ecx
Print/Inkey and Str$() are more complex than their Masm32 counterparts. Inter alia, you can Print several Str$() in the same line (more (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1167)):
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
fn SetCurrentDirectory, "\Masm32\include\"
Inkey Str$("Size of Windows.inc=\t%i bytes", Lof("Windows.inc")), Str$("\nSize of WinExtra.inc=\t%4f MB", Lof("WinExtra.inc")/1024/1024)
Exit
end start
Size of Windows.inc= 977412 bytes
Size of WinExtra.inc= 1.019 MBYou can even print Chinese and Arabic text to the console with MasmBasic Print, if the fonts are available on your machine.
hey jj2007 :biggrin:
thank you for your info
I have looked through your macros and I appreciate your work :eusa_clap:
I know how much effort and knowledge and patience was needed to create it
However, I newer tested it because I don't do 32 bits any more, I don't want to go back to 4 registers and I despise BASIC sins C64
I love assembler
I love 64 bits and 7 nonvolatile registers, they make such a great advantage and ease in programming and, of course speed
I love new horizons, new technology
I enjoy remembering the past but I don't wont to go back
best regards :biggrin:
hi habran,
64-bit certainly is the future, but 32-bit will be around for a long while. I am still using 16-bit apps, even on a Win7-64 system in a VM.
As to speed, it still has to be proven that 64-bit apps are faster. You rarely run out of registers, especially in fast innermost loops that won't call slow Win APIs. And 64-bit code eats up cache, so on balance it's hard to prove that 64-bit code is "faster". Of course, there will be quite a number of applications that can be done faster, e.g. for videos or image processing.
But the transition 32->64 cannot be compared to the (still incomplete) 16->32 bit transition. When porting 16-bit code to 32 bits, you get a huge speedup, and the address space jumps from a tiny 65K to 4 gigs. To visualise that step: a typical 500*600 pixel JPG fits into 65k (so 16 bits of address space are indeed a little bit tight :(). The largest Hubble image so far is 15852*12392 pixel, that requires a 3x2.5 meter screen. To fill the 4 gigs of 3-bit mode address space, you need a 180x150 meter screen. I can afford my notebook, but I cannot afford a screen as large as two football camps...
Now try convincing me that two football camps are not enough ;-)
Hey jj2007
Did I say that YOU should do this or that? :shock:
Why would I do that?
I have no desire to convince YOU to anything, you are grown up person
able to make your own decision
have look what I wrote: I, I, I, I, I ...
I can not expect everyone to think as I do
this world would be boring that way
everyone has got right to live in they own delusion
Imagine this forum, you write a post like:
"Hey guys, I think that farting should be done loudly" ;)
and everyone writes:
"Way to go jj" :biggrin:
have a nice day jj2007 :biggrin: :biggrin:
Quote from: habran on November 07, 2012, 06:14:36 AM
Hey jj2007
Did I say that YOU should do this or that? :shock:
Hey habran,
Did I say that YOU should go back to Win-32? :shock:
;)
Win-32 and Win-64 will peacefully co-exist for a long time, and so will their respective fans :biggrin:
have a nice day habran :icon14:
Hi jj,
QuoteWin-32 and Win-64 will peacefully co-exist for a long time, and so will their respective fans
nicely said :t
If you really said that:
Quote"Hey guys, I think that farting should be done loudly"
I would disagree with you and write:
It should be done Incognito, silent-violently to make people suffer :icon_redface:
Suffering refines human souls :badgrin:
;)
I have fixed some more bugs and refined the source 8)
I am planing some more improvements ;)
I know that you are looking backward to it so I will hurry up :greenclp:
I like to see disappointment in human eyes, that makes me a winner :badgrin:
and, of course, a greener :biggrin:
I have done what nidud was asking for
now it is possible to call C functions like
.for (ebx = strlen(ADDR src)¦memcmp(ADDR src,ADDR dest,count)¦ebx-=2)
;or
.for (ebx = 24¦ebx >= strlen(ADDR src)¦ebx-=2)
and it is possible to use OFFSET or ADDR
thanks nidud for the idea :t
it would be possible to make it the same for .IF and .WHILE :eusa_dance:
and I think that it would be great to have all this available :icon_cool:
my mom always told me "To have more doesn't hurt if it is not a pain by itself"
added possibility to use 'a' characters like:
.for (al = 'h'¦al < 's'¦al++)
you can use any character except '¦'
changed to 209
fixed some issues with && and ||
this is the "final destination"
I will not do it any more :eusa_naughty:
if someone want to continue they can use the source and implement it :eusa_boohoo:
OK, I lied! :icon_mrgreen:
I have improved and reduced the conditional branch totally so that it is now using "EvaluateHllExpression()"
instead of parsing it myself
now is the conditional branch working the same way as ".while" so you can use it exactly the same as it
it looks like that you write: .for (i=0¦.while i<20¦i++) but without .while like this: .for (i=0¦i<20¦i++)
initially, when I started this I wanted to do this but I was not familiar enough with JWasm to be able to do that
now you can not use it any more like this:
.for (ebx = strlen(ADDR src)¦memcmp(ADDR src,ADDR dest,count)¦ebx-=2)
but like this:
.for (ebx = strlen(ADDR src)¦ebx>=40¦ebx-=2)
8)
There was a bug in the code "ForInitAndNext()" :icon_redface:
it is fixed now 8)
Actually, there were two bugs :icon_redface:
it was not my fault, the bug was hiding in the hole but I crushed it :badgrin:
now there is none (I hope so) :biggrin:
this time I used the MORTEIN :badgrin:
no more bugs!!!
Good to know habran. :t
Gunther
I have modified code to work exactly as C
Quote from: habran on February 01, 2013, 06:35:52 AM
I have modified code to work exactly as C
Interesting stuff. JWasm is written in C, and now we can use JWasm as C in some
of its features. At least I hope the JWasm version is faster/smarter/smaller/...er than
C counterpart. :t
"Frankly" :biggrin: it's well optimized
I've wished someone gave me a feedback after testing it
thanks Frank
:icon_confused:
Quote from: habran on February 01, 2013, 01:32:33 PM
I've wished someone gave me a feedback after testing it
JWasm32 told me that MSVCR110.dll was missing (on Win7-32). After fixing this, here are some timings:
AMD Athlon(tm) Dual Core Processor 4450B (SSE3)
22317 cycles for 100 * C style for loop
31539 cycles for 100 * Basic style for loop
14 bytes for C style for loop
30 bytes for Basic style for loopSo your code is really competitive :t
Here are the two loops compared:
m2m eax, 40
.for (ecx = 0¦ecx<=eax¦ecx+=1)
inc edx ; inc eax hangs
.endfor
m2m eax, 41
For_ ecx=0 To eax-1
inc eax ; inc eax OK
Next
The Basic loop is a bit more flexible, as it can handle
eax+whatever, and references to the
initial eax (or whatever) while looping. On the other hand, the C loop is shorter and faster. In real life, if speed was an issue, I would use a .Repeat ... .Until construct anyway, but I guess for C coders your add-on to JWasm is really handy :t
P.S.: I made a little test with Pelles C:
int n=100;
__asm int 3;
__asm nop;
for (jjc=0; jjc<n; jjc++) {
n++;
}
__asm nop;
00401DD5 |. 90 nop
00401DD6 |. 31C0 xor eax, eax
00401DD8 |. BA 64000000 mov edx, 64
00401DDD |> 42 /inc edx
00401DDE |. 40 |inc eax
00401DDF |. 39D0 |cmp eax, edx
00401DE1 |.^ 7C FA \jl short 00401DDD
00401DE3 |. 90 nopHeavily optimised (bravo, Pelle :t), and it seems indeed that C keeps referring to the
current loop counter, i.e. this loop stops only for edx = 80000000h 8)
thanks JJ for testing it
if you write it like this:
.for (ecx = 0¦ecx<=40¦ecx++)
inc eax
.endfor
you will get:
004C879 xor ecx,ecx
004C87B jmp 004C87Fh
004C87D inc ecx
004C87F cmp ecx,28h
004C882 ja 004C888h
004C884 inc eax
004C886 jmp 004C87Dh
I have optimized it so that:
++ will be transformed to INC
-- will be transformed to DEC
but:
+= is ADD
and:
-= is SUB
Quote from: habran on February 01, 2013, 10:32:10 PM
thanks JJ for testing it
if you write it like this:
.for (ecx = 0¦ecx<=40¦ecx++)
inc eax
.endfor
you will get:
004C879 xor ecx,ecx
004C87B jmp 004C87Fh
004C87D inc ecx
004C87F cmp ecx,28h
004C882 ja 004C888h
004C884 inc eax
004C886 jmp 004C87Dh
Compliments habran, a really good job. :eusa_clap:
Thanks Frank :biggrin:
One who can see quality of others, posses quality himself
who wrote that? :shock:
habran himself :lol:
I added Jwasm.zip with 32 bits version with /MT option
needs at least Windows version 6
(Japheth)
however, you have a source code and can build for your system if it is older
Quote from: habran on February 04, 2013, 03:41:52 PM
I added Jwasm.zip with 32 bits version with /MT option
It should be noted that the binary is marked as "needs at least Windows version 6" ( which is Vista ). With XP, you get a message box saying that jwasm.exe "is not a valid Win32 application".
:redface:
Quote from: habran on February 01, 2013, 10:32:10 PM
thanks JJ for testing it
if you write it like this:
.for (ecx = 0¦ecx<=40¦ecx++)
inc eax
.endfor
Habran,
The immediate case
ecx<=40 is trivial. More tricky is what happens when you pass the bounds in (volatile/non-volatile) registers:
; assume eax was set somewhere else, as a return value:
.for (ecx = 0¦ecx<=eax¦ecx+=1)
inc eax ; hangs in C/your JWasm version, in contrast to BASIC/MasmBasic
.endforThe point is that
ecx<=eax is not checked only at the beginning, but rather for every loop. Which implies that in practice you cannot use eax, ecx, edx for bounds if calls are inside the loops.
In MasmBasic it's possible, which is the reason why it is some cycles slower. Speed against convenience, as usual :biggrin:
thanks Japheth I was not aware of that
I don't have Xp nor Vista I have Windos 7 on all computers
jj2007 it is possible to write this:
LIMIT EQU 40
THE_BREAK EQU 20
.for (ecx = 0,eax=LIMIT,edx=THE_BREAK¦ecx<=eax¦ecx++)
;inc eax it is illogical to increase a LIMIT especially with the same step
;of course it will hang
.break .if (ecx > edx)
.endfor
Quote from: habran on February 04, 2013, 10:04:30 PM
;inc eax it is illogical to increase a LIMIT especially with the same step
It depends on where you come from. For C coders, it may look illogical, but assembler coders might want to use return values directly...
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
GetFiles \Masm32\m32lib\*to* ; list conversion to something algos please
; # of files found is returned in eax, as usual
For_ ebx=0 To eax-1 ; it is illogical to forbid the use of eax inside the loop
Print Str$(ebx), Tb$, Files$(ebx), CrLf$
Next
Inkey
Exit
end start
And no, I don't want
you to change your logic :biggrin:
Quote from: jj2007 on February 04, 2013, 08:44:53 PM
The point is that ecx<=eax is not checked only at the beginning, but rather for every loop.
Yes, of course. Anything else would be VERY unintuitive ( at least for non-BASIC coders ).
Quote
In MasmBasic it's possible, which is the reason why it is some cycles slower. Speed against convenience, as usual
... another MB promotion thread ... :icon_rolleyes:
Quote from: japheth on February 05, 2013, 12:49:58 AM
Yes, of course. Anything else would be VERY unintuitive
japheth,
Take it easy. Assembler != C, and assuming some"logic" is a source of difficult to chase bugs. Remember the debate about Switch/Case and falling thru? VERY unintuitive what C does, at least for the rest of the programming world.
Quote... another MB promotion thread ...
thanks again Japheth :eusa_clap:
Look at this ugly code:
QuotePrint Str$(ebx), Tb$, Files$(ebx), CrLf$
only mother can love such an ugly child :lol:
I fill like I will sting my eyes on all of these $$$$$$$ :dazzled:
sorry JJ I like you but I can not like this ugly code, look at this line:
Quote
Inkey Str$("Size of Windows.inc=\t%i bytes", Lof("Windows.inc")), Str$("\nSize of WinExtra.inc=\t%4f MB", Lof("WinExtra.inc")/1024/1024)
it looks like swearing in comic books
I fill sea-sick looking at it ::)
jj2007,
you have a great programmer's skills, use it to create some beautiful code :biggrin:
:greenclp:
I admire your great sense of humour JJ
Same to you, young friend :t
By the way:
Quote from: habran on February 05, 2013, 06:05:05 AM
....I can not like this ugly code, look at this line:
Quote
Inkey Str$("Size of Windows.inc=\t%i bytes", Lof("Windows.inc")), Str$("\nSize of WinExtra.inc=\t%4f MB", Lof("WinExtra.inc")/1024/1024)
it looks like swearing in comic books
I fill sea-sick looking at it ::)
jj2007,
you have a great programmer's skills, use it to create some beautiful code :biggrin:
Can you show me how to do that in C, with beautiful code? Same functionality, of course.
Hi jj2007,
if you find yourself offended I apologize, that was not my intent
I am an assembler programmer, primarily :t
secondarily, I am C, C#, java, C++ (in that order from left to right)
100 years ago I was a BASIC programmer (or maybe only 30... years ago) on C64
for very short time and switched to ASM and fell in love with it :icon_redface:
C is closest to ASM but produces a lot of unnecessary repetition of same codes
while hll ASM looks similarly and is easy to read but is many-fold shorter and faster
I am a perfectionist as well as an artist, I enjoy in a simple natural beauty
and ASM is closest to the nature of processors (except 01001011)
when programming in ASM I am the master and in hll I am a slave
If you want me to show you how to write your code in C or ASM, compile your code and post it here,
or somewhere else, and I can try to make it look beautiful :eusa_boohoo:
however, in my opinion japheth is the greatest C programmer in this forum
and if you look through JWasm source code you will find the beauty of C programming :eusa_clap:
best regards
Quote from: habran on February 05, 2013, 01:47:27 PM
If you want me to show you how to write your code in C or ASM, compile your code and post it here,
or somewhere else, and I can try to make it look beautiful :eusa_boohoo:
You showed it already above, here the complete example:
Quoteinclude \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
Inkey Str$("Size of Windows.inc=\t%i bytes", Lof("Windows.inc")), Str$("\nSize of WinExtra.inc=\t%4f MB", Lof("WinExtra.inc")/1024/1024)
Exit
end start
Output:
Size of Windows.inc= 977412 bytes
Size of WinExtra.inc= 1.019 MBInkey = string to screen ("cout" seems to be the C equivalent) plus wait for a keypress
Str$(n) = the string representation of the number n
Lof(path or #n) = the length of a file
I am curious to see how this five-liner can be made more beautiful. Really, no joke.
(you see of course that it has to be started from \masm32\include to show results)
Quotehowever, in my opinion japheth is the greatest C programmer in this forum
The overall level here is remarkably high; among the C coders subset, qWord (for example) is very bright, too. But I agree that japheth has done an outstanding job with JWasm, and if he can solve his problems, he will certainly make a career.
Quote("cout" seems to be the C equivalent)
"cout" is not "Inkey" it is "Outkey" and not in C but in C++
examples:
//C++ C example
#include <iostream>
using namespace std;
int main()
{
string answer;
cout << "Please enter your name: " << endl;
cin >> answer;
cout << "Your name is: " << answer;
return 0;
}
/* C example */
#include <stdio.h>
int main()
{
char answer[256];
printf ("Please enter your name: ");
fgets(answer, 256, stdin)
printf ("Your name is: %s\n", answer);
return 0;
}
can you see that C++ looks ugly?
and C looks nice
Hi habran,
Quote from: habran on February 05, 2013, 08:51:54 PM
//C++ C example
#include <iostream>
using namespace std;
int main()
{
string answer;
cout << "Please enter your name: " << endl;
cin >> answer;
cout << "Your name is: " << answer;
return 0;
}
/* C example */
#include <stdio.h>
int main()
{
char answer[256];
printf ("Please enter your name: ");
fgets(answer, 256, stdin)
printf ("Your name is: %s\n", answer);
return 0;
}
can you see that C++ looks ugly?
and C looks nice
My first language is assembly language; I started with IBM 360 assembly language and PL/1 35 years ago. I've written programs in FORTRAN, COBOL, PASCAL, Modula2, BASIC and yes, in C and
C++. C was developed to write operating systems; in its first version it couldn't do normal mathematics. Period.
Everyone has the freedom to write programs in his prefered language. I'm not such a sophisticated C programmer like Japheth, you know, but Jochens code is very densed. I'm sure he could write the same in a better readable form with the same functionality and it'll do the same job as your C equivalent. What is the advantage of your C++ code? Your code has a lot of red band (calling a constructor, calling a destructor, name mangling, name decoration) and depending on the used compiler different mangling schemes. Please have a look at the assembly language output and you'll see what I'm speaking about.
Gunther
Quote from: habran on February 05, 2013, 08:51:54 PM
"cout" is not "Inkey" it is "Outkey" and not in C but in C++
Sorry, got confused :redface:
Quote#include <stdio.h>
int main()
{
char answer[256];
printf ("Please enter your name: ");
fgets(answer, 256, stdin)
printf ("Your name is: %s\n", answer);
return 0;
}
can you see that C++ looks ugly?
and C looks nice
Indeed nicer then C++ :biggrin:
include \masm32\MasmBasic\MasmBasic.inc
Init
Print "Your name is ", Input$("Please enter your name: ", "Habran")
Exit
end start
(note the added functionality - try to do that in C ;))
Hi Gunther,
you are right, C++ is ugly and produces to much unnecessary code
that is why I said I fell in love with ASM 30... years ago
QuoteI am an assembler programmer, primarily
means my preferable language is the assembly language
lately I do only 64 bit programming with the best assembler ever, JWasm
there is so much advantage in using all possible registers
if there was no assembly language I would probably give up programming and play chess
so, all in all I agree with everything your said :lol:
jj2007,
QuoteSorry, got confused
apology accepted
Quote(note the added functionality )
did you mean:
Quote"Habran")
:biggrin:
jj2007,
did you try to run your "InputHabran.exe" ??? :icon_eek:
if not do it now :badgrin:
;)
I know C pretty good, but I'm no expert ( had to learn very recently that in the jwasm source I used strcpy() for overlapping regions - which may give undefined results ).
And I'm not going to "make a career", because I'm in an age where a career has already been made - or doesn't happen at all, as in my case :bgrin:.
Sure I ran it. Any problems? I can't test it right now under Win7-64 but with Win7-32 it simply shows this:
Please enter your name: Habran << you can edit that
... and, when you hit Enter:
Your name is Habran
So what's the problem on your end? Which OS?
first empty window with a prompt and than you can not do nothing with window
but when you type something after quite a while it appears:
"Please enter your name:" and that what you tipped in
Same for second attempt? It could be an AV problem. Which OS are you running? Anybody else having the same problem?
Windows 7 64 bit
Thanks, will check tonight. Could be related to WriteConsoleInput. Most of the time Win7-32 and Win7-64.32 are compatible but there are some surprises (for ex, the Win7-64 32-bit APIs trash xmm regs while their Win7-32 bit counterparts don't...).
EDIT: Just tested on Win7-64, it works like a charm. So either you are pulling my leg, or there is some interference from a crappy AV.
I was not pulling your leg it was not working
however, this morning it works properly and when I run it this pops out:
"Please enter your name: Habran"
maybe my machine was tired after whole day running :icon_eek:
no, she is young :P
she just let me know that she doesn't like BASIC either :bgrin:
Interesting, now I put it on my desktop and now behaves again as before :icon_eek:
and after writing the line above I tried to run it again and it worked again as it supposed to
I am curies if someone else had the same behavior
what did you do jj? did you put a poison in your program?
do you want to poison my machine? :shock:
Quote from: habran on February 06, 2013, 06:07:55 AM
what did you do jj? did you put a poison in your program?
do you want to poison my machine? :shock:
Beware of evil BASIC programmers, Habran. Or open the source and have a look. Or run it in Olly - that would actually be the best idea, because you could find out where it starts misbehaving. My guess is the problems start before the entry point - AV or other watchdogs in the system that discover that somewhere this proggie uses deprecated instructions like lodsd or pushad :icon_mrgreen:
OTOH, I never had problems on Win7-64, except for the trashing of xmms (but that was solved some months ago). What AV are you using, if any? Jotti says F-PROT believes it's a dangerous malicious something (http://virusscan.jotti.org/en/scanresult/a3f2eef6618bebe67b6cfd204ae35b9f6f5e0172), they call it W32/FakeAlert.FJ.gen!Eldorado :greensml:
hey jj, you evil programmer, :badgrin:
I am using Microsoft Security Essentials
and sins than my computer is running like a charm :t
I was busy till now earning my living and now I will look inside your evil BASIC :biggrin:
:biggrin: Me too MSE, although some say it's fast because it's so superficial that it never finds anything :greensml:
In case you are using Olly:
- does it load fast (i.e. via the Open menu)? Sometimes Olly takes ages to analyse the main module...
- if you hit F9, does it show the prompt immediately, or does it hang somewhere?
when I run it with olly it takes long to analyze but when I press F9 text appears immediately
but when I run it by itself it takes probably about 10 seconds for text to appear and than if you want to close
it takes again about 10 seconds but it closes itself
sorry, I don't like olly because the font is to small and it is very hard to read it
I tried to change the font size but it is Mission Impossible Vll with Oleh Yuschuk as main character :icon13:
as I said before I don't do 32 bits anymore
that is why I use WinDbg or M$V$ (BASIC!) you love it :P
If you build it as a DEBUG version an supply .pdb
I can look at it otherwise forget about it :bgrin:
Quote from: habran on February 06, 2013, 10:24:53 PM
If you build it as a DEBUG version an supply .pdb
I can look at it otherwise forget about it :bgrin:
Here it is, enjoy. However, the behaviour you describe means the prog works fine, but the OS "reflects" a lot
before executing it. I see that behaviour often in office environments, also for pure Masm32 apps. Ten seconds is a lot, though :P
Re Olly's font: Right-click, "Appearance" at the bottom, Font, System fixed font should do fine.
Japheth
you know C pretty, pretty, pretty... good and if you wrote strcpy() routine it would probably behave better than it does now ;)
Quote
And I'm not going to "make a career", because I'm in an age where a career has already been made - or doesn't happen at all, as in my case
why, are you already dead? :icon_eek:
Quote from: habran on February 07, 2013, 06:29:37 AM
why, are you already dead? :icon_eek:
It's not on my agenda. IMO working in the IT business is no fun at all.
Quote from: japheth on February 08, 2013, 12:34:26 AM
IMO working in the IT business is no fun at all.
Some people seem to enjoy IT business, others a bit less.
It all depends on personal history in the field. But I think,
anyway, there is a time when you enjoy/enjoyed it.
JJ2007,
Delay was my machine because I had open to many apps
here is a beauty in asm:
include \masm32\include\masm32rt.inc
.data?
buffer db 132 dup (?)
align 4
CTEXT MACRO text:VARARG
local TxtA
.data
TxtA BYTE text,0
.code
EXITM <ADDR TxtA>
ENDM
.code
main PROC
invoke StdOut,CTEXT("Please enter your name: ")
invoke StdIn,ADDR buffer,128
invoke StdOut,CTEXT("You have beautiful name ")
invoke StdOut,ADDR buffer
invoke StdOut,CTEXT("Press any key to continue . . .")
invoke wait_key
invoke ExitProcess, 0
ret
main ENDP
END main
and here in C:
#include <stdio.h>
int main()
{
char answer[256];
printf ("Please enter your name: ");
fgets(answer, 256, stdin);
printf ("You have beautiful name %s\n ", answer);
return 0;
}
Quote from: habran on February 08, 2013, 10:57:35 AM
... in C:
#include <stdio.h>
int main()
{
char answer[256];
printf ("Please enter your name: ");
fgets(answer, 256, stdin);
printf ("You have beautiful name %s\n ", answer);
return 0;
}
You know Habran, the keyboard god doesn't allow italian guys to type that
code easily, if they want to type all those nice "{}" they have to cramp their
fingers a bit. This is one of the reasons I gave up studying C and moved to MASM.
:P
Hey Frank Sinatra, :icon_eek:
You have tricked me, I thought you are from Vulcan 8)
I was not aware that you are from "San Remo" (I love those old songs) :P
I always thought about Italians as energetic people like TNT
and now you tell me that you are lazy to type "{}"
if so, you could have used "copy" and "paste" :eusa_dance:
BTW some wannabe programmers use only these two programmers skills :badgrin:
Now you have to admit to yourself and to this forum that the real reason for switching to ASM is because of its 5 elements:
POWER, BEAUTY, FLEXIBILITY, SIMPLICITY and COOLNESS* (no concatenating types but BYTE WORD DWORD QWORD ....) :t
*that means that you are "cool man" because you are an assembler programmer
have you ever seen an italian keyboard ?
it's hard to type when all your fingers are stuck together
(http://img8.joyreactor.com/pics/post/funny-pictures-auto-italian-hand-358248.jpeg)
(http://www.terena.org/activities/multiling/ml-mua/test/img/kbd_italian.gif)
Can you see any curly bracket on the italian keyboard?
Well I missed the train of C during my IT career, so now I switched
to MASM for the reasons habran said. I confess. :lol:
bravo dedndave!!! :eusa_clap:
you made my day! :t
where did you find it, that is the best thing that happened on this forum
finally we have a fan here
Frank, I thought that you are from San Remo but it looks like you are from Vatican:
Quoteto MASM for the reasons habran said. I confess.
CONFESS, CONFESS, CONFESS!!! :greenclp:
I have always had filling that assembly language is for hackers,
evil people, hacking in someone's programs 8)
however, now I am not so sure anymore if it comes from Vatican, blessed by the Pope :icon_confused:
Now I feel relieved :biggrin:
thank you boys for giving me a reason to continue contributing to this forum :t
Hey JJ2007,
wake up! :biggrin:
here are both binaries and source with PDB files
they are debugable with WinDbg
I was unable to do it with your app with WinDbg, only with olly
here you can insert breakpoints in source mode
if you still deny to see a beauty in assembly source I will make you to CONFESS it :bgrin:
Quote from: habran on February 08, 2013, 10:57:35 AM
JJ2007,
Delay was my machine because I had open to many apps
Good to know, I was a bit worried :icon_mrgreen:
Quotehere is a beauty in asm:
Not bad, but it doesn't do much. Where is the "edit your prefilled string" functionality? :biggrin:
Quote from: habran on February 08, 2013, 11:57:48 PM
Hey JJ2007,
wake up! :biggrin:
...
if you still deny to see a beauty in assembly source I will make you to CONFESS it :bgrin:
You haven't seen the source code of MasmBasic - that is real beautiful assembly :biggrin:
QuoteYou haven't seen the source code of MasmBasic - that is real beautiful assembly
that was exactly my point, you are hiding a beautiful part from us and showing us the ugly one
it is the same as if you were wearing your underpants inside out after wearing it for one week normally :lol:
QuoteNot bad, but it doesn't do much. Where is the "edit your prefilled string" functionality?
don't exaggerate but CONFESS and you'll reach nirvana like Frank did :biggrin:
Quote from: habran on February 09, 2013, 06:05:24 AM
you are hiding a beautiful part from us
\Masm32\MasmBasic\MasmBasic.inc is public. When you are finished studying the 8,400 lines, let me know :biggrin:
Quote from: habran on February 09, 2013, 06:05:24 AM
CONFESS and you'll reach nirvana like Frank did :biggrin:
:P = pre-nirvana state
:icon_eek: = nirvana state
:dazzled: = post-nirvana state
forum rule #21
don't get Frank too excited :biggrin:
.for ( :P = pre-nirvana state¦ :P < :icon_eek:¦ :P++)
.break .if ( :dazzled:)
.endfor
JJ2007,
Where is the DLL source? :lol:
dedndave,
Quotedon't get Frank too excited
warning came to late :biggrin:
Quote from: habran on February 09, 2013, 02:48:52 PM
JJ2007,
Where is the DLL source? :lol:
Habran,
You seem to have problems with the BASICs: There is no DLL, only a SLL. And its source is
a) distributed all over the place, check the threads that contain
timers.asmb) in its condensed form as MasmBasic.asc: closed source except for people who have unambiguously proven that they love BASIC :greensml:
Quote from: habran on February 09, 2013, 02:42:26 PM
.for ( :P = pre-nirvana state¦ :P < :icon_eek:¦ :P++)
.break .if ( :dazzled:)
.endfor
Good one, habran. I like your
.for macro-nirvana. :t
I could learn even C/JWasm this way :lol:
OK JJ2007,
LET$ me PUT$$$ the question in other words:
FOR$$$ example where is the source of LET%&%$#@ say "MbPrint PROTO"
or "MbCopy PROTO :DWORD, :DWORD, :DWORD" ? ;)
thanks Frank
that's what are friends for :biggrin:
as you can see we can even tell a joke with a good programming :bgrin:
that is what I call a beautiful programming 8)
Quote from: habran on February 09, 2013, 11:36:42 PM
OK JJ2007,
LET$ me PUT$$$ the question in other words:
FOR$$$ example where is the source of LET%&%$#@ say "MbPrint PROTO"
You mean the one that allows strange things such as
Let My$(1,ecx)="This is Masm32: "+FileRead$("http://www.masm32.com")+CrLf$+My$(ecx,1)
FileWrite "test.txt", NoTag$(My$(ecx, ecx))
?? Caution, it's pure Masm :bgrin:
No, I just made a point that you are hiding your "pure MASM" like a serpent its legs ;)
however, I am not interested to study any 32 bit source code, even if it is a BASIC(!@#$%^&*),
because I don't do any more 32 bit, I do only pure 64 bit :t
Quote from: habran on February 10, 2013, 06:07:43 AM
No, I just made a point that you are hiding your "pure MASM" like a serpent its legs ;)
The macros are open anyway - \Masm32\MasmBasic\MasmBasic.inc
And the superfast algos are closed source because I don't want to pass my time chasing my intellectual babies all over the place, especially not in some obscure C libraries :greensml:
Those who have contributed over time are properly credited, and if somebody who made a significant contribution asks me for the source, I will share it with that person. Privately :biggrin:
That's what I pointed out
How can we admire your beautiful masm when all we see is BASIC($&@/!?%#¥€£~^*) :dazzled:
:biggrin:
8) :bgrin: :t :biggrin:
did you think that I was sleeping these few day :icon_eek:
if you did, you were wrong :eusa_naughty:
I have worked on optimization of this and look what I have got now:
option win64:0
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
xmemcpy PROC dest:QWORD,src :QWORD, count:UINT_PTR
mov rax,rcx
.if (rcx != rdx)
.for (¦r8¦r9b=[rdx],[rcx]=r9b,rcx++,rdx++,r8--)
.endfor
.endif
ret
xmemcpy ENDP
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
xmemcpy:
0000000140034218 mov rax,rcx
000000014003421B cmp rcx,rdx
000000014003421E je xmemcpy+1Eh (140034236h)
0000000140034220 and r8,r8
0000000140034223 je xmemcpy+1Eh (140034236h)
0000000140034225 mov r9b,byte ptr [rdx]
0000000140034228 mov byte ptr [rcx],r9b
000000014003422B inc rcx
000000014003422E inc rdx
0000000140034231 dec r8
0000000140034234 jne xmemcpy+0Dh (140034225h)
0000000140034236 ret
if you don't put r8-- last you get and r8,r8:
option win64:0
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
xmemcpy PROC dest:QWORD,src :QWORD, count:UINT_PTR
mov rax,rcx
.if (rcx != rdx)
.for (¦r8¦r9b=[rdx],[rcx]=r9b,r8--,rcx++,rdx++)
.endfor
.endif
ret
xmemcpy ENDP
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
xmemcpy:
0000000140034218 mov rax,rcx
000000014003421B cmp rcx,rdx
000000014003421E je xmemcpy+21h (140034239h)
0000000140034220 and r8,r8
0000000140034223 je xmemcpy+21h (140034239h)
0000000140034225 mov r9b,byte ptr [rdx]
0000000140034228 mov byte ptr [rcx],r9b
000000014003422B dec r8
000000014003422E inc rcx
0000000140034231 inc rdx
0000000140034234 and r8,r8
0000000140034237 jne xmemcpy+0Dh (140034225h)
0000000140034239 ret
I will test it a little bit more before I post it here
I have uploaded the new version at the beginning of this topic
this new optimization is for counting down to zero
it can be written as single like this "¦ var ¦" or this "¦ var > 0¦"
I have not changed only this but I changed the concept of whole routine
so that now behaves exactly as C "for" command :eusa_dance:
small bug fixed and uploaded new version 8)
hll.c added line 1394:
else hll->codelines = NULLC; //there is nothing after the second '¦'
the var hll->codelines was not cleared if there was nothing after second '¦'
Jwasm210 uploaded at the top of this trad