The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: alanabbott on June 19, 2008, 12:43:17 PM

Title: I come from mainframe IBM/360
Post by: alanabbott on June 19, 2008, 12:43:17 PM
I want to use cataloged Macros and copy libraries, Dummy Sections. "TR" & "TRT" (translate & translate and test).
Where can I red on these subjects.
I´m looking for something similar to the book "VB for COBOL programmers".

Assembler was my first language and I still have a some modules in production.

These I down scaled to PC in Realia COBOL 4.2 which is 16 bit, Computer Associates quoted
u$s- 7,000 for an upgrade of a packet I paid originally $ 500.- (Version 3.0)in 89 and u$s.200 for the upgrade (4.2).
I can not foot this, and further more the quote is about 3 years old from thier office in BA Argentina,
I do not know what they would want  now.


Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 19, 2008, 12:58:56 PM
Install the latest Masm32 from here (http://www.masm32.com/download/beta10i.zip) and have a look at \masm32\help\hlhelp.chm
You will be surprised how easy it is to code in 32-bit assembler. Here is a Hello World proggie...

include \masm32\include\masm32rt.inc

.code
MyApp     db "Test:", 0
MyString   db "Hello World!", 0

start:   invoke MessageBox, 0, addr MyString, addr MyApp, MB_OK
   exit

end start
Title: Re: I come from mainframe IBM/360
Post by: japheth on June 19, 2008, 01:19:56 PM
Here's the Win32 hello world in Cobol. Nice and easy. Of course not just a primitive MessageBox as jj2007 tries to sell but a good console sample:


      $set mf case ans85 defaultbyte"00" noosvs nobound
      $set align"4"
      *
       identification division.
      *
       program-id. cobsmpl.
      *
       environment division.
       special-names.
         call-convention 74 is WINAPI.
      *
       data division.
       working-storage section.
         01 hConout   pic x(04) comp-5.
         01 text1     pic x(14) value "hello, world"&x'0d0a'.
         01 dwWritten pic x(04) comp-5.
         01 rc        pic x(04) comp-5.
      *
       procedure division.
          call WINAPI "GetStdHandle" using
by value -11
                returning hConout
          call WINAPI "WriteConsoleA" using
by value hConout
                by reference text1
                by value 14
                by reference dwWritten
                by value 0
                returning rc
          goback.

:green
Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 19, 2008, 01:27:24 PM
Cobol seems a fantastic language ;-)

Sorry, I had not realised that you wanted a console app. That makes "Hello World" a lot more complex, of course. Here is the console Hello World in assembler:

include \masm32\include\masm32rt.inc

.code
start:
print "Hello World"
exit
end start


Don't get scared too easily. We were all close to throwing our 'puter out of the window in certain moments, but some of us were able to overcome this sort of crisis. And we are a helpful bunch :toothy
Title: Re: I come from mainframe IBM/360
Post by: alanabbott on June 20, 2008, 05:13:24 PM
Thanks you very much, this has been of great use to me.
I just need to find an equivalent to Dummy Section (DSect) to define sheared structures that will reside in one module and be used by several function in different DLL's.   
The other thing I could use is getting storage dynamicly for these tructures.

Alan
Title: Re: I come from mainframe IBM/360
Post by: japheth on June 20, 2008, 06:05:31 PM
Hi Alan,

>I just need to find an equivalent to Dummy Section (DSect) to define sheared structures that will reside in one
> module and be used by several function in different DLL's.   

Masm is C oriented and implementes virtually everything similiar to C. That means, the equivalent for Dummy Sections are STRUCTs and UNIONs. You'll find a good description of how these items are used in the Masm documentation, which is available at various places.

> The other thing I could use is getting storage dynamicly for these structures.

This depends on the OS you are programming for. For Win32, there's a lot of differents memory alloc functions available, the simplest and best are HeapAlloc() and VirtualAlloc().

> That makes "Hello World" a lot more complex, of course. Here is the console Hello World in assembler:

Sorry JJ2006, but your sample is not assembler, this is boring Powerbasic stuff, with a grain of asm ...

Title: Re: I come from mainframe IBM/360
Post by: Vortex on June 20, 2008, 06:08:52 PM
Hello alanabbott,

Welcome to the forum.
Title: Re: I come from mainframe IBM/360
Post by: alanabbott on June 20, 2008, 08:17:03 PM
My needs are
1. read and decompress files (I compress in mainframe with my personal com presion scheme)
2. rewrite my personal SQL for 32 bit which now runs in mainframe and 16 bit Realia COBOL.

