Trouble with assembler subroutines



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

Re: Trouble with assembler subroutines

Postby RISCCISCInstSet » Tue Nov 22, 2011 5:09 pm

Anyway, do you have any further hints as to how I have my program invoke a subroutine without crashing?
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Trouble with assembler subroutines

Postby steve-myers » Tue Nov 22, 2011 5:50 pm

Sorry, no. This is something you'll have to learn yourself!

These users thanked the author steve-myers for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Trouble with assembler subroutines

Postby Robert Sample » Tue Nov 22, 2011 5:58 pm

What I need to understand is: how shall I start up a simple internal subroutine such that I can call it? To call the subroutine, I invoke BAL
R14,subroutine - with subroutine being a selected name. To return from a subroutine, I code BR R14.
This says you understand the basics. If you have trouble after using BAL and BR, then the issue is not with invocation of the subroutine but somewhere else.

And asking how to get something to run "without crashing" is totally useless -- either you are running the code and getting a specific abend code (in which case you should post the code at a minimum), or you are not running the code and just guessing about crashing.

These users thanked the author Robert Sample for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
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

Re: Trouble with assembler subroutines

Postby enrico-sorichetti » Tue Nov 22, 2011 6:00 pm

did You care to look at the link I provided You with ? looks like not!
quite a bit of info there and additional links.
anyway the quirks of CALLing <subroutines> are clearly explained here
http://publibz.boulder.ibm.com/cgi-bin/ ... 0522045539
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

These users thanked the author enrico-sorichetti for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Trouble with assembler subroutines

Postby dick scherrer » Wed Nov 23, 2011 2:13 am

Hello,

do you have any further hints as to how I have my program invoke a subroutine without crashing?
Possibly - if you will invest a bit of time to show us what is wrong.

Posting "it didn't work" is probably the worst that can be posted when looking for help. We knew it didn't. So, post some specifics.

My guess is that you have done something incorrectly with register usage or have "walked on" some of memory (instructions).
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
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: Trouble with assembler subroutines

Postby RISCCISCInstSet » Wed Nov 23, 2011 6:02 am

There's something interesting. How do you walk on memory?
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Trouble with assembler subroutines

Postby RISCCISCInstSet » Wed Nov 23, 2011 6:03 am

My stupid gibberish:
LAB6A    SUBENTRY
LAB6A    CSECT
       
         BALR    12,0
         USING   *,12
         SAVE    (14,12)
         BALR    12,0
         USING   *,12 
         LA      2,SAVEAREA 
         ST      2,8(,13)
         ST      13,4(,2)
         LR      13,2
         LA      1,DATA
         
         LM 14,12,12(13)
         OI 15(13),X'01'
         LA      15,0(0,0)
         
         
         
         BAL    15,SUMRTN
         BAL    15,SUMRTN
         BAL    15,SUMRTN
         LA     3,X'00000000'
         LA     4,X'00000001'
         LA     5,X'00000063'
         ZAP   B,=P'0'
         ZAP   SUM,=P'0'
         ZAP   A,=P'1'

LOOP     DS    0H
         AP    B,A
         AP    SUM,B
 
         BXLE  3,4,LOOP
         
         MVC  FIELD,MASK
         ED   FIELD,SUM
         WTO  MF=(E,WTOMSG)
         SUBEXIT

WTOMSG   DC AL2(WTOMEND-*,0)
HELLO    DC  C'THE SUM OF THE NUMBERS FROM 1 TO 100 IS '
FIELD    DS CL10
WTOMEND  EQU *

*
MASK     DC X'40206B2020206B202020'
PRNTLINE DS CL133
SUM      DS PL4
B        DS PL4
A        DS PL4
C        DS PL4
CB       DS PL4
DB       DS PL4
SAVEAREA DS 18F
DATA     DC CL5'00800'
SUMRTN   DS      0H
         WTO 'NONSENSE'
         BR      15

ENDPGM   DS  D

    END  LAB6A
RISCCISCInstSet
User avatar
RISCCISCInstSet
 
Posts: 121
Joined: Mon Oct 17, 2011 1:46 pm
Has thanked: 146 times
Been thanked: 0 time

Re: Trouble with assembler subroutines

Postby Robert Sample » Wed Nov 23, 2011 7:10 am

I can certainly see why your program is crashing. Everything up to the LA 1,DATA is okay -- bizarre from the repeated code, but not causing a crash. The LM 14,12,12(13) destroys everything else you'd done up to that point -- it restores register 1 to the value it had when the operating system turned control over to your program, wipes out register 12 (which is being used as your base register). This makes the rest of your program hazardous since the base displacements are no longer valid since they're using register 12 that just got restored to the original value, not the value the BALR 12,0 put in it.

And since you are so careful to use WTO M=(E,WTOMSG) the first time with a length and all that, why use WTO 'NONSENSE' in the subroutine?

These users thanked the author Robert Sample for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
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

Re: Trouble with assembler subroutines

Postby steve-myers » Wed Nov 23, 2011 7:18 am

RISCCISCInstSet wrote:There's something interesting. How do you walk on memory?
"Walking on memory" is a phrase to indicate something is altering your program, almost always that "something" is your program.

These users thanked the author steve-myers for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Trouble with assembler subroutines

Postby steve-myers » Wed Nov 23, 2011 9:07 am

There are a lot of problems in your code; many more than Mr. Sample indicated. You'll learn more if you figure them out yourself.

These users thanked the author steve-myers for the post:
RISCCISCInstSet (Mon Nov 12, 2012 4:50 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

PreviousNext

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post