1830251 Members
2295 Online
110000 Solutions
New Discussion

How to learn Macro

 
SOLVED
Go to solution
Martin P.J. Zinser
Honored Contributor

How to learn Macro

Hi,

I do need to get a handle on the Macro language some time soon. Anybody knows Web resources and/or books teaching macro?

The only thing I've found yet is the reference manual, which is certainly useful later on, but first I am looking for "Hello World" to get me started ;-)

Thanks, Martin
24 REPLIES 24
Hein van den Heuvel
Honored Contributor

Re: How to learn Macro

This is not an april fool is it now Martin!?
You are of course right by looking at simple example, and a bunch of reading before serious writing.

VAX macro? Alpha? IPF?


Well, I have two VAX Macro, Alpha compatible, 'hello worlds' for you in my freeware submissions:


http://h71000.www7.hp.com/freeware/freeware50/rms_tools/bonus/fix_saveset.mar

[you'll appreciate the date in that file, but it was a serious program!]

And here is a tool I like a lot to poke at indexed files specifically, but in a pinch i use it to patch executables and stuff!

http://h71000.www7.hp.com/freeware/freeware50/rms_tools/src/zap.mar


Both tools are in Macro as that is the only language garantueed to be available on a VMS box. What is your excuse to write (maintain?) in Macro? (Pick C if you can escape still!)


Attached a couple more smallish standalone examples.

Enjoy,
Hein.

Willem Grooters
Honored Contributor

Re: How to learn Macro

Martin,

If I remember well, there are quite some examples on the freeware CD-s - better look for the OLD ones, or check the freeware archive for .MAR files.
If you master it: Welcome to the Ranks of Real Programmers (Sorry Hein)

Willem
Willem Grooters
OpenVMS Developer & System Manager
Willem Grooters
Honored Contributor

Re: How to learn Macro

BTW
I'll dig into my archives tonight and see if I can find some examples to share.

WG
Willem Grooters
OpenVMS Developer & System Manager
Martin P.J. Zinser
Honored Contributor

Re: How to learn Macro

Hello,

Thanks for some examples, they will certainly be helpfull once I've got the basic concepts and syntax of the language. What I am really looking for is a K&R or Camel book like introduction. In a pinch also the handouts of a course would be fine. Any idea where to find something like this?

Greetings, Martin

P.S. This is <> an Aprils fools joke. I registered for the crash dump class im May and one of the prerequesits is "brush up your Macro".
Hein van den Heuvel
Honored Contributor

Re: How to learn Macro

>P.S. I registered for the crash dump class im May and one of the prerequesits is "brush up your Macro".

That makes sense. You have be able to read the instructions and grasp what their intent is to fully appreciate a crashdump. [often the data structures help a lot/enough, but not always]

For that purpose you may want to consider using a regular Fortran or C program and compile/list=macro.

Next step, compil/debug/noopti, link/debu.
Run, and display source, AND instructions and use STEP /INST trying to understand the steps (step /over or step/ret to avoid going too deep in (rtl)procedutd.

Final step, compile/nodebug/opti and yet run/debug. Now see if you can still keep track of what the program is up to!

fwiw,
Hein.
Craig A Berry
Honored Contributor
Solution

Re: How to learn Macro

Martin, I have a college textbook style book on Macro that I bought at a used bookstore. I don't have it in front of me at the moment and don't remember the author, but it looks pretty good from what little time I've had to dip into it. I'd be happy to loan it to you for a few weeks; we could meet at the train station for a hand-off sometime.
Antoniov.
Honored Contributor

Re: How to learn Macro

Hello Martin,
I wrote using assembler in past (no CPU AXP); remember macro is very different form any other language: before you can write using macro you must known very well CPU architecture and CPU instruction set. It's not enough known about architecture (sorry for my broken english).
Then you have to learn about OS use CPU register: for example any function return status code into register zero (R0).
Remember also macro has a preprocessor (as C language) to declare some "high-level" statement.
Martin, if you have to write some serious programm in macro you need study a lot (more than high-level language).

@Antoniov
Antonio Maria Vigliotti
Antoniov.
Honored Contributor

Re: How to learn Macro

Hi Martin,
you could find something here:
German language: http://www.complang.tuwien.ac.at/ublu/
Commercial book:
http://all-computer-books.co.uk/RISC_microprocessors_Architecture.html
Compaq Alpha architecture
http://www.ee.lsu.edu/ee4720/alphav4.pdf
Some vax assembly handbook (same rules of macro, different assembly instruction set):
http://isbn.nu/0852744595
http://isbn.nu/0023992557http://isbn.nu/0139421521
http://isbn.nu/0805371222
http://isbn.nu/0697030601

Try using assembler or assembly insted of macro onto web search engine.

@Antoniov
Antonio Maria Vigliotti
Willem Grooters
Honored Contributor

Re: How to learn Macro


...if you have to write some serious programm in macro you need study a lot (more than high-level language).


If you're used to what I would consider "proper programming" - that is: VERY modular and thouroughly thought about before hitting any key - it's no more difficult than programming in a language as Fortran, Pascal or C.
Agreed, things get far more complicated since you have to do everything yourself - conversions, memroy mananegment, IO..., but where possible you can (and should) use system services, and create a kind of building blocks. Or better: 'steal' them.
It helps a lot if you have some idea of the processor and the rest of the architecture, but once you get familiar with is, it's more or less a piece of cake.
I would suggest to read the article in the latest issue of the VMS Technical Journal on this issue. It describes pretty well what I mean to say.
Willem
Willem Grooters
OpenVMS Developer & System Manager
Antoniov.
Honored Contributor

Re: How to learn Macro

Hello Willem,
I don't agree :-(
programming using assembler/macro require knoledge of CPU architecture.
For example (but it's only an example) you need known R0 register is changed by system call (as returc code);
Again: reading assembler code is not simple; every statement is a CPU instruction; yes usually you can use macro to abstract but most code is based on CPU instruction.
Again: if you have to interface a external C library (or any other language) you must known as parameter are pushed into stack while using high-level language you can ignore theese information!
I confirm my prior post: if Martin have to write some little routine he can work quicky by example but if he have to write more complex software have heavly to study.

Obviously it only my idea!

@Antoniov
Antonio Maria Vigliotti
Ian Miller.
Honored Contributor

Re: How to learn Macro

writing MACRO32 is good clean educational fun :-) Yes it requires some detailed knowledge but thats the fun of it.

I think you have the key references already.

On itanium VMS there is a IMACRO compiler (corresponding to AMACRO on alpha) which attempts to make sense of VAX assembly language. The VAX architecture is no more but the assembly language lives on!

Apart from fun and education why are you doing this?
____________________
Purely Personal Opinion
Willem Grooters
Honored Contributor

Re: How to learn Macro

Ian:
What about:
* control of virtually everything
* no (or less) overhead
* speed of execution

Martin:
There is a remarkebly good book on the VAX processor architecture written in the '80s - I'll share the details tonight if no-one has done already - that will surely help to grasp the ideas of MACRO32.
But since you'll attend the crashdump course, it will be on AXP, I think you'll need the AXP assembly language (MACRO64) wouldn't you? (It's on some freeware CD). I don't know of some book like above on AXP....

Antonio:
Don't get me wrong: yes, you DO need a fair understanding of the architecture when writing programs in MACRO. But it's no luxury either to know about it writing programs in any other language - and certainly when debugging to system level....I found this true on PDP, VAX, AXP, Zilog and IA32; it will apply to IA64 as well.
The point is: I found the VAX architecture pretty straight forward, and easy to grasp. So understanding it wasn't a big problem.
Basically, MACRO32, even on AXP, uses the same principles. What takes time is getting the dicipline to keep in mind what you're working with - and to anticipate on consequences of your choices (AKA "side-effects"). But that applies to 'standard' languages as well - whether it's COBOL, PASCAL, FORTRAN or C.
I didn't say it's easy. On the contrarary. But in my early days as a programmer when I followed the System programming course, the instructor give a nice statement:

"Programming in Macro compares to programming in any high-level language, as driving a Formula-1 car compared to a standard car. The principles are the same, but any mistake stetches much further. You should be aware of that and act accordingly."

Willem Grooters
OpenVMS Developer & System Manager
Antoniov.
Honored Contributor

Re: How to learn Macro

Hello Willem,
the example of F1 and standard car is very pretty; i like it and I agree!

@Antoniov
Antonio Maria Vigliotti
Willem Grooters
Honored Contributor

Re: How to learn Macro

Martin,
The book is:

Computer Programming and architecture: The VAX
Written by Henry M. Levy and Richard H. Eckhouse, jr.

I own the second edition, published by Digital Press in 1989, ISBN 1-55558-105-7

And, of course, there is the Big Black Book (as we used to call it): VAX/VMS internals and data structures, by Rith Goldenberg. No doubt you know the book (others will...)

Collector's items?

Willem
Willem Grooters
OpenVMS Developer & System Manager
Ian Miller.
Honored Contributor

Re: How to learn Macro

IDSM is vital for non-trival macro32 programming as acccessing the VMS exec data structures in kernal mode is often why program in macro32 (for me generally). Have a look around Hunter Goatly's fileserv for some fine examples in macro32
____________________
Purely Personal Opinion
John Gillings
Honored Contributor

Re: How to learn Macro

Martin,

For crash dump analysis, you really don't need to be able to write MACRO32. You really don't need to read it much either, as I doubt you'll be analysing many VAX crash dumps. About the most you'll need is to be able to read listings, which may be in MACRO32.

What's more important is an understanding of the concepts of assembly languages in general. Operators, registers, operands, base/offset addressing, all that kind of stuff.

If you really want to learn MACRO32, DON'T start with "hello world". You really don't want to be doing general I/O in assembly language. Instead, find yourself a small, simple, utility routine that you already use somewhere. Translate it from whatever language it's already written in into MACRO32. See if you can improve something (performance, compactness, whatever). Chances are you can't!

John Gillings
A crucible of informative mistakes
John Eerenberg
Valued Contributor

Re: How to learn Macro

Hello Martin,

I am a litte late in responding, but then again I was on vacation and purposely avoided using any computers. :-)