My users query the results thou Ex cell, Word and Access.

Basically the results are batch balance sheets extracted from 60 MB files (non compressed 280 MB).

For the writting of my SQL can be maneged with  any gui system. (VB C# or C++), I do not need speed there.

Title: Re: I come from mainframe IBM/360
Post by: UlliN on June 20, 2008, 11:20:23 PM
Hi alanabbott,

Cobol seems a fantastic language ;-)  YES it is!

It's very easy to use all the functions/procedures of the masm32.lib with COBOL:

e.g.  reading a file into a dynamic buffer :


        ...
        working-storage section.
        01 pFile                            pointer.
        01 LenOfFile                     pic 9(9) comp-5.
        01 rc                               pic 9(9) comp-5.

        linkage section.
        01 FileContent                 pic x(1000).
        procedure division.
            call winapi "read_disk_file" using
                                           "AnyFileName" & x"00"
                                            pFile
                                            LenOfFile
                           returning  rc
            if rc not = 0
                set address of FileContent to pFile

       ************************************************
       *- Now you can operate on FileContent(1:LenOfFile)
       ************************************************

       *- Release the buffer
               call winapi "GlobalFree" using by value pFile                         

            else
               call winapi "MBox" using "Open Error" & x"00"
                                                 "AnyFileName" & x"00"
                                                  by value 0                                                   
            end-if



with MASM-Proc  MBox:


.386
.model flat, stdcall
option casemap :none
;     include files
;     ~~~~~~~~~~~~~
      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\macros\macros.asm
;     libraries
;     ~~~~~~~~~
        includelib \masm32\lib\masm32.lib
        includelib \masm32\lib\user32.lib
        includelib \masm32\lib\kernel32.lib
;
.code

MBox proc uses esi,
               pCaption:dword, pText:dword, MBTyp:dword
     MsgBox 0,pText,pCaption,MBTyp
     ret
MBox endp

END



Just link your Cobol *.obj with masm32.lib and MBox.obj

Ulli

Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 21, 2008, 12:56:29 AM
Quote from: japheth on June 20, 2008, 06:05:31 PM
Sorry JJ2006, but your sample is not assembler, this is boring Powerbasic stuff, with a grain of asm ...

Sorry Japheth, you are in the wrong forum. This forum is about Masm, and the M stands for MACRO. Hutch has invested man-years of hard work to make assembler more accessible to those who come from other languages. Have a look at the libraries. Everybody can hide behind cryptic syntax... much as everybody is free to learn Japanese. Go back to machine code, if you find that less boring. I know you are an excellent programmer, sincere compliments for JWasm, so you should be able to poke the bytes and words directly into the machine, without boring interfaces called "Masm".
The code below opens two files, and performs a case-insensitive search in both of them to find a string. Its syntax resembles more BASIC than Assembler, but it assembles to a mere 3584 bytes, and is blazingly fast. Masm is about getting compact, fast and elegant output; it's not a competition for the most cryptic input.

And, by the way, although I appreciate the work of Bob Zale, and have bought a license some time ago, I don't use it and don't plan to use it. Masm is more challenging.

include \Masm32\gfa2masm\Gfa2Masm.inc

.data?
TitleBuffer dd 100 dup(?)

.code
Title$ dd TitleBuffer

start: invoke GetTickCount  ; start timer
push esi
push edi

push eax

; FindString pMain, Sub$   [, IgnoreCase]   [, sPos]   [, inFile$]   [, inFileEnd$]

FindString 0, "FR_MatchAlefHamza", 1, 1, "\masm32\include\winextra.inc", 0

.if eax==0 ; not found, let's try one more file
    FindString 0, "FR_MatchAlefHamza", 1, 1, "\masm32\include\windows.inc", 0
.endif

mov edi, ecx ; save the position
invoke GetTickCount  ; end timer
mov esi, eax

pop eax

sub esi, eax ; time in ms - we add 1 ms to make sure
inc esi ; people believe you how fast it is ;-)

; Compose the MsgBox title:
mov esi, MCAT$(Title$, "FindString took ", <STR$(esi)>, " ms:")

MsgBox MCAT$(FileBuf$, "We found the key in ", LastPath$, " at pos ", <STR$(edi)>, chr$(13,10,10), FifRet$), esi, MB_OK

pop edi
pop esi
free$ FileBuf$
exit
End start

[attachment deleted by admin]
Title: Re: I come from mainframe IBM/360
Post by: japheth on June 21, 2008, 05:13:17 AM
Quote from: jj2007 on June 21, 2008, 12:56:29 AM
Go back to machine code, if you find that less boring.

