HP3000-L Archives

September 1997, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Klein <[log in to unmask]>
Reply To:
Mark Klein <[log in to unmask]>
Date:
Fri, 5 Sep 1997 13:11:51 PST
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Stan writes:

>Sample code to get the CCR (Coprocessor Configuration Register):


[pascal example snipped]:

And since Mark is primarily working in C, I'll provide the following
examples:

extern int get_control_reg(int reg);

int getccr(void)
  {
  /*
   * Get the coprocessor control register.
   */
  return get_control_reg(10) & 0xff;
  }

I'll also provide an example on how to determine the architecture level
because this requires the use of assembly in gcc and is a good exercise:


typedef struct {
  int           spaceid;
  unsigned int  offset;
  } LONGPOINTER;

extern LONGPOINTER _get_monarch_model(void);

int machinetype(void)
  {
  /*
   * Get the address of the IVA.
   */
  LONGPOINTER lptr = _get_monarch_model();

  lptr.offset += 6 * sizeof(int);

  asm("ldw %0, %%r31" : : "m" (lptr.offset));
  asm("ldw %0, %%r28" : : "m" (lptr.spaceid));
  asm("mtsp %r28,%sr1");
  asm("ldw 0(%sr1,%r31), %r28");
  }


You can check out the GNU documentation at
http://www.dis.com/gnu/gcc_toc.html for an explanation on how to use the
assembly features if you're curious!

Regards,



M.

ATOM RSS1 RSS2