Mainframe Assembler Macro



High Level Assembler(HLASM) for MVS & VM & VSE

Mainframe Assembler Macro

Postby deathwish73 » Fri Nov 18, 2011 2:25 am

Hi,
I needed help in defining a macro called SWITCH that will interchange the contents of 2 fullwords in storage.

This is Mainframe Assembler IBM PC 370.

Thanks
deathwish73
 
Posts: 17
Joined: Fri Nov 18, 2011 2:20 am
Has thanked: 0 time
Been thanked: 0 time

Re: Mainframe Assembler Macro

Postby enrico-sorichetti » Fri Nov 18, 2011 2:47 am

and what has this to do with DFSORT/ICETOOL

using the basic good manners of posting in the proper forum will make helping You a pleasure rather than a pain in the ...

anyway Your request is not really a help request, rather a request for a complete solutions

edited quickly to add ...
what knowledge do You have about writing macros
what is You knowledge if logic operators
what is Your knowledge of register operations

there are three ways of doing it
1) 3 exclusive OR
2) 3 moves using an intermediate work variable
3) 1 load 1 move 1 store ( using a register instead of the work variable )

option 3 works on up to 64 bits operands , for longer operands only options 1 and 2 are available
Last edited by enrico-sorichetti on Fri Nov 18, 2011 2:53 am, edited 1 time in total.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Mainframe Assembler Macro

Postby dick scherrer » Fri Nov 18, 2011 2:48 am

Hello and welcome to the forum,

How much experience using or creating macros do you have? If this is your first attempt, suggest you read about Macros for the assembler you are using before building one. Your topic has been moved to the Assembler part of the forum.

You might also look here:
http://www.les-smith.com/software/assembler/macros.htm

Simply said, you would define a work area and then move from the first fullword to the work area. Move the second fullword to the first fullword. Then move the work area to the second fullword. Expanded just a bit, you can switch data that is longer than a fullword.

I suspect SWITCH will work - we used SWAP (unconditional) once upon a time :) We also supported CSWAPHI and CSWAPLO (swap when a > b and when a < b. Actually, these were not macros, but instructions we incorporated into the application development language specification.

Good luck :)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Mainframe Assembler Macro

Postby steve-myers » Fri Nov 18, 2011 6:20 am

We do not do homework.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Mainframe Assembler Macro

Postby dick scherrer » Fri Nov 18, 2011 10:43 am

Hello,

Yup, we won't actually do the homework - but we will help when you get stuck or have problems.

To get this help, one needs to post what they have tried and what went wrong or where they are stuck.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Mainframe Assembler Macro

Postby deathwish73 » Sat Nov 26, 2011 6:47 am

The following below is not a homework assignment but just a book exercise for practice.

Can someone explain how to print out the prime numbers from 1 to 500 on the DOS Screen?

I can do this comfortably using C# as below, but need help in doing this using MAINFRAME ASSEMBLY.


using System;

class Program
{
static void Main()
{
//
// Write prime numbers between 0 and 100.
//
Console.WriteLine("--- Primes between 0 and 100 ---");
for (int i = 0; i < 100; i++)
{
bool prime = PrimeTool.IsPrime(i);
if (prime)
{
Console.Write("Prime: ");
Console.WriteLine(i);
}
}
//
// Write prime numbers between 10000 and 10100
//
Console.WriteLine("--- Primes between 10000 and 10100 ---");
for (int i = 10000; i < 10100; i++)
{
if (PrimeTool.IsPrime(i))
{
Console.Write("Prime: ");
Console.WriteLine(i);
}
}
}
}

Class that contains IsPrime [PrimeTool.cs, C#]

using System;

public static class PrimeTool
{
public static bool IsPrime(int candidate)
{
// Test whether the parameter is a prime number.
if ((candidate & 1) == 0)
{
if (candidate == 2)
{
return true;
}
else
{
return false;
}
}
// Note:
// ... This version was changed to test the square.
// ... Original version tested against the square root.
// ... Also we exclude 1 at the very end.
for (int i = 3; (i * i) <= candidate; i += 2)
{
if ((candidate % i) == 0)
{
return false;
}
}
return candidate != 1;
}
}
deathwish73
 
Posts: 17
Joined: Fri Nov 18, 2011 2:20 am
Has thanked: 0 time
Been thanked: 0 time

Re: Mainframe Assembler Macro

Postby deathwish73 » Sat Nov 26, 2011 6:49 am

About the Macro

Can you please explain how to:

there are three ways of doing it
1) 3 exclusive OR
2) 3 moves using an intermediate work variable
3) 1 load 1 move 1 store ( using a register instead of the work variable )

Illustrate the move Macro with one of the following techniques?
deathwish73
 
Posts: 17
Joined: Fri Nov 18, 2011 2:20 am
Has thanked: 0 time
Been thanked: 0 time

Re: Mainframe Assembler Macro

Postby steve-myers » Sat Nov 26, 2011 7:30 am

deathwish73 wrote:The following below is not a homework assignment but just a book exercise for practice. ...
Most of us would regard this as homework.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Mainframe Assembler Macro

Postby deathwish73 » Sat Nov 26, 2011 8:08 am

It's not homework, I swear. And I would greatly appreciate your help on this, PLEASE
deathwish73
 
Posts: 17
Joined: Fri Nov 18, 2011 2:20 am
Has thanked: 0 time
Been thanked: 0 time

Re: Mainframe Assembler Macro

Postby Robert Sample » Sat Nov 26, 2011 8:31 am

there are three ways of doing it
1) 3 exclusive OR
2) 3 moves using an intermediate work variable
3) 1 load 1 move 1 store ( using a register instead of the work variable )
1. Google is your friend. Googling swap memory xor find 1,770,000 hits and the very first one explains it clearly.
2. You cannot figure out how to use a temporary variable to hold one of the values, move the other to that variable, then move the temporary variable to the second variable? Are you sure you should be in IT at all if such simple logic escapes you?
3. Hint: fullwords in memory are, conveniently, the same size as registers. Knowing that and finding a solution to #2 will allow you to easily find this method as well.

Doing the prime problem in Assembler is tedious but not difficult. Assembler requires a lot of other code around the actual algorithm for control mechanisms. How long it would take depends upon your level of expertise with Assembler -- based upon what you've posted so far, count on weeks or months of effort to write and debug the code.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post