No. The M in Masm stands for Macro, but that doesn't mean that one MUST use macros excessively with Masm. And I also doubt that the macros implemented in Masm32 help those who come from other languages. There is some effort needed to learn ASM, and you won't learn it if everything is hidden in macros.
Title: Re: I come from mainframe IBM/360
Post by: hutch-- on June 21, 2008, 06:35:22 AM
 :bg

> Sorry JJ2006, but your sample is not assembler, this is boring Powerbasic stuff, with a grain of asm ...

No, its pure MASM, the "print" macro emulates IMB ROM BASIC (note the upper case). MASM is a macro assembler, not a bare mnemonic muncher.

Quote
No. The M in Masm stands for Macro, but that doesn't mean that one MUST use macros excessively with Masm. And I also doubt that the macros implemented in Masm32 help those who come from other languages. There is some effort needed to learn ASM, and you won't learn it if everything is hidden in macros.

Sad to say this theory is not based on practice, people who are faced with a bare assembler have a very high failure rate, people who start with libraries and macros learn faster, get more done and end up knowing something.
Title: Re: I come from mainframe IBM/360
Post by: Rainstorm on June 22, 2008, 02:00:02 AM
QuoteDon't get scared too easily. We were all close to throwing our 'puter out of the window in certain moments, but some of us were able to overcome this sort of crisis. And we are a helpful bunch tgrin
Laughing out Loud !!!!
Title: Re: I come from mainframe IBM/360
Post by: GregL on June 22, 2008, 04:25:19 AM
QuoteAnd, by the way, although I appreciate the work of Bob Zale, and have bought a license some time ago, I don't use it and don't plan to use it. Masm is more challenging.

Why limit yourself to one language? I like to program in several languages, including PowerBASIC, C, C++, C#, PowerShell.

Don't get me wrong, I love MASM, but I like programming in other languages too. I would have to say MASM is my favorite though.

QuoteNo. The M in Masm stands for Macro, but that doesn't mean that one MUST use macros excessively with Masm.

I say why not use macros? They eliminate repetitive typing and simplify complex blocks of code. They also come in really handy for later use.

Title: Re: I come from mainframe IBM/360
Post by: japheth on June 22, 2008, 06:59:40 AM
Quote
MASM is a macro assembler, not a bare mnemonic muncher.
Thanks for telling me.

Quote
Sad to say this theory is not based on practice, people who are faced with a bare assembler have a very high failure rate, people who start with libraries and macros learn faster, get more done and end up knowing something.

Since there's no evidence supplied ...

I suggest that we all continue to believe what we want to believe and everything's fine.
Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 22, 2008, 08:11:36 AM
Quote from: Greg on June 22, 2008, 04:25:19 AM
Why limit yourself to one language? I like to program in several languages, including PowerBASIC, C, C++, C#, PowerShell.
... I would have to say MASM is my favorite though.

I have programmed in several languages, starting with Fortran, ZX Spectrum BASIC, then GfaBasic and 68k assembler on Atari ST, Unix shell scripts, VB, JavaScript & DHTML, ... but I get strong allergic reactions when I see too many brackets around, so C is not on my list and will never be.

And yes, Masm is my favourite right now, because it's incredibly powerful and flexible and does not produce bloatware.

As to PowerBasic, I tested it but gave up when I saw that the compiler was ten times or so slower than my good ol' Gfabasic.
Title: Re: I come from mainframe IBM/360
Post by: hutch-- on June 22, 2008, 11:36:57 AM
 :bg

> Since there's no evidence supplied ...

I wonder what would qualify as evidence ?

When was the milionth download ? about 9 years ago. I don't count it any more

How long has the masm32 project been going ? Just over 10 years.

How many newbies have I dealt with over that period of time ? Dunno, I lost count.

Where do I get the idea of what succeeds and what does not ? From the number of newbies over that time period.

The market is well served with bare bones assemblers, why does MASM hold such a large market share ? Dunno, ask the newbies.  :bg
Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 22, 2008, 12:24:42 PM
Quote from: hutch-- on June 22, 2008, 11:36:57 AM
The market is well served with bare bones assemblers, why does MASM hold such a large market share ? Dunno, ask the newbies.  :bg
Watch your step, old man! Japheth's JWasm is advancing rapidly. For longer projects it's perhaps a bit slow, and my macros are a bit too complex for JWasm, but for newbies with small projects and no macros you are facing serious competition  :green
Title: Re: I come from mainframe IBM/360
Post by: hutch-- on June 22, 2008, 01:42:54 PM
I have made no criticism of Japheth's assembler. I am of the view that anyone who can resurrect WASM from the dead has done a lot of good work.

