static char sccsid
[] = "@(#)opset.c 4.4 %G%";
* Instruction printing routines.
* Definitions for registers and for operand classes
char *insregname(); /* how to print a register */
#define OC_CONS(oc,reg) (((oc & 0xF) << OC_SHIFT) | (reg & 0xF))
#define OC_AMEXT(x) (((x) >> OC_SHIFT) & 0xF)
#define OC_REGEXT(x) ((x) & 0xF)
* Definitions for large numbers
typedef struct as_number
*numberp
;
* Definitions for special instructions
* Definitions for converting TYP's into numbers, booleans, etc.
* These are shared with the assembler.
extern char *ty_string
[];
short ioptab
[3][256]; /* two level 1-based index by opcode into insttab */
for(p
= insttab
; p
->iname
; p
++){
mapchar
= mapescbyte(p
->eopcode
);
if (ioptab
[mapchar
][p
->popcode
])
ioptab
[mapchar
][p
->popcode
] = (p
- insttab
) + 1;
* Global variables for communicating with the minions and printins
static short argno
; /* which argument one is working on */
static char insoutfmt
[2]; /* how to format the relocated symbols */
static struct proct
*procp
;
char *indexreg
; /* print of which register indexes */
char *indexed
; /* we indexed */
if (procp
->paddr
== dot
){
if ((mapchar
= mapescbyte(ins
)) != 0){
if (ioptab
[mapchar
][ins2
] == 0){
* Oops; not a defined instruction;
* back over this escape byte.
if (ioptab
[mapchar
][ins
] == 0){
printf("<undefined operator byte>: %x", ins
);
ip
= &insttab
[ioptab
[mapchar
][ins
] - 1];
printf("%s\t", ip
->iname
);
for (ap
= ip
->argtype
, argno
= 0; argno
< ip
->nargs
; argno
++, ap
++) {
savevar(0x80000000); /* an illegal symbol */
if (A_ACCEXT(optype
) & ACCB
){
switch(A_TYPEXT(optype
)){
mode
= OC_CONS(OC_BDISP
, R_PC
);
mode
= OC_CONS(OC_WDISP
, R_PC
);
indexreg
= operandout(mode
, optype
);
casebody(insoutvar
[1], insoutvar
[2]);
struct as_number
*valuep
;
#define OSIZE (sizeof(short))
for (i
= 0; i
<= limit
; i
++) {
printf(" %d: ", i
+ base
);
printf(" %R: ", i
+ base
);
valuep
= snarfreloc(OSIZE
, 0);
dispaddress(valuep
, OC_CONS(OC_WDISP
, R_PC
));
* magic values to mung an offset to a register into
* something that psymoff can understand.. all magic
static long magic_masks
[5] = {0, 0x80, 0x8000, 0, 0};
static long magic_compl
[5] = {0, 0x100, 0x10000,0, 0};
* Snarf up some bytes, and put in the magic relocation flags
numberp
snarfreloc(nbytes
)
if (back
->num_ulong
[0] & magic_masks
[nbytes
])
back
->num_ulong
[0] -= magic_compl
[nbytes
];
* The following code is NOT portable from the PDP 11 to the VAX
* because of the byte ordering problem.
static struct as_number backnumber
;
static struct as_number znumber
; /* init'ed to 0 */
for (i
= 0; i
< nbytes
; i
++)
backnumber
.num_uchar
[i
] = snarfuchar();
* Read one single character, and advance the dot
* assert: bchkget and inkdot don't have side effects
back
= (u_char
)bchkget(inkdot(incp
), idsp
);
* normal operand; return non zero pointer to register
* name if this is an index instruction.
char *operandout(mode
, optype
)
regnumber
= OC_REGEXT(mode
);
r
= insregname(regnumber
);
shortliteral(mode
, optype
);
return(r
); /* will be printed later */
pcimmediate(mode
, optype
);
dispaddress(snarfreloc(nbytes
), mode
);
dispaddress(valuep
, mode
)
int regnumber
= OC_REGEXT(mode
);
/* PC offset addressing */
valuep
->num_ulong
[0] += inkdot(incp
);
psymoff(valuep
->num_ulong
[0], type
, &insoutfmt
[0]);
if (regnumber
!= R_PC
){ /* } */
if(psymoff(valuep
->num_ulong
[0], regnumber
, &insoutfmt
[0])
printf("(%s)", insregname(regnumber
));
savevar((long)valuep
->num_ulong
[0]);
char *insregname(regnumber
)
if ( (insoutfmt
[0] == 'i')
&& (adrtoregvar(regnumber
, procp
) != -1)) {
* print out a short literal
shortliteral(mode
, optype
)
switch(A_TYPEXT(optype
)){
printf("$%s", fltimm
[mode
]);
pcimmediate(mode
, optype
)
if (mode
== OC_CONS(OC_DAIREG
, R_PC
)){ /* PC absolute, always 4 bytes*/
dispaddress(snarfreloc(4), mode
);
nbytes
= ty_nbyte
[A_TYPEXT(optype
)];
if (! ty_NORELOC
[A_TYPEXT(optype
)]){
dispaddress(snarfreloc(nbytes
), mode
);
bignumprint(nbytes
, optype
);
bignumprint(nbytes
, optype
)
switch(A_TYPEXT(optype
)){
printf("0f%f", valuep
->num_num
.numFf_float
.Ff_value
);
printf("0d%f", valuep
->num_num
.numFd_float
.Fd_value
);
printf("0g::"); goto qprint
;
printf("0h::"); goto qprint
;
for (bindex
= nbytes
- 1; bindex
>= 0; --bindex
){
for (nindex
= 4; nindex
>= 0; nindex
-= 4){
ch
= (valuep
->num_uchar
[bindex
] >> nindex
);
if ( ! (leading_zero
&= (ch
== 0) ) ){
psymoff(v
, regnumber
, fmt
)
if ((diff
= adrtoparam((ADDR
) v
, adrtoprocp(dot
)))
if ((diff
= adrtolocal((ADDR
) -v
, adrtoprocp(dot
))
if ((procp
= adrtoprocp((ADDR
) v
)) != badproc
) {
if ((diff
= adrtoext((ADDR
) v
)) != -1) {