How do you specify the item size when adding?

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Seymour J Metz
Sent: Thursday, February 08, 2018 11:12 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Silly C problem adding hex 6C

Isn't pointer arithmetic in C scaled by the item size?


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@listserv.ua.edu> on behalf of 
Barkow, Eileen <ebar...@doitt.nyc.gov>
Sent: Thursday, February 8, 2018 11:06 AM
To: IBM-MAIN@listserv.ua.edu
Subject: Silly C problem adding  hex 6C

I am still trying to crawl my way around C/C++ and am just trying to do one 
simple thing:
add value 0X6C to a pointer address (which was originally supplied by this list 
as a means to get the jobname).
 something gets added to the pointer but it is not 0x6c.
i tried all different combinations of char *; int *; void *; adding decimal 
108; but still get the same thing.

My little program correctly picks up the address of a valid ASCB (00FCAA00) 
from the PSA.
Now I just want to point to the address at 00FCAA6C which is a pointer to the 
ASXB which contains the jobname at offset 0XC0.

But somehow I cannot add 6C to the ASCB pointer FCAA00 and get the ASXB pointer 
at FCAA6C.
Instead I get FCABB0 (or some other address depending on which ASCB is 
obtained).
Can some C guru please tell me what I am doing wrong?

i will post the program and results - this is running on UNIX/OMVS.


 MVSZ MVSZ - Storage Contents : ACSCEXB -- (00FCAA00,,SQA) -------------------
 Command ===>                                                  Scroll ===> PAG

 Address  Offset  0-1-2-3-  4-5-6-7-  8-9-A-B-  C-D-E-F-    0---4---8---C---
 00FCAA00     +0  C1E2C3C2  00FBC100  00FCAB80  00000000  | ASCB..A...¿Ø.... |
 00FCAA10    +10  00000000  00000000  00000000  00000000  | ................ |
 00FCAA20    +20  000002E4  00780000  000100FF  00000000  | ...U.Ì.......... |
 00FCAA30    +30  7FF19E00  00000000  19A77000  00000000  | "1Æ......xø..... |
 00FCAA40    +40  00000000  00308F46  D3DC5674  8B346008  | ......±ãLüîÈ».-. |
 00FCAA50    +50  00000000  00000000  00000000  00000000  | ................ |
 00FCAA60    +60  00AFF158  FFFF8F80  00000000  00AFD000  | .®1ì..±Ø.....®}. |
 00FCAA70    +70  1D171020  00000000  00000000  00AFD520  | .............®N. |
 00FCAA80    +80  00000000  00000000  80AFFF98  40000000  | ........Ø®.q ... |

 result running jn2
$ jn2
ASCB = FCAA00
ASXB =  FCABB0
$

jn2.c program

#define _XOPEN_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include <iostream.h>
int main(int argc, char *argv[])
 {
int *PSA;
int      *ASCB;
int      *ASXB;
char jobname[9];
PSA=(int *)0x224; /* address of PSAAOLD */
ASCB=(int *)*PSA;
printf("ASCB = %X\n",ASCB);
ASXB=ASCB+0x6c;
printf("ASXB =  %X\n",ASXB);
}

to compile:
c++ -+ -c -o jn2.o -I/u/eileen/j16/cons \
 -I/usr/lpp/java/J8.0_64/include \
 -W"c,lp64,dll,xplink,langlvl(longlong,nullptr)" jn2.c

to link:
c++                                         \
-W l,AMODE=64,lp64,LET=4,xplink,dynam=dll,case=mixed \
-I=CELQS003.x \
-o jn2            \
  linkmods/CELQSTRT.o \
 linkmods/CEESTART.o \
 linkmods/CELQSG03.o \
 linkmods/CELQINPL.o \
 linkmods/CELQETBL.o \
 linkmods/CELQLLST.o \
 linkmods/CELQBST.o \
 linkmods/CELQTRM.o \
 jn2.o



  ________________________________

This e-mail, including any attachments, may be confidential, privileged or 
otherwise legally protected. It is intended only for the addressee. If you 
received this e-mail in error or from someone who was not authorized to send it 
to you, do not disseminate, copy or otherwise use this e-mail or its 
attachments. Please notify the sender immediately by reply e-mail and delete 
the e-mail from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to