Memory Map (S390): Difference between revisions

no edit summary
[unchecked revision][unchecked revision]
No edit summary
No edit summary
Line 28:
</source>
 
Now there needs to be a function to "catch" the exceptions recognized by the processor:
<source lang="c">
/* Check if an address is valid - this only catches program exceptions to
Line 68 ⟶ 69:
return r;
}
</source>
 
Some C compilers are known to crash or even ABEND during compilation if addresses of labels are taken via the && operator, alternatively using direct high-level assembler syntax:
 
<source lang="asm">
* HwCheckAddress
* IN:
* pointer to address to probe
*
ENTRY @ZHWCHKA
@ZHWCHKA DS 0H
SAVE (14,12),,@ZHWCHKA
LR R12,R15
USING @ZHWCHKA,12
LR R11,R1
* CATCHPSW address on R1
L R1,=A(CATCHPSW)
* Save address of TMPSAVE on R2
L R2,=A(TMPSAVE)
* And FLCPNPSW on R3
L R3,FLCPNPSW
*
MVC 0(8,R2),0(R3)
* ... use a new PSW to catch the exceptions
MVC 0(8,R3),0(R1)
* Probe the address, if it raises a PC exception then
* we will simply catch it and return 1
L R1,0(R11)
L R15,0(R1)
* rc = 0
MVC 0(8,R3),0(R2)
L R15,=F'0'
RETURN (14,12),RC=(15)
CATCHPCR DS 0H
* rc = 1
MVC 0(8,R3),0(R2)
L R15,=F'1'
RETURN (14,12),RC=(15)
LTORG
DROP 12
*
CATCHPSW DS 0D
DC X'020E0000'
DC A(AMBIT+CATCHPCR)
TMPSAVE DS 1D
</source>
 
170

edits