Author Topic: High Level Language in MASM  (Read 59296 times)

CommonTater

  • Guest
Re: High Level Language in MASM
« Reply #30 on: November 15, 2012, 02:29:53 AM »
yes - they do have their place
i tried other languages in days of old
but always came back to assembler because of some limitation from the compiler   :P

if i were writing apps on a professional basis, i would probably use C with some asm-created OBJ's

Yep... mostly I write in C... and occasionally dip into a couple of lines of ASM when needed.

That's not to say I have anything against ASM.  It is to say that, so far, I've been lucky enough to not get into projects that require ASM's fine grained code (and the learning curve that implies)... Now that I'm here, I'm hoping to pick some of it up by osmosis and do a little ASM coding for the experience.  I try very hard to never close my mind to new possibilities.


nidud

  • Member
  • *****
  • Posts: 1386
    • https://github.com/nidud/asmc
Re: High Level Language in MASM
« Reply #31 on: November 15, 2012, 04:37:27 AM »
No high level language owns assembler
:biggrin:
MASM is own by Microsoft, and it’s written in a high level language called C

JWasm is own by us, but this is also written in C, and there is a reason for this. If we then could agree on the fact that there are some benefits in writing applications in C compare to assembly, then we could move on to the issue at hand.

We have the source code to a MASM compatible assembler, and the capacity to apply changes to it. There is no intention of importing any constraints of C or any other high level language into this equation. What is suggested is to enhance the already built in hll directives by MASM. The aim is then to steal some of these benefits from C, and implement them to increase readability without breaking any already existing code.

The result could then be a smoother transition from C and an increase of the overall usage of assembly.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4874
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: High Level Language in MASM
« Reply #32 on: November 15, 2012, 09:19:31 AM »
The problem is that the facts also support writing apps in Pascal, Fortran and a number of dialects of basic. Nor does the language a tool is written in effect what its output is. Early C compilers were written in assembler, various compilers have been written in Pascal and i have seen compilers written in basic. I have no beef with C apart from its notation being a bit long in the tooth, many modern C compiler produce very good code as long as you are not doing anything that is truly critical and this is why Microsoft still update MASM on a needs basis.

As far as introducing C control flow directives into MASM, Microsoft did it in 1990 with MASM version 6.00 and it has had the capacity ever since. With current existing pre-processor macros, MASM does "switch" blocks with no problems and variations that a C compiler does not do, string versions of switch in case or casei variations. The more recent version of MASM32 also added the data type specifiers to function calls so the you have either pointers or dereference notation.

Then you have a project like JJ's MasmBasic which leverages the MASM pre-processor to produce a basic dialect while retaining all of MASM's capacity.

I more than happily encourage folks to keep extending MASM but you will have to forgive me in that I have heard too many zealots for other languages and it all sound much the same after a while.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

nidud

  • Member
  • *****
  • Posts: 1386
    • https://github.com/nidud/asmc
Re: High Level Language in MASM
« Reply #33 on: November 15, 2012, 11:51:18 AM »
I have never expressed any zealous attitude towards other languages. I only made a point of the fact that the hll section in MASM is based on C. I wrote an application in assembly and it become difficult maintain. I then started to use the hll directives (which I normally don’s use) to compensate for this, and discovered some shortcomings. I debated this with Japheth and he meant that this was a design flaw in MASM and not a bug JWasm. He is of course right in this regard. However, I looked at the source code and provided a fix for the label: macro() issue. This was fixed in v2.06, and now the .elseif macro(), and .while macro() issue is fixed using v2.08. JJ provided a test case for the bug, and this now seems to work, so I’m happy with the result. That’s about the size of it, no more, no less.

Since the feedback here seems to revolve around other unrelated issues, and the purpose of the fix only serves selfish interest, I will not pursue this any further.

jj2007

  • Member
  • *****
  • Posts: 7635
  • Assembler is fun ;-)
    • MasmBasic
Re: High Level Language in MASM
« Reply #34 on: November 15, 2012, 05:24:32 PM »
nidud,

You did a very good job on that late expansion problem :t

I only made a point of the fact that the hll section in MASM is based on C.

My previous favourite BASIC dialect, GfaBasic, born around 1988, features
REPEAT .. UNTIL
WHILE ... WEND
DO WHILE ... LOOP
DO ... LOOP UNTIL
IF ELSE ELSEIF ENDIF
SWITCH CASE DEFAULT ENDSW

But it did not require the excessive use of {strange brackets everywhere}, and both its interpreter and its blazing fast compiler knew that the end of a line is marked by CrLf, not by ;

So obviously MASM is based on GfaBasic.

japheth

  • Guest
Re: High Level Language in MASM
« Reply #35 on: November 15, 2012, 06:54:57 PM »
Since the feedback here seems to revolve around other unrelated issues, and the purpose of the fix only serves selfish interest, I will not pursue this any further.

