From - Sat Oct  2 16:28:16 1999
Path: reader2.news.rcn.net!feed1.news.rcn.net!rcn!dispose.news.demon.net!demon!newsfeed.icl.net!newspeer.clara.net!news.clara.net!remarQ-uK!rQdQ!supernews.com!remarQ.com!corp.supernews.com!SendSpamHere.ORG!SYSTEM
From: system@SendSpamHere.ORG (Brian Schenkenberger, VAXman-)
Newsgroups: comp.os.vms
Subject: Re: Reserved Opcode fault trying to ANAL/PROC a dump file.
Date: Thu, 30 Sep 1999 10:46:48 GMT
Organization: TMESIS Software
Message-ID: <009DEE98.0855225E@SendSpamHere.ORG>
References: <1999Sep29.145913@alcor.process.com>	<009DEE1F.1AA9E403@SendSpamHere.ORG>	<1999Sep29.175632@alcor.process.com>	<009DEE38.4CC14C73@SendSpamHere.ORG> <y4905oojh2.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
Reply-To: system@SendSpamHere.ORG
X-Complaints-To: newsabuse@supernews.com
Lines: 137
Xref: reader2.news.rcn.net comp.os.vms:246137

In article <y4905oojh2.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>, Jan Vorbrueggen <jan@mailhost.neuroinformatik.ruhr-uni-bochum.de> writes:
>system@SendSpamHere.ORG (Brian Schenkenberger, VAXman-) writes:
>
>> I encountered this in a fork process that used registers outside of the 
>> permitted set of "scratchable" regs (R0-R5) and preserved them with PUSH
>> and restored them with POPR.  This, however, only saved and restored the
>> lower 32 bits and upone return R6 would contain 0000000066666666 and R8 
>> would contain FFFFFFFF88888888.  (Note the sign extension through the upper
>> 32 bits.)
>
>Isn't this a bug in the implementation of PUSHR/POPR by the MACRO-32 compiler?
>
>	Jan


Yes and no.  If you intend to preserve/restore registers using these two
instructions and only to preserve/restore them, then it might be argued
that it is a bug.  However, I thought about it when I encountered it and
I would have to argue that it is not a bug.  With Macro32 code on VAX, a
common practice was to PUSHR registers and then massage the contents of
the register's context on the stack.  I tend to do this using the macro
$OFFSET to refer to the register's location symbolically but I have seen
code wherein the references were simply hard-coded values.

Here's a simple example.  This will work on both VAX and Alpha.  If the
PUSHR/POPR instructions were to preserve the full 64 bit context, this
would fail on Alpha.

;++
.SBTTL  Primitive program datum definitions
;--
        ZERO = 0                  ; |_ 
        BYTE = 1@0                ; |_|_ 
        WORD = 1@1                ; |___|___ 
        LONG = 1@2                ; |_______|_______
        QUAD = 1@3                ; |_______________|_______________
        OCTA = 1@4                ; |_______________|_______________|
        PAGE = 1@9                ; VAX page ; Alpha Pagelet
        BLOCK= 1@9                ; Standard disk block size

        $OFFSET ZERO,POSITIVE,<-
                <Reg0,LONG>,-
                <Reg1,LONG>,-
                <Reg2,LONG>,-
                <Reg3,LONG>,>

        .PSECT  CODE,NOWRT,EXE,5
        .ENTRY  GO,0

        MOVL    #0,R0
        MOVL    #^x11111111,R1
        MOVL    #^x22222222,R2
        MOVL    #^x33333333,R3
        PUSHR   #^m<R0,R1,R2,R3>

        XORL2   Reg0(SP),Reg3(SP)
        XORL2   Reg3(SP),Reg0(SP)
        XORL2   Reg0(SP),Reg3(SP)

        XORL2   Reg1(SP),Reg2(SP)
        XORL2   Reg2(SP),Reg1(SP)
        XORL2   Reg1(SP),Reg2(SP)

        POPR    #^m<R0,R1,R2,R3>

        RET

        .END    GO


Here is a simple ditty with my own macros to replace the VAX PUSHR/POPR
instruction pair.  These do save the full 64 bit context on the stack.

;++
.SBTTL  Primitive program datum definitions
;--
        ZERO = 0                  ; |_ 
        BYTE = 1@0                ; |_|_ 
        WORD = 1@1                ; |___|___ 
        LONG = 1@2                ; |_______|_______
        QUAD = 1@3                ; |_______________|_______________
        OCTA = 1@4                ; |_______________|_______________|
        PAGE = 1@9                ; VAX page ; Alpha Pagelet
        BLOCK= 1@9                ; Standard disk block size

;++
.SBTTL  Macros to manipulate 64 bit register stack saves and restores
;--
        .MACRO  $PUSHR64,REGLST
        .MACRO  ...REV,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15
        .IRP    REG,<A15,A14,A13,A12,A11,A10,A9,A8,A7,A6,A5,A4,A3,A2,A1,A0>
        .IIF NB,REG, EVAX_STQ REG,-(SP)
        .ENDR
        .ENDM   ...REV
        ...REV  REGLST
        .MDELETE ...REV
        .ENDM   $PUSHR64

        .MACRO  $POPR64,REGLST
        .IRP    REG,<REGLST>
        .IIF NB,REG, EVAX_LDQ REG,(SP)+
        .ENDR
        .ENDM   $POPR64

        $OFFSET ZERO,POSITIVE,<-
                <Reg0,QUAD>,-          ; note that these are now QUADs
                <Reg1,QUAD>,-
                <Reg2,QUAD>,-
                <Reg3,QUAD>,>

        .PSECT  CODE,NOWRT,EXE,5
        .ENTRY  GO,0

        MOVL    #0,R0
        MOVL    #^x11111111,R1
        MOVL    #^x22222222,R2
        MOVL    #^x33333333,R3
        $PUSHR64 <R0,R1,R2,R3>

        EVAX_XOR Reg0(SP),Reg3(SP),Reg0(SP)
        EVAX_XOR Reg3(SP),Reg0(SP),Reg3(SP)
        EVAX_XOR Reg0(SP),Reg3(SP),Reg0(SP)

        EVAX_XOR Reg1(SP),Reg2(SP),Reg1(SP)
        EVAX_XOR Reg2(SP),Reg1(SP),Reg2(SP)
        EVAX_XOR Reg1(SP),Reg2(SP),Reg1(SP)

        $POPR64  <R0,R1,R2,R3>

        RET

        .END     GO

Copyright 1999 by Brian Schenkenberger

--
VAXman- OpenVMS APE certification number: AAA-0001           VAXman@TMESIS.COM
