Getting page-aligned storage

The EDCX4KGT routine is called to get page-aligned storage from the operating system. Its entry point must be @@X4KGET. It has the following parameter:
R0
The requested length, in bytes. If the high-order bit of this register is zero or if the request was made in 24-bit addressing mode, the storage is allocated below the 16M line. If the high-order bit is on and the request is made in 31-bit addressing mode, storage is allocated above the 16M line. If this space is not available, storage is allocated elsewhere.
Upon return, the following values are set:
R0
The length of the storage block acquired, in bytes. This length may be greater than the size requested.
R1
The address of the acquired area or NULL.
R15
A system-dependent return code, which must be zero on success and nonzero otherwise.

This routine is not provided with a save area. In addition to the linkage registers, this routine may freely alter registers 2 and 4.