You probably did not express yourself clearly in the first post - and in the thread caption. The topic becomes clear if you read everything carefully ... but quite a few people in this board are in "write-only" mode and a true discussion with them is virtually impossible.

Also, be a bit careful with statements about C. I well remember Agner Fog a few years ago who started a discussion about JWasm and assembly language "standards". He happened to make a innocent remark, kinda "C is probably sometimes better than assembly", and was then scared away by one of the super-intelligent super-moderators. This event made me realize that this forum is the WRONG place for ... "certain things".


MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: High Level Language in MASM
« Reply #36 on: November 15, 2012, 06:58:46 PM »
So obviously MASM is based on GfaBasic.

I think Microsoft started on MASM around 1980, so they must have had an early pre-alpha version that they pirated :biggrin:
Well Microsoft, here’s another nice mess you’ve gotten us into.

jj2007

  • Member
  • *****
  • Posts: 7635
  • Assembler is fun ;-)
    • MasmBasic
Re: High Level Language in MASM
« Reply #37 on: November 15, 2012, 08:45:25 PM »
So obviously MASM is based on GfaBasic.

I think Microsoft started on MASM around 1980, so they must have had an early pre-alpha version that they pirated :biggrin:

I was joking, of course. Around 1980 I coded in Fortran IV, and that looked similar, too. GfaBasic is a well-balanced mix of Fortran, Pascal and Basic syntax elements, but anyway, practically all languages have these constructs. Strange that C coders believe they invented it ::)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4874
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: High Level Language in MASM
« Reply #38 on: November 15, 2012, 10:19:18 PM »
Funny enough I used GFA basic back in the middle 90s as it out performed Microsoft C version 7.0. C version 6.0 was a much better version but had limited Windows support at the time. I wrote GFA basic until WinNT version 4 when I went to 32 bit with both MASM and PowerBASIC. I remember the guy I used to buy some basic stuff from in the DOS days giving me a copy of PowerBASIC to test out and it took me about 2 days to digest enough of it to start 32 bit Windows programming. I have been buying it ever since.

It is unfiortunate that GFA never made the transition to 32 bit properly as they wrote some good stuff in the late 16 bit Windows period. Their code example tended to be scruffy looking piles of crap but much of it works well. I already had the discipline of writing original SDK C for Windows so it was not a hard transition to full API code in both MASM and PowerBASIC. I can still write pure Microsoft C in 32 bit but I was long ago seduced by the sheer elegance of MASM. I still keep a number of C compilers going from VC98 up to current but most of the C code I have builds best in VC2003, the later versions became piggy and slower.

I actually liked the interface on early VB Versions but the fun stopped when you had to write some decent code behind the easy interface. It was an absolute toothless terror behind the scene and I gave up on it by about 1994.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4874
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: High Level Language in MASM
« Reply #39 on: November 22, 2012, 08:07:51 PM »
 :biggrin:

Quote
Also, be a bit careful with statements about C. I well remember Agner Fog a few years ago who started a discussion about JWasm and assembly language "standards". He happened to make a innocent remark, kinda "C is probably sometimes better than assembly", and was then scared away by one of the super-intelligent super-moderators. This event made me realize that this forum is the WRONG place for ... "certain things".

Something that some need to be aware of is how rare an assembler venue is yet after about 15 years of practice we still occasionally see and hear a selection of programmers waxing lyrical about the superiority of of the C language over others including assembler programming. There is a vast number of our members who can read and write competent C code with many years of experience but they write assembler code where they need it without needing to try and shift the status of one language over another.

Knowing the difference is where the action is, if you need high quality compiler code that is portable, C is a very good language and a massive amount of operating system code has been written in C but equally if you need high precision targeted code without the clunkyness of a high level language, assembler has no peers. There is of course considerable overlap between the two in Windows coding because the Windows API is available to both.

Its the old assumptions that were long ago discredited that can still grate when you hear another zealot waxing lyrical about the superiority of C as a language. I don't personally care if someone wants to create a macro system where you can write COBOL in MASM, as long as we are free from the dogma.  :P
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

CommonTater

  • Guest
Re: High Level Language in MASM
« Reply #40 on: November 22, 2012, 09:59:26 PM »
There is a vast number of our members who can read and write competent C code with many years of experience but they write assembler code where they need it without needing to try and shift the status of one language over another.

Last week I was helping a friend fix the drywall in his kid's bedroom (long story), and mostly I used a putty knife and sandpaper.

Before that I was busy working on a home theatre system and mostly I used a soldering iron and some transistors.

I'm often given to helping out in the  your link does not work IDIOT  and that's usually soaps and towels.

Programming is no different... you simply use the right tools for the job. 

There is no one universal programming language that is magically better than any other... each has it's strengths and weaknesses.  Delphi had a good run because you could knock out (bloated, slow and kludgey) code faster than you could say "spit".  C++ is pretty cool when you have data that can be easily compartmentalized in objects.  C is the man when it comes to general procedural programming (like Easy Build).  ASM is the obvious choice when you need to get down and dirty with the chip itself. 

