News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

I come from mainframe IBM/360

Started by alanabbott, June 19, 2008, 12:43:17 PM

Previous topic - Next topic

alanabbott

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.



jj2007

Install the latest Masm32 from here 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

japheth

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

jj2007

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

alanabbott

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

japheth

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


Vortex

Hello alanabbott,

Welcome to the forum.

alanabbott

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.


UlliN

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


jj2007

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]

japheth

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.

hutch--

 :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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rainstorm

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

GregL

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.


japheth

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.