I wrote a program that queued up kernel mode AST's between processes (on VAX). It helped a lot when it came to just getting my feet wet on crash dumps (these crashes were very narrow is focus and the only ones I can comfortably analyze -- I'm told we will see much, much more at the upcoming class).

I wrote it in Macro-32 but I don't think the language matters as much as doing it. Macro-32, Macro-64, or C are good candidates as far I can tell. I think I'll try my hand at Macro-64 before going (we got it when we got out first Alpha).

What about jointly doing something like this offline? We have about 3-4 weeks. :-)

john
It is better to STQ then LDQ
Hein van den Heuvel
Honored Contributor

Re: How to learn Macro

For your entertainment mostly...

In the same general time window as this topic, an other thread on learning Macro was started in a whole other place:

http://www.encompasserve.org/DECUServe/DECnotes/VMS/3401.1/PREV_TOPIC.HTML

I point it out, not really because of the topic itself, but mostly because is yet an other place where VMS fans come together and exchange ideas.

fwiw,
Hein.


Martin P.J. Zinser
Honored Contributor

Re: How to learn Macro

Hello John,

I've got to warn you, I am a real beginner in Macro (and assembly like languages in general). Craig was friendly enough to borrow me his book (Big thanks!) and I am just reading it right now. After that I will try to write some very, very simple programs, so I am really not sure I am the right partner for you. If you still want to give it a shot sent me mail at zinser@zinser.no-ip.info .

