Annotation of 43BSDTahoe/ucb/pascal/pdx/runtime/entry.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)entry.c    5.1 (Berkeley) 6/6/85";
                      9: #endif not lint
                     10: /*
                     11:  * routines to deal with the entry addresses of blocks
                     12:  */
                     13: 
                     14: #include "defs.h"
                     15: #include "runtime.h"
                     16: #include "frame.rep"
                     17: #include "machine.h"
                     18: #include "process.h"
                     19: #include "sym.h"
                     20: #include "source.h"
                     21: #include "object.h"
                     22: #include "process/pxinfo.h"
                     23: #include "process/process.rep"
                     24: 
                     25: /*
                     26:  * Return the address of the beginning of the procedure/function
                     27:  * associated with the given frame.
                     28:  */
                     29: 
                     30: ADDRESS entry(frp)
                     31: register FRAME *frp;
                     32: {
                     33:        return(frp->blockp - 2 - ENDOFF);
                     34: }
                     35: 
                     36: /*
                     37:  * Find the entry address of the caller of the current block.
                     38:  * This is only called in connection with breakpoints.
                     39:  *
                     40:  * This routine assumes it is at the very beginning of the block.
                     41:  */
                     42: 
                     43: ADDRESS caller_addr()
                     44: {
                     45:        FRAME *frp;
                     46: 
                     47:        if ((frp = curframe()) == NIL) {
                     48:                panic("caller_addr(main program)");
                     49:        }
                     50:        frp = nextframe(frp);
                     51:        if (frp == NIL) {
                     52:                return(codeloc(program));
                     53:        } else {
                     54:                return(entry(frp));
                     55:        }
                     56: }
                     57: 
                     58: /*
                     59:  * Find the return address of the current procedure/function.
                     60:  *
                     61:  * There are two special cases:
                     62:  *
                     63:  *     we're right at the beginning of the main program
                     64:  *     we're right at the beginning of some procedure or function
                     65:  *
                     66:  * The first one is handled by returning the last instruction in
                     67:  * the object code.  In the second case, we get the return address
                     68:  * directly from the process' stack.
                     69:  */
                     70: 
                     71: ADDRESS return_addr()
                     72: {
                     73:        ADDRESS addr;
                     74:        FRAME *frp, frame;
                     75: 
                     76:        if (pc == codeloc(program)) {
                     77:                addr = lastaddr();
                     78:        } else {
                     79:                frp = curframe();
                     80:                if (frp == NIL) {
                     81:                        dread(&frame, (ADDRESS) process->sp, sizeof(FRAME));
                     82:                        addr = frame.save_pc - ENDOFF;
                     83:                } else {
                     84:                        addr = frp->save_pc;
                     85:                }
                     86:        }
                     87:        return addr;
                     88: }
                     89: 
                     90: /*
                     91:  * Calculate the entry address for a procedure or function parameter,
                     92:  * given the address of the descriptor.
                     93:  */
                     94: 
                     95: ADDRESS fparamaddr(a)
                     96: ADDRESS a;
                     97: {
                     98:        ADDRESS r;
                     99: 
                    100:        dread(&r, a, sizeof(r));
                    101:        return (r - ENDOFF);
                    102: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.