Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
The assembler instructions in the posted code are among the most basic in the language. If these are not yet familiar to you, i'd suggest you do a bit more research.
The first link shows a list of most assembler instructions. The second is to an IBM Introduction for Assembler.
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
rammraju wrote:
It would be helpful if i can get to know what is happening in each step.
What's 'a matter Dick, couldn't you just try to answer the question?
Code:
EXAMPLE1 START
STM 14,12,12(13)
LR 3,15
USING EXAMPLE1,3
set up a base reg
L 4,0(1)
get the first parm
L 5,4(1)
get the second parm
MVC 0(8,5),=C'11111111'
Move X'FF' to the second parm
LBL1 TM 0(4),C'AB'
Eww, that's one I gotta look up....Testing the first byte of a passed parm with what should be an immeadiate, but is actually an addtess of X'C1C2' off of zero.....Or do I have it backward....grin....
Beyond this, I'm needing my POP and green card.....
BO LBL2
MVI 0(5),C' '
LBL2 TM 0(4),C'CD'
BO LBL3
MVI 1(5),C' '
LBL3 LM 14,12,12(13)
BR 14
LTORG
CSECT
DC CL24'@@@001EXAMPLE2 11/11/11'
END EXAMPLE1
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
Quote:
MVC 0(8,5),=C'11111111'
Move X'FF' to the second parm
LBL1 TM 0(4),C'AB'
Eww, that's one I gotta look up....Testing the first byte of a passed parm with what should be an immeadiate, but is actually an addtess of X'C1C2' off of zero.....Or do I have it backward....grin....
Beyond this, I'm needing my POP and green card.....
BO LBL2
Not moving X'FF' to second parm - overwriting the first 8 bytes of the parm with char '1'.
The TM is a single byte instruction to check an immediate mask, so only tests for bits b'11000001' (first byte of immediate C'AB') - any value with these bits 'on' will result in branch to LBL2.
ApexNC, I don’t see a pdf in the link posted by you.
However why are we discussing 12 years old post now ? If you would like to share any manuals related stuff then it’s best to share to any of the moderator so that it can be marked with sticky key.
E.g ibmmainframes.com/viewtopic.php?t=2744
doesn't make any sense, at all. The second operand must represent any value from the range 0-255 (that fits to one byte); The value C'AB' is a different entity.
Correct syntax might be
Code:
TM 0(4),X'AB'
but the subsequent logic remains unclear.
I also expect Assembly error at compilation, but I'm lazy to verify this senseless example.
After this point no need to further analyze this "example".
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
There are a couple of Assembler errors in this "example."
Code:
000014 0000 0000 00000 8 LBL1 TM 0(4),C'AB'
ASMA031E Invalid immediate or mask field
ASMA435I Record 8 in XXXXXX.X1.ASM on volume: XXXXXX
000020 0000 0000 00000 11 LBL2 TM 0(4),C'CD'
ASMA031E Invalid immediate or mask field
ASMA435I Record 11 in XXXXXX.X1.ASM on volume: XXXXXX
Assembler Done 2 Statements Flagged / 8 was Highest Severity Code
An instruction like TM can specify one byte of data within the instruction. Perhaps, instead of C'AB', X'AB' was intended. Other "immediate" instructions can have two or even four bytes of data embedded in the instruction.
START, CSECT, USING, LTORG, END - System/360 Assembler programs - the programs that analyze user assembler programs to build the binary code the machines eventually execute - have a number of "Assembler instructions" that direct the Assembler to do something rather than emit binary code. START, CSECT, USING, LTORG and END are all Assembler instructions. These "instructions" are sometimes called pseudo ops.
START and CSECT are similar, though the difference between them is very subtle. Both instructions define a CSECT, or "control section." A CSECT is just a block of data, which can be a program, or data, that must be kept together. One "assembly," the data from one run of the Assembler program, can have several CSECTs in the assembly. The Binder - in z/OS the program that takes the binary data produced by the Assembler to produce a loadable, executable program - combines the CSECTs. The CSECT without a label defines a CSECT with no name. Sadly, this is perfectly legal; in fact, a load module can have several unnamed CSECTS.
USING - Many instructions have to access storage. Rather than specify a storage address directly in an instruction, A storage address is specified in an instruction as a base register and an value that is added to the contents the vase register. A programmer can specify these values directly -- 12(13), where the base register is register 13, and 12 is the value added to the base register. It's often more convenient to specify a symbolic label, for example LBL3 in "BO LBL3" and request the Assembler program to calculate the base register and offset.
Code:
Loc Object Code Addr1 Addr2 Stmt Source Statement
000024 4710 302C 0002C 12 BO LBL3
The address in the machine instruction is 302C; the base register is register 3 and the offset is 02C. As a convenience to the programmer, the Assembler computes the relative location of the address and stores it in the Addr1 and Addr2 columns.
LTORG - As a convenience to the programmer, the Assembler provides the programmer a way to specify fixed data as an inline literal in the form (for example) =C'11111111' The Assembler will normally store these literals some place.
The default location may not be acceptable, so the LTORG Assembler instruction can be used to select the location of the literal pool. Large programs often have several literal pools.
END - As Homer Simpson often says, "Duh!" This one is pretty obvious. You can specify an address on the END statement. This address can be conveyed to the Binder as the location where the program will start executing. Hint: specify an address that is also an external symbol.
An external symbol is the label in a CSECT or START statement. There are other ways to create an external symbol which will not be discussed in this post.What actually happens when the program executes can not be determined since there are known Assembler errors.
Our late colleague Dick Scherrer commented more than 11 years ago that the computer instructions in this "example" are very basic. People like CICS guy should do more research. If they still do not understand something they should post the piece they do not understand and someone should be able to help them.
EXAMPLE1 START , create Control Section named EXAMPLE1
STM 14,12,12(13) save registers on input
LR 3,15 copy entry point address
USING EXAMPLE1,3 let use R3 as program base reg
L 4,0(1) get address of output STRING
L 5,4(1) get address of input FLAGS
MVC 0(8,5),=C'11111111' initialize STRING with '11111111'
LBL1 TM 0(4),C'AB' error! trying to check something in FLAGS; must be (5)
BO LBL2 if checked condition OK, bypass to LBL2
MVI 0(5),C' ' if check failed, replace FLAGS(?) with B'01000000'
LBL2 TM 0(4),C'CD' error! trying to check something in FLAGS; must be (5)
BO LBL3 if checked condition OK, bypass to LBL3
MVI 1(5),C' ' if check failed, then FULL MESS!!
LBL3 LM 14,12,12(13) restore registers to initial state
BR 14 return to caller
LTORG , define place for literals (=C'11111111')
CSECT , define unnamed Control Section (for nothing!)
DC CL24'@@@001EXAMPLE2 11/11/11' place eye catcher to read the dump if needed
END EXAMPLE1 end of code; set entry point to EXAMPLE1
Two lines marked with error! demonstrated for sure that the code developer had not a minor idea about Assembler basics in his mind; he just copied-and-pasted unknown code from unknown place, adding some typos. If so, what is the need to analyze, and to explain this senseless and useless code? It even cannot be compiled!