Hein, I did read the thread you quoted. There is one important difference. The guy there knows what he is doing! Don't insult him by the comparison ;-)

And yes, I do enjoy reading the Macro book :-))

All the best, Martin
Antoniov.
Honored Contributor

Re: How to learn Macro

Hi Martin,
even I don't write using assembler since last 2-3 years, I started my working using this language and macro and I used them for plenty years.
If you will post any question, I 'll answer you as I can.

Regards
@Antoniov
P.S. If you prefer you can send me any e-mail to antoniov at shs-av.it
Antonio Maria Vigliotti
Thomas Ritter
Respected Contributor

Re: How to learn Macro

Martin, did you eventually find a worthwhile book which provides an introduction to Macro-32 ?
Wim Van den Wyngaert
Honored Contributor

Re: How to learn Macro

Craig A Berry
Honored Contributor

Re: How to learn Macro

I loaned him a copy of a MACRO book I have by Sara Baase, which he read and returned. Shortly thereafter Martin seems to have dropped off the Net and I haven't heard from him in quite a while. Has anyone else?
Martin Vorlaender
Honored Contributor

Re: How to learn Macro

Craig,

>>>
Martin seems to have dropped off the Net and I haven't heard from him in quite a while. Has anyone else?
<<<

My last email exchange with him dates from late November. The last time he translated a story for de.openvms.org was around Christmas. Nothing since then here.

cu,
Martin