Display actual memory data in mainframe assembler/hlasm

Source: Internet
Author: User

 

This article focuses on how to display the actual data in the memory. First, let's take a look at how the Assembly is implemented. The next step is to implement it using Cobol.

000000 00000 00100 1 main csect
R: C 00000 2 using *, 12
000000 90ec d00c rjc 3 STM, 12 (13)
000004 0dc0 4 BaSr
000006 50d0 c02c 0002c 5 st 13, save + 4
00000a 41d0 c028 00028 6 la 13, save
0000e 7 start equ *
00000e f384 c075 c070 00075 00070 8 unpk output (9), input (5)
000014 dc07 c075 c000 00075 00000 9 tr output, hextab
0001a 10 Exit equ *
20171a 58d0 c02c 0002c 11 L 13, save + 4
20171e 98ec d00c rjc 12 lm 14,12, 12 (13)
000022 41f0 0000 00000 13 La 15, 0
000026 07fe 14 BR 14
000028 15 save DS 18f
000070 a0b1c2d312 16 input DC x 'a0b1c2d3 ', x' 12'
000075 4040404040404040 17 output DC cl8'', C''
20177e 0007e 000f0 18 org main + C '0'
Limit F0 000f0 000f0 19 org,
00000 20 hextab equ *-C '0'
2017f0 f0f1f2f3f4f5f6f7 21 dc c '0123456789abcdef'
000000 22 end main

 

The above code turns the data in the hex memory into the data that can be displayed. For example, if you input 'a0b1c2d3 ', the output data is the displayed a0b1c2d3 data.

Here we need to clarify the following points:

1. The only difference between output DC cl8'', c'' and output DC cl9'' is that the former output length is 8 and the latter is 9.

Similarly, the difference between input DC x 'a0b1c2d3 ', X '12', and input DC x 'a0b1c2d312' is that the former is 4 and the latter is 5, this is why (9) needs to be specified in the unpk command.

In fact, in this program, the real input data is stored in the first four bytes of input. The last one does not matter, and the real output is also stored in the first eight bytes of output.

 

2. A location counter exists in the computer to identify the address of each instruction or field, while base register. For example, R12 of this program can only identify a small part of location connter. They are not the same thing.

In this program, using *, 12 is written in the first line. If you write a few lines down, you will find that their data is different, location counter must start from the first line of the program, and base register can theoretically be placed anywhere in the program.


000014 dc07 c075 c000 00075 00000 9 tr output, hextab

In this sentence, we found that the address of hextab was resolved to c000 by the computer. Isn't that the starting address of the program? Is hextab at the start address of the program? No, because it has no address, it uses equ, which can be seen from listing, but it represents the starting address of the program.

00000 20 hextab equ *-C '0'
2017f0 f0f1f2f3f4f5f6f7 21 dc c '0123456789abcdef'

They are two isolated rows. They do not have any relationship with the computer. If the first row is hextab equ *, this only indicates that the address indicated by hextab is the address of the next row, in this case, hextab indicates that the current address is pushed forward to 240 bytes, that is, the address pointing to the beginning of the program.

 

3. How does the tr command convert data?

Through the unpk command, the output is changed to X 'faf0fbf1fcf2fdf3 'and X '21'. Taking the first byte as an example, TR should find the data at hextab + x 'fa, to replace it, so it is

*-C '0' + x' fa '= Current address-x 'f0' + x' fa '= Current address + x '0a'. The corresponding table contains the character.

Someone may ask how to convert x '21? In fact, you don't have to worry about it, because the output length is 8. After TR is converted eight times, it stops, and it does not process the data '21 '.

In fact, in the end, the input and output define that byte in the end, which is purely the need of commands. As for writing, it is not important, but because of it, the program is indeed beautiful.

4.

20177e 0007e 000f0 18 org main + C '0'
Limit F0 000f0 000f0 19 org,

The two lines of code are completely for the purpose of hextab equ *-C '0', and the program is very short. In case the current address represented by * is not '0' large, isn't it an error !?

The first line above is to force the location counter to be changed to 000f0 (and the previously set maximum is 0007e ), the next line is to set location counter to the maximum value we encountered previously, so that the two rows can ensure that the minimum location counter is 000f0.

Another point is that hextab equ *-C '0'. The value * here is based on base register (for example, we say * represents the current address, but how does the current address program represent it? Base register R12 + offset, which is also expressed by CXXX in the Program). In this program, the location
The counter value is equal to the base register offset, that is, the * value is equal to the location counter value.

You can move the base register statement back and compile it again. *-C '0' is a negative value.

 

5.
R: C 00000 2 using *, 12

The first line of this program is as shown above. It means that during compilation, the value stored in R12 is the value of location counter 0000. If this line is placed in the fourth line, it will become

R: C 00006 2 using *, 12

It means that the value of R12 is 0006, that is, the base address register starts from where the location counter is 0006, that is, the representation of each subsequent instruction or field, the offset calculated from R12 is 6 smaller than the location counter of R12. When it is loaded, the data in R12 will be 0006 larger than the entry address.

 

I used the following code (that is, moved using back) to test it myself:

000000 00000 00100 1 main csect
000000 90ec d00c rjc 2 STM, 12 (13)
000004 0dc0 3 BaSr
R: C 00006 4 using *, 12
000006 50d0 c026 0002c 5 st 13, save + 4

Result:


0-3 fd000008 running 6ff8 00000040 008d29d4
4-7 008d29b0 008ea920 008c4fe0 fd000000
8-11 008eae40 008ea350 00000000 008ea920
12-15 1167f06 1167f28 80fccae0 20177f00

 

Is base register 0006 less than EAP?

 

**************************************** **************************************** *******************************

The same functions can be implemented using COBOL:

Identification Division.
Program-id. Hello.
Environment Division.
Data Division.
Working-storage section.
01 aaa pic 9 (7) COMP-3.
01 BBB redefines AAA.
05 bbb1 pic x (3 ).
05 bbb2 PIC x (1 ).
01 ccc pic 9 (7 ).
01 DDD redefines CCC.
05 ddd1 pic x (6 ).
05 ddd2 pic x.
Procedure division.
Move x '1a3e5b 'to bbb1.
Move AAA to CCC.
Inspect ddd1 replacing all x 'fa' by 'A ',
All X 'fb 'By' B ', all x 'fc' By 'C', all x 'fd 'by 'D'
All X 'fe 'By 'E', all x 'ff' by 'F'
Stop run.

If you have any objection, please contact dy1818dy@126.com

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.