We differ on a notion that throwing learners into bare bones assemblers is useful, from 10 years of maintaining the masm32 project I have good reason to see it otherwise.

It has been my experience that people who use all of the high level simulations learn faster, write a lot more successful code and get to understand proper low level code reasonably quickly where people who get conned into the alternative more often than not get pissed off with bashing their heads against the wall and go and write VB or PHP or something really different.
Title: Re: I come from mainframe IBM/360
Post by: japheth on June 22, 2008, 03:06:05 PM
Quote from: jj2007 on June 22, 2008, 12:24:42 PM
Watch your step, old man! Japheth's JWasm is advancing rapidly. For longer projects it's perhaps a bit slow, and my macros are a bit too complex for JWasm, but for newbies with small projects and no macros you are facing serious competition  :green

As far as speed is concerned, there is indeed good reason for Masm to fear JWasm. Not the current v1.8 - I released it just yesterday - but the coming version. The original Wasm was utterly slow, initially one of my projects needed 12,000 ms  for a compile. For the final JWasm 1.7, it was reduced to about 5.000 ms, with JWasm 1.8 it is about 3.000 ms now. For JWasm 1.9, it will be about 1.000-1.250.

How is this achieved?

- for JWasm 1.7, the speed boost was achieved a) by increasing the hash table size significantly and b) by exchanging the memory allocation/deallocation routines.
- for JWasm 1.8, the speed boost was achieved by reducing the number of passes with a better management of forward references.

The strategy for the next speed boost is simple: avoid to scan the full source for every pass, instead just scan the - preprocessed - source from the position the first byte has been emitted. This will bring JWasm into the very same league with FASM, and Masm will be left behind as a lame duck  :green .




Title: Re: I come from mainframe IBM/360
Post by: jj2007 on June 22, 2008, 03:15:26 PM
Quote from: hutch-- on June 22, 2008, 01:42:54 PM
I have made no criticism of Japheth's assembler. I am of the view that anyone who can resurrect WASM from the dead has done a lot of good work.

I agree fully - he does a brilliant job. I just don't like the "boring Powerbasic" attitude; but it's probably mutual. C programmers believe that Basic code consists of GOTO's, while Basic programmers think that {C} programmers are a [bunch of] ->nerds with {Repetitive Stress Injury} and {no sense} of ->humour.

Quote
people who use all of the high level simulations learn faster, write a lot more successful code and get to understand proper low level code reasonably quickly where people who get conned into the alternative more often than not get pissed off with bashing their heads against the wall and go and write VB or PHP or something really different.
Exactly. I'd like to add that those who know how to write macros and prefer typing the same boring stuff over and over again are commonly called masochists.
Title: Re: I come from mainframe IBM/360
Post by: japheth on June 22, 2008, 03:22:29 PM
Quote from: hutch-- on June 22, 2008, 11:36:57 AM
:bg

When was the milionth download ? about 9 years ago. I don't count it any more

How long has the masm32 project been going ? Just over 10 years.

How many newbies have I dealt with over that period of time ? Dunno, I lost count.

Where do I get the idea of what succeeds and what does not ? From the number of newbies over that time period.


Thanks for providing some backup for my theory, Hutch--!  Because, if there were so many downloads and if there were so many noobies dealing with Masm32, then why is/was the general usage of ASM so declining, why are so many noobies just here for some weeks and then quickly abandon ASM again and last, why is Masm's market share not rising anymore, but instead - I guess - slighly declining?

No, there's no evidence for your claim, it's pure propaganda and, btw., there is always the argument: is it "because of" or is it "in spite of"?

:green
Title: Re: I come from mainframe IBM/360
Post by: hutch-- on June 22, 2008, 03:59:51 PM
I have been listening to the prophets of doom for the last 10 years and I have not heard anything new here. If assembler programming is declining, it sure does not show with the download rate over the last 10 years, it does not show with members who come in, learn enough and don't need te forum any longer and then there is the notion of falling market share, against what, the rest ?  :bg

RE: What learner "should" be doing, I hae heard all of this claptrap before in ALA, we did it that way so you should too.

The reason why you see no evidence is because you don't want to see evidence. I have no doubt that the vast number of successful MASM programmers sit up at night wiping away the tears inbetween wringing their hands at such revelations except that they could not be bothered hearing them.  :P