Browse Prior Art Database

Establishing Data Addressability for Code Segments Called Out of Context

IP.com Disclosure Number: IPCOM000106817D
Original Publication Date: 1993-Dec-01
Included in the Prior Art Database: 2005-Mar-21
Document File: 2 page(s) / 72K

Publishing Venue

IBM

Related People

Heisch, RR: AUTHOR

Abstract

A RISC architecture, such as the RS/6000*, provides a number of General Purpose Registers (GPRs) for typical programming usage. A small subset of these GPRs are typically allocated (by convention) for specific uses such as maintaining the stack pointer and a local data segment pointer. Prior to running a program, these special registers must be initialized by the operating system before the program is given control. There is no dedicated hardware to provide access to program stack or data areas and furthermore, these special registers are not always guaranteed to contain valid pointers to stack and data.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Establishing Data Addressability for Code Segments Called Out of Context

      A RISC architecture, such as the RS/6000*, provides a number of
General Purpose Registers (GPRs) for typical programming usage.  A
small subset of these GPRs are typically allocated (by convention)
for specific uses such as maintaining the stack pointer and a local
data segment pointer.  Prior to running a program, these special
registers must be initialized by the operating system before the
program is given control.  There is no dedicated hardware to provide
access to program stack or data areas and furthermore, these special
registers are not always guaranteed to contain valid pointers to
stack and data.

      In particular, if a program or routine is called out of
context, such as is done when patching code, then the stack and data
segment registers must also be changed to point to the called program
or routine stack and data areas.  However, the called program or
routine, which has the responsibility of loading the stack and data
pointer registers, does not have addressability to a valid stack or
data area and therefore cannot acquire the correct stack and data
values to load into the registers.

      One solution to this problem is to have stored the appropriate
stack and data pointer values at a known offset in a preallocated
area of the instruction text segment.  However, when the program or
routine is called, it must have some method of accessing this data in
the instruction text segment.  This disclosure describes such a
method.

The following RS/6000 like assembler code listing shows an
implementation of this method.

+00 Program_Entry:  b start        #Branch over following instruction

+04 return_point:   nop            #Space for patched instruction

+08                 b return_addr

+12 function2:      l rn,lr        #Get link reg (lr) into reg 'rn'

+16                 b done

+20 function1:      bl  function2  #Call function2(), save return
addr in lr

+24 data_area:     .long     0     #First item in data area

+28                .long     0     #Next item in data area, etc.

 :                   :

 :          ...