Assembler! No, it’s not a language that Ikea has come up with. Assembly, asm, scary numbers language thingy or assembler, it has many names. This is there part where I tell you I haven’t written any asm but state that I’ve written some language that looks like it. Ehh… not this time.
This challenge is about… surprise surprise! Assembler!
IBM Z Mainframe Assembler
IBM Master the Mainframe Part Three – Challenge #13
This challenge sure won’t make me a full fledged Assembler programmer but I’ll at least have some experience with asm. Asm is more difficult to learn than other languages. It requires you to learn Assembler mnemonics, machine instructions, Assembler directives, Assembler macros and you need to know a thing or two about hardware architecture.
Being able to understand Assembler gives one the ability to debug complex system problems by reading system dumps. Higher level languages such as C/C++, Java, Cobol etc. were created to make programming the computer easier by hiding the complexity of the underlying machine instructions, addressable memory and registers.
Compile assembler program
Use TSO TEST facility to understand assembler program execution
Note, I will have to enter go numerous times to proceed with the program execution. It should stop at +42.
Well that sure was something! I did this process twice, help! Once for myself and the second time to get some screenshots. I can’t embarrass myself right?!
Modify and re-compile ASMPGM assembler program
- Use register 6 for all operations where register 2 was previously used
- Use register 7 for all operations where register 3 was previously used
- Initialize the register used to sum each add operation in the loop with a zero value
- Execute the loop 10 times adding 5 to the register being used to sum each add operation
Help! Can I pay someone to do this for me?
As for the registers 6 and 7, just change all occurrences where register 2 or 3 is used. In IBM’s explanation they state which register is being used at what line inside the code. So it’s a matter of understanding the code or just ctrl+f ‘register 2’ at mybluemix 😉
Initialise the register used to sum each add operation in the loop with a zero value is easy. Think how the two registeres are initialised now, they hold the value Begin. Then a bit further register 6 and 7 are ‘loaded‘ with value 4 and 1. I’ve only edited the one register where we add something. I didn’t touch the other register where we subtract from.
We can find the storage address of label LOOP at +3A, when we’ve entered go it adds 1 to register 3 until register 2 is zero as it subtracts one every loop. So in the end register 3 was 5 and register 2 held the value zero. How many times did we need to enter go in order to get register 2 to 0?
Think fast! IBM now wants us to execute the loop 10 times and add 5 every iteration to the register where we add a number.
I think I’ve got it right, now is a good time to debug again and tso submit ‘zos.public.jcl(p3ch13)’ to copy my code to P3.OUTPUT. Let’s debug first! Don’t make the same mistake I did, we’re debugging new registers now 🙂 not register 2 or 3. But 6 or 7.
Looks like it iterated 10 times all the way down to where register 6 equals zero and register 7 equals 0x32 (hex).
Should be it!
Good article, thanks for sharing, please visit
our website
Hi Kevin!
After how many days of completing part 3,do we get the badge?
Hi Anonymous,
Should be within a week if they had time to score your solutions. The transition to the 2019 edition might be a problem though. You should try and contact Mr. Paul Newton or Mr. Troy Crutcher on Slack.
Kind regards,
– Kevin
Or if you can tell me,when at what point we have to stop the iteration?
When we will get 0x32 in 7R,we will stop?
Hi Kevin!
L 6,=C’begin’
LA 6,=C’begin’
LOOPINIT DS 0H
SR 6,6
L 6,=F’10’
L 7,=F’0′
LOOP DS 0H
A 7,=F’5′
BCT 6,LOOP
LH 7,HALFCON
A 7,FULLCON
ST 7,HEXCON
EXIT DS 0H
I did this.
I am getting more than 10 iterations.
Can you help me to correct?
Thank you.
Or if you can tell me,when at what point we have to stop the iteration?
When we will get 0x32 in 7R,we will stop?
Hi Anonymous
Your comment hasn’t gone unnoticed, I’m at work now and I’ll try and get back to you in 8 hours if it’s still needed.
Kind regards,
– Kevin
Sure.
Waiting.
Hi Anonymous
I have the same variables, https://kevindurant.be/wp-content/uploads/2019/08/p3c13-20.png, did you change the debug register commands to 6 or 7? ‘at +3A (l 2r:3r)‘ becomes ‘at +3A (l 6r:7r)‘.
I believe you need to start the loop when debugging and enter Go until it stops.
Kind regards,
– Kevin
I’ ll have to execute the GO command until and unless i get the same output as yours, right?
And yes,i changed that.
Hi Anonymous
Yes that is correct, execute the GO command until you get 000032.
Kind regards,
– Kevin
Hi Kevin!
I am not being able to understand where exactly do i have to make the changes except that i have to change register 2 to 6 and 3 to 7.
(Correct me if i am wrong)
Basically i am confused where and how to initialize.
I have read the first message, almost a same doubt..But i am still confused.
I have try this code, little bit dificult if we dont understand it detaily
Please dont be sorry, I totally understand and dont want to put you in a spot either. Anyway, I got it already, very much thanks to your help!! Onward to ch15!!
Cheers! 🙂
Hi Ronald, I’m happy to hear you have figured it out 🙂 Good luck with chapter 15! I hope to see you on the hall of fame 🙂
– Kevin
Wow this looked pretty difficult I don;t know how you could do this without any help. That’s pretty impressive
Hi Walter, it was difficult indeed! Thanks for the kind words 🙂
– Kevin
how did you know the answer you got was correct? Im struggling
Welcome back Walter, 0x32 or 000032 shown on the screen is in Hexadecimal format. 0x32 to the decimal format equals to 50. We add 5 to the needed register and we loop 10 times, so eventually 10 times 5 equals 50.
more hints for Initialise the register used to sum each add operation in the loop with a zero value please!!! I am not able to load values into record 6, it keeps showing 6r fffffffffff.
many thanks in advance!
Hi Ronald, is it possible to paste some of your code? You should only change some things, not insert lines. I’ll make a small checklist for you.
1. Determine which register we use to add a number. Is it register 6 or 7?
2. This register is already initialised, just change the initialised value to 0.
3. Be sure to change the debug register commands to 6 or 7. ‘at +3A (l 2r:3r)‘ becomes ‘at +3A (l 6r:7r)‘.
Re-read this part 🙂
* program body
*—————————
L 6,=C’Begin’
LA 6,=C’Begin’
LOOPINIT DS 0H
SR 6,6 <—- subtract register 6 from itself
L 6,=F'50' <– load '50' for subtraction of 5 /loop for 10 loops
L 7,=F'1' <–load '1' as starting value
*—————————
LOOP DS 0H
A 7,=F'5' <– addition of 5 every loop
BCT 6,LOOP <— decrement register 6 by 5
*—————————
STOP1 LH 7,HALFCON
STOP2 A 7,FULLCON
STOP3 ST 7,HEXCON
I made changes to the program body section only. I am using register 7 for addition(if that's the right thing to do haha).
I see that Stmt 34 is where register 6 will be loaded with 'Begin', but which line shows register 7 being loaded with 'Begin'?
When you mention the register is already initialize, is the step performing initialization the step below?
stmt 37 SR 2,2
Does this in turn mean that i am heading in the right direction by using register 6 for addition?
Thanks for your response Kevin and your kind help!!
at +2c (l 6r)
TEST
go
AT +2C
6R FFFFFFFF
TEST
at +2c (l 6r)
TEST
go
AT +2C
6R FFFFFFFF
TEST
at +30 (l 6r;l 11f8. length(5) c)
TEST
go
AT +30
6R FFFFFFFF
INVALID ADDRESS 11F8. +
REENTER THIS OPERAND –
not sure if i am entering the debugging line accurately either, so here are some lines!
L 6,=F’50’ < – load '50' for subtraction of 5 /loop for 10 loops L 7,=F'1' <–load '1' as starting value Why do you load 50 as a starting value? We just need to loop 10 times. We don't subtract 5 from register 6 anywhere in the code. The code only adds 5 to register 7 in the code and thats it. See this part in my blog: