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

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #60 on: February 05, 2013, 06:05:05 AM »
Quote
... another MB promotion thread ... 
thanks again Japheth  :eusa_clap:

Look at this ugly code:
Quote
Print 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:
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #61 on: February 05, 2013, 07:12:17 AM »
 :greenclp:

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #62 on: February 05, 2013, 08:35:20 AM »
I admire your great sense of humour JJ 
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #63 on: February 05, 2013, 09:43:00 AM »
Same to you, young friend :t
By the way:

....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.

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #64 on: February 05, 2013, 01:47:27 PM »
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

   
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #65 on: February 05, 2013, 07:51:41 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:
Quote
include \masm32\MasmBasic\MasmBasic.inc        ; download
        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 MB


Inkey = 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)

Quote
however, 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.

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #66 on: February 05, 2013, 08:51:54 PM »
Quote
("cout" seems to be the C equivalent)

"cout" is not "Inkey" it is "Outkey" and not in C but in C++

examples:
Code: [Select]
//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
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 3723
  • Forgive your enemies, but never forget their names
Re: .FOR built in JWasm
« Reply #67 on: February 05, 2013, 09:19:13 PM »
Hi habran,

Code: [Select]
//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   
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #68 on: February 05, 2013, 10:22:27 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 ;))

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #69 on: February 05, 2013, 10:59:09 PM »
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
Quote
I 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,
Quote
Sorry, got confused
apology accepted
Quote
(note the added functionality )
did you mean:
Quote
"Habran")
:biggrin:
 
Cod-Father

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #70 on: February 05, 2013, 11:11:15 PM »
jj2007,
did you try to run your "InputHabran.exe" ??? :icon_eek:
if not do it now  :badgrin:
 ;)
Cod-Father

japheth

  • Guest
Re: .FOR built in JWasm
« Reply #71 on: February 05, 2013, 11:29:07 PM »

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:.
 


jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #72 on: February 05, 2013, 11:30:03 PM »
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?

habran

  • Member
  • *****
  • Posts: 1226
    • uasm
Re: .FOR built in JWasm
« Reply #73 on: February 05, 2013, 11:43:50 PM »
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
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #74 on: February 05, 2013, 11:58:11 PM »
Same for second attempt? It could be an AV problem. Which OS are you running? Anybody else having the same problem?