View previous topic :: View next topic
|
Author |
Message |
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
here is my pg, i just want to create a table from input file
Code: |
000001 *********************************************************************
000002 * PROGRAM: CRETABLE. *
000003 * PURPOSE: DEMONSTATION ASSEMBLER PROGRAM *
000004 * DESIGN : ROGERQ *
000005 * DATE : AUGUST, 2008 *
000006 *********************************************************************
000007 CRETABLE CSECT
000008 * DEFINE REGISTER EQUALS USING IBM STANDARD MACRO YREGS *
000009 YREGS
000010 * BUILD UP BASE REGISTERS FOR THE PROGRAM *
000011 USING CRETABLE,R15 ;R15 IS CURRENT ADDRESS, USING IT
000012 SAVE (14,12) ;SAVE CALLER'S REGISTERS USING SAVE
000013 LR R12,R15 ;COPY THE CURRENT CSECT LOCATION
000014 DROP R15 ;DROP THE TEMPORARY USING
000015 USING CRETABLE,R12 ;USE R12 AS BASE REG FROM NOW ON
000016 * BUILD LINKAGE OF THIS PROGRAM AND THE CALLER.
000017 ST R13,SAVEAREA+4 ;SET OUR BACKWARD LINK IN OUR SAVE
000018 LA R15,SAVEAREA ;LOAD ADDR OF OUR SAVEAREA TO R15
000019 ST R15,8(R13) ;SET CALLER(MYSELF)'S FORWARD LINK
000020 LR R13,R15 ;LOAD OUR SAVEAREA ADDR TO R13.
000021 * MAIN PROGRAM BEGINS HERE
000022 * INITIALIZE POINTER OF THE TABLE
000024 LA R3,TABLE ;SET POINTER TO BEGINING
000025 * READ THE 1ST RECORD
000026 OPEN (FILEIN,INPUT,SYSPRINT,OUTPUT)
000027 LOOP GET FILEIN,CARD
000028 PUT SYSPRINT,CARD
000029 L R2,CARD
000033 * ADD VALID VALUE TO THE TABLE
000034 ST R2,0(R3) ;PUT INTO TABLE FROM R3 ADDRESS
000036 LA R3,4(R3) ;DIRECT COUNTER TO NEXT RECORD
000037 * READ NEXT RECORD
000038 B LOOP
000039 * PRINT THE WHOLE TABLE
000041 ENDINPUT PUT SYSPRINT,TABLE ;WRITE THE TABLE
000044 CLOSE SYSPRINT ;CLOSE SYSPRINT FILE
000045 CLOSE FILEIN ;CLOSE SYSPRINT FILE
000046 * LTORG
000047 * RETURN LINKAGE TO THE CALLER
000048 L R13,4(R13) ;LOAD ADDR OF CALLER'S SAVEAREA
000049 RETURN (14,12),RC=0 ;RESTORE CALLER'S REGS AND RETURN
000051 * STATIC STORAGE AREA
000052 SAVEAREA DS 18F ;REGISTER SAVE AREA
000053 CARD DS CL80
000054 TABLE DS 50CL8
000056 SYSPRINT DCB DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,RECFM=FB,LRECL=80
000057 FILEIN DCB DSORG=PS,MACRF=GM,DDNAME=FILEIN,RECFM=FB,LRECL=80, X
000058 BLKSIZE=3600,EODAD=ENDINPUT
000059 END CRETABLE
|
here is my input file
Code: |
000001 11112222
000002 22223333
000003 99998888 |
but i get the sysprint as below:
Code: |
11112222
22223333
99998888
111122229999
|
the table content become 111122229999
what i expected is 111122222222333399998888
i cant find where the data is truncated
could you guys give me some ideas ?
thanks very much! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
000036 LA R3,4(R3) ;DIRECT COUNTER TO NEXT RECORD |
Are the table entries 4 bytes long or 8 bytes long? |
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
the table is 8 bytes long
i also tried this
whatever i define the table, i get the same results |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Your problem is not the table definition.
Please review the post from Robert. You increment the address by 4. . . |
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
thanks, Dick and Robert
i tried again, using this
Code: |
000036 LA R3,8(R3) ;DIRECT COUNTER TO NEXT RECORD |
but, i get the value
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You are also only storing 4 bytes into the table. . .
Code: |
L R2,CARD
000033 * ADD VALID VALUE TO THE TABLE
000034 ST R2,0(R3) ;PUT INTO TABLE FROM R3 ADDRESS
|
You are using register instructons and i believe you'll do better with a storage instruction (MVC). |
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
thanks, Dick
i got it, u means, it will meet the 4 bytes limit if i use register instructions
and it will be better useing MVC
but, if i use MVC, i can only move between lables, and, i cant put the value to register, so, how can i realize the pointer moving, you know, now i use R3 to move pointer,
Code: |
LA R3,4(R3) ;DIRECT COUNTER TO NEXT RECORD |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
but, if i use MVC, i can only move between lables |
Well, not quite.
You may specify the sending field, the receiving field, or both by label or by register&displacement.
Which assembler reference material are you using? |
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
thanks for your tips
i just using a simple chinese version assembler book, maybe it's not suitable, i will try to get a better one from our forums |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
000029 L R2,CARD
000033 * ADD VALID VALUE TO THE TABLE
000034 MVC 0(8,R3),CARD ;PUT INTO TABLE FROM R3 ADDRESS
000036 LA R3,8(R3) ;DIRECT COUNTER TO NEXT RECORD |
would fix your problem. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There is a book from Murach Publishing written by Kevin McQuillen that is very good for people just starting in assembler. It begins from knowing nothing of assembler syntax and the instructions. Once you complete that book, the ibm reference manuals have more detail. So far, it is the best mainframe assembler for beginners i've worked with. For a time it was used in several universities as their text for assembler studies.
The ibm manuals are excellent for resolviing a question, but i do not believe them to be a good way to learn from scratch.
Near the top of the PL/I & Assembler part of the forum is a "Sticky" with considerable information:
ibmmainframes.com/viewtopic.php?t=2744
Good luck |
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
hi, i just found the book name in the link, but cant find where to download it , could you pls tell me where i can read that book ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
RogerQ
New User
Joined: 20 Aug 2008 Posts: 10 Location: China
|
|
|
|
Dick , thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
d |
|
Back to top |
|
|
|