コード例 #1
0
ファイル: macro.c プロジェクト: jdelgadoalfonso/gputils
void setup_macro(struct macro_head *h, int arity, struct pnode *parms)
{
  if (enforce_arity(arity, list_length(h->parms))) {
    /* push table for the marco parms */
    state.stTopDefines = push_symbol_table(state.stTopDefines, 
                                        state.case_insensitive);

    /* Now add the macro's declared parameter list to the new 
       defines table. */
    if (arity > 0) {
      struct pnode *pFrom, *pFromH;
      struct pnode *pTo, *pToH;
      struct symbol *sym;

      pTo = parms;

      for (pFrom = h->parms; pFrom; pFrom = TAIL(pFrom)) {
	pToH = HEAD(pTo);
	pFromH = HEAD(pFrom);
	assert(pFromH->tag == symbol);
 
        arg_index = 0;
        arg_buffer[0] = '\0';
        node_to_string(pToH);
        sym = add_symbol(state.stTopDefines, pFromH->value.symbol);	
        annotate_symbol(sym, strdup(arg_buffer));
        pTo = TAIL(pTo);
      }
    }

    state.next_state = state_macro;  
    state.next_buffer.macro = h;
    state.lst.line.linetype = none;
  }
}
コード例 #2
0
ファイル: special.c プロジェクト: LGTMCU/gputils
static gpasmVal do_tstf(gpasmVal r,
                        const char *name,
                        int arity,
                        struct pnode *parms)
{
  if (enforce_arity(arity, 1)) {
    do_insn("movf", add_symbol_constant(parms, 1));
  }

  return r;
}
コード例 #3
0
ファイル: macro.c プロジェクト: jdelgadoalfonso/gputils
void setup_macro(struct macro_head *h, int arity, struct pnode *parms)
{
  if (enforce_arity(arity, list_length(h->parms))) {
    /* push table for the marco parms */
    state.stTopDefines = push_symbol_table(state.stTopDefines, 
                                        state.case_insensitive);

    /* Now add the macro's declared parameter list to the new 
       defines table. */
    if (arity > 0) {
      struct pnode *pFrom, *pFromH;
      struct pnode *pTo, *pToH;
      struct symbol *sym;
      char buffer[BUFSIZ];

      pTo = parms;

      for (pFrom = h->parms; pFrom; pFrom = TAIL(pFrom)) {
	pToH = HEAD(pTo);
	pFromH = HEAD(pFrom);
	assert(pFromH->tag == symbol);
 
        sym = add_symbol(state.stTopDefines, pFromH->value.symbol);	

        /* must convert the parm to a plain string, this will allow
           subsitutions of labels and strings */
        if (pToH->tag == symbol) {
          annotate_symbol(sym, strdup(pToH->value.symbol));
        } else if (pToH->tag == string) {
          sprintf(buffer, "\"%s\"", pToH->value.string);
          annotate_symbol(sym, strdup(buffer));
        } else {
          int value = maybe_evaluate(pToH);

	  if (value < 0)
	    sprintf(buffer, "-%#x", -value);
          else
	    sprintf(buffer, "%#x", value);	  
	  annotate_symbol(sym, strdup(buffer));
        }
    
        pTo = TAIL(pTo);
      }
    }

    state.next_state = _macro;  
    state.next_buffer.macro = h;
    state.lst.line.linetype = none;
  }
}
コード例 #4
0
ファイル: special.c プロジェクト: LGTMCU/gputils
static gpasmVal do_negf(gpasmVal r,
                        const char *name,
                        int arity,
                        struct pnode *parms)
{
  if ((arity == 1) || (arity == 2)) {
    do_insn("comf", add_symbol_constant(parms, 1));
    do_insn("incf", parms);
  } else {
    enforce_arity(arity, 2);
  }

  return r;
}
コード例 #5
0
ファイル: special.c プロジェクト: LGTMCU/gputils
static gpasmVal do_mode(gpasmVal r,
                        const char *name,
                        int arity,
                        struct pnode *parms)
{
  if (enforce_arity(arity, 1)) {
    struct pnode* val = HEAD(parms);

    if ((val->tag == PTAG_CONSTANT) && (val->value.constant > 0x1f)) {
      gpvwarning(GPW_RANGE, NULL);
      val->value.constant &= 0x1f;
    }
    do_insn("movlw", parms);
    do_insn("movwm", NULL);
  }
  return r;
}