OR... maybe your list is a little different. 

It doesn't matter, it's still all about using the right tool for the job.

dedndave

  • Member
  • *****
  • Posts: 8741
  • Still using Abacus 2.0
    • DednDave
Re: High Level Language in MASM
« Reply #41 on: November 22, 2012, 10:19:38 PM »
i don't really see one as "better" than another - no reason for it, really
i write in assembler because it is my preference
i have more experience with assembler and, thus, a shorter learning curve to get going
with me - the fewer changes i have to make, the happier i am - lol

if i had to write code on a day-to-day basis, i would probably want to use C with some routines in assembler
it's a matter of productivity and maintainability
this hypothetical company i work for can hire C programmers a lot easier than it can hire assembly programmers

nidud

  • Member
  • *****
  • Posts: 1386
    • https://github.com/nidud/asmc
Re: High Level Language in MASM
« Reply #42 on: November 23, 2012, 08:44:50 AM »
The experience:
I started using the hll directives and found out they where crap.
I analysed the situation and made some arguments.
I probed into the usage of it and found this to be very low.
The overall feedback was that this is a minor issue.

The assumptions:
I assume that the reason for not using it is bad experience.
I assume that the lack of interest is that nobody uses it.
I assume that removing the reason for not using it will increase usage.

Conclusion:
I fail to emphasise enough that this was an experiment, an idea to apply changes for increased usage in the future. By doing so I was mixing logic with assumptions. The problem with this experiment is that nobody knows the outcome of it, and the only way to find out is to implement the changes and wait for the results.

The feedback:
changes might break some existing code -- if (not may) so: problem
The hll section is bad, slow, ancient, junk -- agree: the window of opportunity.
The norm is to write the program in HLL and include some asm -- fact
The libraries and programs included in MASM32 is written in C -- fact
The C declarations are needed in assembly code using these libraries -- fact

Some results (MASM32):
Code: [Select]
        .WHILE TRUE
                invoke GetMessage, ADDR msg, 0,0,0
.BREAK .IF (!eax)
invoke TranslateAccelerator, hwnd, hAccel, ADDR msg
                .IF !eax
    invoke TranslateMessage, ADDR msg
                    invoke DispatchMessage, ADDR msg
.ENDIF
        .ENDW

    .while GetMessage(ADDR msg, 0,0,0)
.if !TranslateAccelerator(hwnd, hAccel, ADDR msg)
    invoke TranslateMessage, ADDR msg
    invoke DispatchMessage, ADDR msg
.endif
    .endw
if i had to write code on a day-to-day basis, i would probably want to use C with some routines in assembler
it's a matter of productivity and maintainability
this hypothetical company i work for can hire C programmers a lot easier than it can hire assembly programmers
True: C to asm:
Code: [Select]
#include <io.h>
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string. h>
..
int IOGetFileType(char *fname)
{
    char *p;
    p = strrchr(fname, '.');
    if (p == NULL)
        return NO_SOURCE;
    if (!stricmp(p, ".c"))
        return SOURCE_C;
    if (!stricmp(rsi, ".asm"))
        return SOURCE_ASM;
    if (!stricmp(rsi, ".idd"))
        return SOURCE_IDD;
    if (!stricmp(rsi, ".obj"))
        return SOURCE_OBJ;
    return –1;
}

include io.inc
include dir.inc
include stdio.inc
include stdlib.inc
include string.inc
..
IOGetFileType proc uses rsi fname:ptr byte
    invoke strrchr,fname, '.'
    mov rsi,eax
    .if !rax
        mov rax,NO_SOURCE
    .elseif !stricmp(rsi, ".c")
        mov rax,SOURCE_C
    .elseif !stricmp(rsi, ".asm")
        mov rax,SOURCE_ASM
    .elseif !stricmp(rsi, ".idd")
        mov rax,SOURCE_IDD
    .elseif !stricmp(rsi, ".obj")
        mov rax,SOURCE_OBJ
    .else
        mov rax,-1
    .endif
    ret
IOGetFileType endp

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: High Level Language in MASM
« Reply #43 on: November 23, 2012, 09:15:46 AM »
The problem as I see it is that no matter how much you massage the high-level syntax, or how creative your macros are, you still do not have anything close to a HLL syntax. To get the full benefit of coding in a HLL you need a HLL compiler. I think the time would be much better spent developing a compiler that would allow you to more or less freely mix HLL code with MASM/JWASM code and macros.
Well Microsoft, here’s another nice mess you’ve gotten us into.

qWord

  • Member
  • *****
  • Posts: 1464
  • The base type of a type is the type itself
    • SmplMath macros
Re: High Level Language in MASM
« Reply #44 on: November 23, 2012, 09:33:09 AM »
MREAL macros - when you need floating point arithmetic while assembling!