If I use a -1 pointer and a member of the structure other than the first, why would I get an S0C4?
-- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 ________________________________________ From: IBM Mainframe Assembler List <[email protected]> on behalf of Bernd Oppolzer <[email protected]> Sent: Sunday, September 13, 2020 1:54 PM To: [email protected] Subject: Re: Deep Cuts This is a very interesting discussion for me, as I am the current maintainer of "New Stanford Pascal". I am trying to extend the language to make it more usable, while not violating the Pascal spirit. Inspiration and motivation are the different versions of IBM's Pascal (Pascal/VS and VS/Pascal), available for MVS and VM/CMS starting from ca. 1980 on. I recently added MEMCPY, MEMSET and MEMCMP; I allowed to take the ADDR of every object (that is, pointers do not only exist for dynamically created variables, via NEW), and I added new functions ALLOC and FREE, which do a better job in storage allocating than NEW and DISPOSE (DISPOSE, in fact, was never implemented in the "old" Stanford compiler; it only had some global heap freeing mechanism using MARK and RELEASE). The NULL pointer (called NIL in Pascal) is implemented as 0xFFFFFFFF (minus one), so that MEMSETting a struct containing pointers indeed will not yield NIL pointers; you have to set the pointers explicitly to NIL after the MEMSET. Dereferencing a NIL pointer will give a 0C4 abend on the mainframe; if you want, you can create a DEBUG version of the program which checks for NIL before dereferencing and throws a Pascal runtime error. Regarding pointer arithmetic: it is not allowed to add an integer value to a pointer directly, but there is a function called PTRADD (p, i), which adds an integer value i to a pointer p. i may be positive or negative. The pointer p is of type ANYPTR (or VOIDPTR), which is a ptr type compatible to all other pointer types. The result of PTRADD is of type ANYPTR, too. In contrast to C, PTRADD adds byte addresses, not elements. PTRADD (p, 0) is used to cast pointer types (pointers are typed pointers in Pascal); it can be coded as PTRCAST (p), too. PTRDIFF (p1, p2) with integer result is the distance between two pointers. There are functions like SIZEOF etc., which work much the same way as their C counterparts. All those functions have to be used with care, because the normal runtime checks (array index limits, subrange, scalar types) do not apply. The compiler works the same on the mainframe and on Windows/Linux etc. (since 2016, before 2016, it was mainframe-only) More information and download: https://secure-web.cisco.com/1-xMTtCWiO7L6XDWmkGQHTWjKV4-xbuy3IHibeWmsG5NPx8pG3gu0GYfymKp6fmPSI2B_7X7vx-a8GBSfBk23WkoXc_Whk0-b_8t4-o7GPaQXuODGTnbIQ0FdLMa-fXB8pyn1oxY0EKwj6hhQ6fx_w8blXo-_GRqRADITTpesrSgHHD1Zhzx74V4mraJCAdaPFu-EnlY7hI7E90FJrNpa0bsZGWiYmbJ16i_IpVJmJEbFV6WkqFYsAL2a_npgFB-T6cn3wwxdzW33F4q14qcWXMJDzfyEZOc3kpKyFlkOcHkptH7XOvwO1isMfUXoDoVWMy5Mg_Ps25eucsAYdUCLrXoC5IILsrSJqLYs9s4LUZbwaDUHjijrNwZw8CQbR3wdm4eDyowPw1YFLqdKEhaowDw6eUp5AIikTrNs6ry5SeX6AtO0QcBZaZ4xGmHN9iaX/https%3A%2F%2Fgithub.com%2FStanfordPascal%2FPascal Kind regards Bernd Am 13.09.2020 um 13:47 schrieb Thomas David Rivers: > Charles Mills <[email protected]> wrote:` > >> I would think if you were going to design a rigorous language you would not >> have a memset() as part of the language or its included library. Memset >> implicitly treats its target as a union between whatever it actually is and >> an array of chars. So using memset kind of violates the restriction I speak >> of in the first paragraph. > Yes - that is a good point. I think such a rigorous language might > lead you down to something like PASCAL-0, which turned out to be wonderful > in a lot of ways, but not too practical. > > Not to defend "C" - I don't really disagree with your point; but I > think a nod-toward-practicality is what lead to some of the > choices we now live with. > > - Dave R. -
