9 /*****************************************************************************/
11 /* Een constraint-function */
14 struct t_operand *arg;
16 return( arg->type == CONST);
20 /*****************************************************************************/
23 /* decode_operand() recognizes the follwing assembly-argumnets:
27 -(register) : AUTO_DEC
28 (register)+ : AUTO_INC
30 indx(register) : IND_REG
36 /* An assembly instruction has at most 5 arguments.
37 * This is for the time being.
42 *match(), *lab(), *ind(), *end_arg(), *strindex();
44 static int n_index = -1;
59 process_operand( arg, op)
61 register struct t_operand *op;
70 if ( arg[0] == '~' ) {
74 else if ( is_reg( arg, &(op->num)) ) {
77 else if ((arg[0]=='-') && (arg[1] == LEFT) &&
78 is_reg( arg+2,&(op->num))) {
81 else if( ( arg[0] == LEFT) && is_reg( arg+1, &(op->num))) {
82 arg = match( arg, RIGHT);
89 einde = end_arg( arg);
90 if ( (*einde == 'b' || *einde == 'f') && isdigit( *(einde-1))) {
96 else if ( *einde == RIGHT) {
98 arg = ind( ind_buf[ n_index], arg);
99 if ( is_reg( arg+1, &(op->num)))
100 op->indx = ind_buf[ n_index];
102 fprint( STDERR, "unknown argtype %s\n", arg);
106 arg = lab( lab_buf[ n_index], arg);
107 op->lab = lab_buf[ n_index];
119 register char *buf, *str;
121 /* Reads the index in front of '(register)'.
124 while ( *str != LEFT)
132 register char *buf, *str;
134 /* Reads 'label' in front of '+offset'.
137 while ( ( *str != '+') && ( *str != '\0'))
140 while ( isspace( *(buf-1)) ) {
148 int is_reg( str, num)
152 /* Is "str" a 'registers' ?
155 if ( ( *str == 'a') && ( *(str+1) == 'p')) {
159 else if ( ( *str == 'f') && ( *(str+1) == 'p')) {
163 else if ( ( *str == 's') && ( *(str+1) == 'p')) {
168 if ( isdigit( *(str+1)) && isdigit( *(str+2))) {
169 *num = ( *(str+1) - '0') * 10 + *(str+2) - '0';
172 else if ( isdigit( *(str+1))) {
173 *num = *(str+1) - '0';
186 /* Shift to the last character of "str".
189 while ( *str != '\0')
195 char *match( str, sym)
205 /******************************************************************************/
210 register struct t_operand *op;
212 /* Generate object-code for a argument.
217 if (isdigit(op->cst[0])) {
225 @text4( %$(op->cst));
229 @__as_const(%$(op->cst));
232 case REGISTER: @text1( %d(0x50 | op->num));
234 case REG_DEF : @text1( %d(0x60 | op->num));
236 case AUTO_DEC : @text1( %d(0x70 | op->num));
238 case AUTO_INC : @text1( %d(0x80 | op->num));
241 if (isdigit(op->indx[0])) {
245 @text1( %d(0xa0 | op->num));
246 @text1( %$(op->indx));
247 } else if (fit_word(l)) {
248 @text1( %d(0xc0 | op->num));
249 @text2( %$(op->indx));
251 @text1( %d(0xe0 | op->num));
252 @text4( %$(op->indx));
256 @__as_indexed(%$(op->indx) , %d(op->num));
259 case LABEL : @text1( 0xef);
260 if ( strindex( op->lab, DOLLAR)) {
261 @reloc4( %$(op->lab), %$(op->offset), PC_REL);
263 else if ( strindex( op->lab, LEFT)) {
264 @reloc4( %$(op->lab), %$(op->offset), PC_REL);
267 sprint( my_buf, "\"%s\"", op->lab);
268 @reloc4( %$(my_buf), %$(op->offset) , PC_REL);
271 case L_ILB : @text1( %dist( op->lab));
273 default : fprint( STDERR, "error");