Ejemplo n.º 1
0
//--------------------------------------------------------------------------
// начало сегмента
void N78K_segstart(ea_t ea)
{
  segment_t *Sarea = getseg(ea);
  const char *SegType=	(Sarea->type==SEG_CODE)?"CSEG":
						((Sarea->type==SEG_DATA)?"DSEG":
						"RSEG"
						);
	// Выведем строку вида RSEG <NAME>
#if IDP_INTERFACE_VERSION > 37
	char sn[MAXNAMELEN];
	get_segm_name(Sarea,sn,sizeof(sn));
	printf_line(-1,"%s %s ",SegType, sn);
#else
	printf_line(-1,"%s %s ",SegType, get_segm_name(Sarea));
#endif
	// если смещение не ноль - выведем и его (ORG XXXX)
	if ( inf.s_org ) {
		ulong org = ea - get_segm_base(Sarea);
		if( org != 0 ){
#if IDP_INTERFACE_VERSION > 37
			char bufn[MAX_NUMBUF];
			btoa(bufn, sizeof(bufn), org);
			printf_line(-1, "%s %s", ash.origin, bufn);
#else
			printf_line(-1, "%s %s", ash.origin, btoa(org));
#endif
		}
	}
}
Ejemplo n.º 2
0
char printerr(char *msg,int value)
{
 static char buf[0x100];
stringserial(msg);
buf[0]="(";
buf[1]=0;
if(value<0)btoa(buf+1,value,-10);
else btoa(buf+1,value,10);
strcat(buf,")!\n");
stringserial(buf);
}
Ejemplo n.º 3
0
Archivo: out.cpp Proyecto: nealey/vera
// Generate a segment header
void gen_segm_header(ea_t ea) {
    segment_t *Sarea = getseg(ea);

    char sname[MAXNAMELEN];
    get_segm_name(Sarea, sname, sizeof(sname));

    char *segname = sname;
    if ( *segname == '_' )
        segname++;

    if ( ash.uflag & UAS_ASW ) {
        printf_line(inf.indent, COLSTR("SEGMENT %s", SCOLOR_ASMDIR),
            segname);
    }
    else {
        printf_line(inf.indent, COLSTR(".section .%s", SCOLOR_ASMDIR),
            segname);
    }

    ea_t orgbase = ea - get_segm_para(Sarea);

    if ( orgbase != 0 )
    {
      char buf[MAX_NUMBUF];
      btoa(buf, sizeof(buf), orgbase);
      printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
    }
}
Ejemplo n.º 4
0
//----------------------------------------------------------------------
void out(void)
{
  char buf[MAXSTR];
  // output .org for enties without any labels
  if ( !has_any_name(uFlag) && helper.altval(cmd.ea) )
  {
    btoa(buf, sizeof(buf), cmd.ip);
    printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
  }

  init_output_buffer(buf, sizeof(buf));

  OutMnem();

  out_one_operand(0);
  if ( cmd.Op2.type != o_void )
  {
    out_symbol(',');
    OutChar(' ');
    out_one_operand(1);
  }

  if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1);
  if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2);

  term_output_buffer();

  gl_comm = 1;
  MakeLine(buf);
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------
void segstart(ea_t ea)
{
  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;
  char sname[MAXNAMELEN];
  char sclas[MAXNAMELEN];
  get_segm_name(Sarea, sname, sizeof(sname));
  get_segm_class(Sarea, sclas, sizeof(sclas));
  printf_line(0, COLSTR("%s", SCOLOR_ASMDIR)
                 " "
                 COLSTR("%s %s", SCOLOR_AUTOCMT),
                 strcmp(sclas,"CODE") == 0
                    ? ".CSEG"
                    : strcmp(sclas,"DATA") == 0
                         ? ".DSEG"
                         : ".ESEG",
                 ash.cmnt,
                 sname);
  if ( Sarea->orgbase != 0 )
  {
    char buf[MAX_NUMBUF];
    btoa(buf, sizeof(buf), Sarea->orgbase);
    printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
  }
}
Ejemplo n.º 6
0
Archivo: out.cpp Proyecto: nealey/vera
//--------------------------------------------------------------------------
void idaapi gen_stkvar_def(char *buf, size_t bufsize, const member_t *mptr, sval_t v)
{
  char sign = ' ';
  if ( v < 0 )
  {
    sign = '-';
    v = -v;
  }

  char name[MAXNAMELEN];
  name[0] = '\0';
  get_member_name(mptr->id, name, sizeof(name));

  char vstr[MAX_NUMBUF];
  btoa(vstr, sizeof(vstr), v);
  qsnprintf(buf, bufsize,
            COLSTR("%s",SCOLOR_KEYWORD) " "
            COLSTR("%c%s",SCOLOR_DNUM)
            COLSTR(",",SCOLOR_SYMBOL) " "
            COLSTR("%s",SCOLOR_LOCNAME),
            ash.a_equ,
            sign,
            vstr,
            name);
}
Ejemplo n.º 7
0
//--------------------------------------------------------------------------
void idaapi z8_assumes(ea_t ea)
{
  segreg_t *Darea  = get_srarea(ea);
  segment_t *Sarea = getseg(ea);

  if ( Sarea == NULL || Darea == NULL || !inf.s_assume )
    return;

  // always show at the start of code segments
  int show = (ea == Sarea->startEA) && (Sarea->type == SEG_CODE);
  if ( show || Darea->startEA == ea )
  {
    segreg_t our = *Darea;
    segreg_t *prev = show ? NULL : get_srarea(ea-1);
    sel_t rp = our.reg(rRp);
    if ( prev == NULL || prev->reg(rRp) != rp )
    {
      if ( rp == BADSEL )
        rp = 0;
      char num[MAX_NUMBUF];
      btoa(num, sizeof(num), rp);
      char nbuf[MAXSTR];
      qsnprintf(nbuf, sizeof(nbuf), COLSTR(".rp %s", SCOLOR_ASMDIR), num);
      MakeLine(nbuf, inf.indent);
    }
  }
}
Ejemplo n.º 8
0
void print_bits(int i) {
  const int size = sizeof(int) * 8;

  char buffer[size + 1] = {0};
  buffer[size] = '\0';
  btoa(i, buffer, size);
  printf("%9d: %s\n", i, buffer);
}
Ejemplo n.º 9
0
static int out_equ(ea_t ea)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);
  segment_t *s = getseg(ea);
  if ( s != NULL && s->type == SEG_IMEM && ash.a_equ != NULL)
  {
    char nbuf[MAXSTR];
    char *name = get_name(BADADDR, ea, nbuf, sizeof(nbuf));
    if ( name != NULL
      && ((ash.uflag & UAS_PBYTNODEF) == 0 || !IsPredefined(name)) )
    {
      get_colored_name(BADADDR, ea, buf, sizeof(buf));
      uchar off = uchar(ea - get_segm_base(s));
      do_out_equ(buf, ash.a_equ, off);
      if ( (ash.uflag & UAS_AUBIT) == 0 && (off & 0xF8) == off )
      {
        char *ptr = tag_on(tail(buf), end, COLOR_SYMBOL);
        APPCHAR(ptr, end, ash.uflag & UAS_NOBIT ? '_' : '.');
        APPCHAR(ptr, end, '0');
        tag_off(ptr, end, COLOR_SYMBOL);
        for ( int i=0; i < 8; i++ )
        {
          const ioport_bit_t *b = find_bit(off, i);
          char *p2 = ptr;
          if ( b == NULL || b->name == NULL )
            ptr[-1] = '0' + i;
          else
            p2 = tag_addstr(ptr-1, end, COLOR_HIDNAME, b->name);
          tag_off(p2, end, COLOR_SYMBOL);
          do_out_equ(buf, ash.a_equ, off+i);
        }
        MakeNull();
      }
    }
    else
    {
      gl_name = 0;
      MakeLine("");
    }
    return 1;
  }
  if ( ash.uflag & UAS_NODS )
  {
    if ( !isLoaded(ea) && s->type == SEG_CODE )
    {
      adiff_t org = ea - get_segm_base(s) + get_item_size(ea);
      btoa(buf, sizeof(buf), org);
      printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
      return 1;
    }
  }
  return 0;
}
Ejemplo n.º 10
0
Archivo: out.cpp Proyecto: nealey/vera
//--------------------------------------------------------------------------
void segstart(ea_t ea)
{
  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;

  char sname[MAXNAMELEN];
  char sclas[MAXNAMELEN];
  get_true_segm_name(Sarea, sname, sizeof(sname));
  get_segm_class(Sarea, sclas, sizeof(sclas));

  if ( ash.uflag & UAS_GNU )
  {
    const char *const predefined[] =
    {
      ".text",    // Text section
      ".data",    // Data sections
      ".rdata",
      ".comm",
    };

    int i;
    for ( i=0; i < qnumber(predefined); i++ )
      if ( strcmp(sname, predefined[i]) == 0 )
        break;
    if ( i != qnumber(predefined) )
      printf_line(inf.indent, COLSTR("%s", SCOLOR_ASMDIR), sname);
    else
      printf_line(inf.indent, COLSTR(".section %s", SCOLOR_ASMDIR) " " COLSTR("%s %s", SCOLOR_AUTOCMT),
                   sname,
                   ash.cmnt,
                   sclas);
  }
  else
  {
    if ( strcmp(sname, "XMEM") == 0 )
    {
      char buf[MAX_NUMBUF];
      btoa(buf, sizeof(buf), ea-get_segm_base(Sarea));
      printf_line(inf.indent, COLSTR("%s %c:%s", SCOLOR_ASMDIR),
                  ash.origin,
                  tolower(sname[0]),
                  buf);
    }
    else
    {
      printf_line(inf.indent, COLSTR("section %s", SCOLOR_ASMDIR) " "
                              COLSTR("%s %s", SCOLOR_AUTOCMT),
                  sname,
                  ash.cmnt,
                  sclas);
    }
  }
}
Ejemplo n.º 11
0
//--------------------------------------------------------------------------
static void out_equ(const char *name, const char *equ, uchar off)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);

  char *p = tag_addstr(buf, end, COLOR_DNAME, name);
  APPCHAR(p, end, ' ');
  p = tag_addstr(p, end, COLOR_KEYWORD, equ);
  APPCHAR(p, end, ' ');
  p = tag_on(p, end, COLOR_NUMBER);
  p += btoa(p, end-p, off);
  tag_off(p, end, COLOR_NUMBER);
  MakeLine(buf, 0);
}
Ejemplo n.º 12
0
//--------------------------------------------------------------------------
static void print_segment_register(int reg, sel_t value)
{
  if ( reg == ph.regDataSreg ) return;
  if ( value != BADADDR )
  {
    char buf[MAX_NUMBUF];
    btoa(buf, sizeof(buf), value);
    gen_cmt_line("assume %s = %s", ph.regNames[reg], buf);
  }
  else
  {
    gen_cmt_line("drop %s", ph.regNames[reg]);
  }
}
Ejemplo n.º 13
0
//--------------------------------------------------------------------------
void assume(ea_t ea)
{
  segreg_t *Darea  = getSRarea(ea);
  segment_t *Sarea = getseg(ea);
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);

  if ( Sarea == NULL || Darea == NULL || !inf.s_assume ) return;

  bool show = (ea == Sarea->startEA);
  if ( show || Darea->startEA == ea )
  {
    bool used = false;
    segreg_t our = *Darea;
    segreg_t *prev = show ? NULL : getSRarea(ea-1);
    char *ptr = NULL;
    for ( int i=ph.regFirstSreg; i <= ph.regLastSreg; i++ )
    {
      if ( i == ph.regCodeSreg ) continue;
      if ( prev == NULL || prev->reg(i) != our.reg(i) )
      {
        if ( !used )
        {
          ptr = tag_on(buf, end, COLOR_AUTOCMT);
          APPEND(ptr, end, ash.cmnt);
          APPEND(ptr, end, " assume ");
        }
        else
        {
          APPCHAR(ptr, end, ',');
          APPCHAR(ptr, end, ' ');
        }
        used = true;
        APPEND (ptr, end, ph.regNames[i]);
        APPCHAR(ptr, end, ':');
        if ( our.reg(i) == BADSEL )
          APPEND(ptr, end, "nothing");
        else
          ptr += btoa(ptr, end-ptr, our.reg(i), 16);
      }
    }
    if ( used )
    {
      tag_off(ptr, end, COLOR_AUTOCMT);
      MakeLine(buf, inf.indent);
    }
  }
}
Ejemplo n.º 14
0
Archivo: out.cpp Proyecto: nealey/vera
void segstart( ea_t ea )
{
    segment_t *Sarea = getseg( ea );

    char name[MAXNAMELEN];
    get_segm_name(Sarea, name, sizeof(name));
    gen_cmt_line( COLSTR("segment %s", SCOLOR_AUTOCMT), name );

    ea_t org = ea - get_segm_base( Sarea );
    if ( org != 0 )
    {
        char buf[MAX_NUMBUF];
        btoa(buf, sizeof(buf), org);
        gen_cmt_line("%s %s", ash.origin, buf);
    }
}
Ejemplo n.º 15
0
Archivo: out.cpp Proyecto: nealey/vera
// --------------------------------------------------------------------------
// generate start of segment
void idaapi segstart(ea_t ea) {
  // generate ORG directive if necessary
  if (inf.s_org)
  {
    // get segment data
    segment_t *Sarea = getseg(ea);
    size_t org = size_t(ea - get_segm_base(Sarea));

    // generate line
    if ( org != 0 )
    {
      char buf[MAX_NUMBUF];
      btoa(buf, sizeof(buf), org);
      printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
    }
  }
}
Ejemplo n.º 16
0
//--------------------------------------------------------------------------
void segstart(ea_t ea)
{
  const char *predefined[] =
  {
    ".text",    // Text section
    ".rdata",   // Read-only data section
    ".data",    // Data sections
    ".lit8",    // Data sections
    ".lit4",    // Data sections
    ".sdata",   // Small data section, addressed through register $gp
    ".sbss",    // Small bss section, addressed through register $gp
    ".bss",     // bss (block started by storage) section, which loads zero-initialized data
  };

  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;

  char sname[MAXNAMELEN];
  char sclas[MAXNAMELEN];
  get_true_segm_name(Sarea, sname, sizeof(sname));
  get_segm_class(Sarea, sclas, sizeof(sclas));

  int i;
  for ( i=0; i < qnumber(predefined); i++ )
    if ( strcmp(sname, predefined[i]) == 0 )
      break;
  if ( i != qnumber(predefined) )
    printf_line(inf.indent, COLSTR("%s", SCOLOR_ASMDIR), sname);
  else
    printf_line(inf.indent, COLSTR("%s", SCOLOR_ASMDIR) "" COLSTR("%s %s", SCOLOR_AUTOCMT),
                 strcmp(sclas,"CODE") == 0
                    ? ".text"
                    : strcmp(sclas,"BSS") == 0
                         ? ".bss"
                         : ".data",
                 ash.cmnt,
                 sname);
  if ( Sarea->orgbase != 0 )
  {
    char buf[MAX_NUMBUF];
    btoa(buf, sizeof(buf), Sarea->orgbase);
    printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
  }
}
Ejemplo n.º 17
0
void segstart(ea_t ea)
{
  char buf[MAXSTR];
  segment_t *Sarea = getseg(ea);

  char name[MAXNAMELEN];
  get_segm_name(Sarea, name, sizeof(name));

  if ( ash.uflag & UAS_SECT )
  {
    if ( Sarea->type == SEG_IMEM )
    {
      MakeLine(".RSECT", inf.indent);
    }
    else
    {
      printf_line(0, COLSTR("%s: .section", SCOLOR_ASMDIR), name);
    }
  }
  else
  {
    if(ash.uflag & UAS_NOSEG)
       printf_line(inf.indent, COLSTR("%s.segment %s", SCOLOR_AUTOCMT), ash.cmnt, name);
    else
       printf_line(inf.indent, COLSTR("segment %s",SCOLOR_ASMDIR), name);
    if(ash.uflag & UAS_SELSG) MakeLine(name, inf.indent);
    if(ash.uflag & UAS_CDSEG)
      MakeLine(Sarea->type == SEG_IMEM
                 ? COLSTR("DSEG", SCOLOR_ASMDIR)
                 : COLSTR("CSEG", SCOLOR_ASMDIR),
               inf.indent);
            // XSEG - eXternal memory
  }
  if ( inf.s_org )
  {
    adiff_t org = ea - get_segm_base(Sarea);
    if ( org != 0 )
    {
      btoa(buf, sizeof(buf), org);
      gen_cmt_line("%s %s", ash.origin, buf);
    }
  }
}
Ejemplo n.º 18
0
//--------------------------------------------------------------------------
void idaapi segstart(ea_t ea)
{
  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;

  char sclas[MAXNAMELEN];
  get_segm_class(Sarea, sclas, sizeof(sclas));

  if ( strcmp(sclas,"CODE") == 0 )
    printf_line(inf.indent, COLSTR(".text", SCOLOR_ASMDIR));
  else if ( strcmp(sclas,"DATA") == 0 )
    printf_line(inf.indent, COLSTR(".data", SCOLOR_ASMDIR));

  if ( Sarea->orgbase != 0 )
  {
    char buf[MAX_NUMBUF];
    btoa(buf, sizeof(buf), Sarea->orgbase);
    printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
  }
}
Ejemplo n.º 19
0
// generate segment header
void idaapi gen_segm_header(ea_t ea) {
    segment_t *Sarea = getseg(ea);

    char sname[MAXNAMELEN];
    get_segm_name(Sarea, sname, sizeof(sname));
    char *segname = sname;

    if ( ash.uflag & UAS_SEGM )
        printf_line(inf.indent, COLSTR("SEGMENT %s", SCOLOR_ASMDIR), segname);
    else if ( ash.uflag & UAS_RSEG )
        printf_line(inf.indent, COLSTR("RSEG %s", SCOLOR_ASMDIR), segname);

    ea_t orgbase = ea - get_segm_para(Sarea);
    if ( orgbase != 0 )
    {
      char buf[MAX_NUMBUF];
      btoa(buf, sizeof(buf), orgbase);
      printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
    }
}
Ejemplo n.º 20
0
void
one_switch_entry(ea_t ea, ea_t ptr)
{
  if ( !isData(ea) )
   do_unknown_range(ea, 4, true);
  add_cref(ea, ptr, 
#if (IDP_INTERFACE_VERSION > 65)
  fl_USobsolete
#else
  fl_US
#endif
  );
  char abuf[0x10];
  btoa(abuf, 0x10, ptr, 0x10);
  rp_set_comment(ea, abuf, false );
  ua_code(ptr);
  doDwrd(ea, 4);
#ifdef PIC_DEBUG
 RP_TRACE2("add_cref %X to %X\n", ea, ptr );
#endif
}
Ejemplo n.º 21
0
//--------------------------------------------------------------------------
static void print_segment_register(int reg, sel_t value)
{
  if ( reg == ph.regDataSreg ) return;
  char buf[MAX_NUMBUF];
  btoa(buf, sizeof(buf), value);
  switch (reg)
  {
    case ARMS:
      if (value == -1) break;
      printf_line(inf.indent,COLSTR(".arms_%s",SCOLOR_ASMDIR), value ? "on":"off");
      return;
    case CPL:
      if (value == -1) break;
      printf_line(inf.indent,COLSTR(".cpl_%s",SCOLOR_ASMDIR), value ? "on":"off");
      return;
    case DP:
      if (value == -1) break;
      printf_line(inf.indent,COLSTR(".dp %s",SCOLOR_ASMDIR), buf);
      return;
  }
  gen_cmt_line("assume %s = %s", ph.regNames[reg], buf);
}
Ejemplo n.º 22
0
void
        showdef(void)
{
  register i, j, x = 0, y = 0, xo = 0, yo = 0, max_desc = 0, height = 1,
          width = 1;
  register struct def *d;
  char   *val;

  name = getdefault("name");
  keymap = getdefault("keymap");
  ckeymap = getdefault("ckeymap");
  plist = getdefault("playerlist");
  cloak_chars = cloakChars;
  bmap = getdefault("buttonmap");

  if (!defWin)
    defWin = W_MakeTextWindow("xtrekrc_help", 1, 100, 174, 41, NULL, BORDER);

  for (i = 0, d = def_messages; i < DEFMESSAGES; i++, d++)
    {
      x = xo;
      y = yo;

      W_WriteText(defWin, x, y, W_Yellow, d->name, strlen(d->name),
      W_BoldFont);
      x += NAME_WIDTH;

      W_WriteText(defWin, x, y, textColor, d->desc, strlen(d->desc),
      W_RegularFont);
      if (strlen(d->desc) > max_desc)
  {
    max_desc = strlen(d->desc);
    width = MAX(width, x + max_desc);
  }
      y++;
      x = xo + INDENT;

      if (d->type != STR_DEF)
  {
    if (!d->values[0].desc && d->variable)
      {
        if (d->type == SINT_DEF)
    val = itos(*d->variable);
        else
    val = itos(d->values[0].i_value);

        W_WriteText(defWin, x, y, W_Green, val, strlen(val),
        W_RegularFont);
        y++;
      }
    for (j = 0; d->values[j].desc; j++)
      {
        switch (d->type)
    {
    case INT_DEF:
      val = itos(d->values[j].i_value);
      if (d->values[j].i_value == *d->variable)
        {
          W_WriteText(defWin, x, y, W_Green, val, strlen(val),
          W_BoldFont);
          if (W_Mono())
      {
        W_WriteText(defWin, x + 1, y, W_Green, "*", 1,
              W_RegularFont);
      }
        }
      else
        W_WriteText(defWin, x, y, textColor, val, strlen(val),
        W_RegularFont);
      x = xo + NAME_WIDTH;
      W_WriteText(defWin, x, y, textColor, d->values[j].desc,
            strlen(d->values[j].desc), W_RegularFont);
      y++;
      x = xo + INDENT;
      break;

    case BOOL_DEF:
      val = btoa(*d->variable);
      W_WriteText(defWin, x, y, W_Green, val, strlen(val),
            W_RegularFont);
      y++;
      x = xo + INDENT;
      break;
    default:
      fprintf(stderr, "Unknown type.\n");
      break;
    }
      }
  }
      else if (d->variable && *d->variable)
  {
    W_WriteText(defWin, x, y, W_Green, *((char **) d->variable),
          strlen(*((char **) d->variable)),
          W_RegularFont);
    y++;
  }

      height = MAX(height, y);
      if (y > MAX_VLINES)
  {
    yo = 0;
    xo += NAME_WIDTH + max_desc + 2;
    max_desc = 0;
  }
      else
  {
    yo = y + 1;
  }
    }

  W_ResizeTextWindow(defWin, width, height);
  W_MapWindow(defWin);
}
Ejemplo n.º 23
0
void main(void)
{
	unsigned long temp_ulong;
	INT temp_int, temp_int2;
	BYTE temp_byte;
	AMUX4_0_InputSelect(AMUX4_0_PORT0_1);        
   	AMUX4_1_InputSelect(AMUX4_1_PORT0_0);
   	INSAMP_Start(INSAMP_LOWPOWER); 
    ADCINC_Start(ADCINC_HIGHPOWER);      
   	DAC9_Ia_Start(DAC9_Ia_HIGHPOWER);
	DAC6_VGND_Start(DAC6_VGND_MEDPOWER);
	DAC6_VGND_WriteStall (31);
    PWM8_Vout_DisableInt();  
    PWM8_Vout_Start();     
    PWM8_Heater_DisableInt();  
    PWM8_Heater_Start();
	PWM8_NB_Out_DisableInt();  
    PWM8_NB_Out_Start(); 
	ADCINC_GetSamples(0);
	SleepTimer_Start();  
   	SleepTimer_SetInterval(SleepTimer_512_HZ);  
   	SleepTimer_EnableInt();   
	M8C_EnableGInt ;  
	LCD_Start();                  // Initialize LCD
	LCD_InitBG(LCD_SOLID_BG);

	while(1) {
		temp_ulong++;
		if ((ADC_IF & 1) == 1) {
			ADC_IF = ADC_IF & 254;
			Ri_Min = IIR_Int(Ri_Min_x1*2,Ri_Min,Ri_Filter_Strength);
			Ri_Delta = Ri_Max - Ri_Min;
			Ri_Mid = (Ri_Max + Ri_Min) / 2;
		}

		if ((ADC_IF & 2) == 2) {
			ADC_IF = ADC_IF & 253;
			Ri_Max = IIR_Int(Ri_Max_x1 * 2, Ri_Max, Ri_Filter_Strength);
			Ri_Delta = Ri_Max - Ri_Min;
			Ri_Mid = (Ri_Max + Ri_Min) / 2;
		}

		if ((ADC_IF & 4) == 4) {
			ADC_IF = ADC_IF & 251;
			ip = IIR_Int(ip_x1 * 2, ip, ip_Filter_Strength);
		}

		Ia_PID_Counter += Sleep_Counter;
		Heater_PID_Counter += Sleep_Counter;
		Heatup_Counter += Sleep_Counter;
		Vout_Lookup_Counter += Sleep_Counter;
		LCD_Counter += Sleep_Counter;
		Sleep_Counter = 0;

		if (Ia_PID_Counter > Ia_PID_Counter_Set) {
			Ia_PID_Counter = 0;
			Ia_PID();
		}

		if (Heater_PID_Counter > Heater_PID_Counter_Set) {
			Heater_PID_Counter = 0;
			Heater_PID();
		}

		if (Vout_Lookup_Counter > Vout_Lookup_Counter_Set) {}
			Vout_Lookup_Counter = 0;
			temp_int = ip - ip_to_Vout_Lookup_Start;
			if (temp_int < 0) {
				temp_int = 0;
			} else if (temp_int > (ip_to_Vout_Lookup_Size - 1)) {
				temp_int = (ip_to_Vout_Lookup_Size - 1);
			}
			PWM8_Vout_WritePulseWidth(ip_to_Vout_Lookup[temp_int]);
			
			#ifdef NB_Out
				temp_byte = 23;//0.45v
				if (ip < 251) { // 251 =0.9797787392968
					temp_byte = 46; //0.9v		
				} else if (ip > 259) { //259 = 1.02295956968912
					temp_byte = 0; //0v
				}
				PWM8_NB_Out_WritePulseWidth(temp_byte);
			#endif
		}

		if (LCD_Counter > LCD_Counter_Set) {
			LCD_Counter = 0;
			
			#ifdef LCD_Lambda_Text
				temp_int = ip - ip_to_Lambda_Lookup_Start;
				
				if (temp_int < 0) {
					temp_int = 0;
				} else if (temp_int > (ip_to_Lambda_Lookup_Size - 1)) {
					temp_int=(ip_to_Lambda_Lookup_Size - 1);
				}

				Lambda_x100 = ip_to_Lambda_Lookup[temp_int];
				temp_int = Lambda_x100;
				LCD_Position(0,0);
				temp_int2 = temp_int / 100;
				Str1[9] = btoa(temp_int2);
				temp_int = temp_int - (100 * temp_int2);
				temp_int2 = temp_int / 10;
				Str1[11] = btoa(temp_int2);
				temp_int = temp_int - (10 * temp_int2);
				Str1[12] = btoa(temp_int);
				LCD_PrString(Str1);
			#endif

			#ifdef LCD_AFR_Text
				temp_int = ip - ip_to_Lambda_Lookup_Start;

				if (temp_int < 0) {
					temp_int = 0;
				} else if (temp_int > (ip_to_Lambda_Lookup_Size - 1)) {
					temp_int = (ip_to_Lambda_Lookup_Size - 1);
				}

				Lambda_x100=ip_to_Lambda_Lookup[temp_int];
				temp_int = (INT) Lambda_x100 * 147;
				LCD_Position(0,0);
				temp_int2 = temp_int / 1000;
				Str1[6] = btoa(temp_int2);
				temp_int = temp_int - (1000 * temp_int2);
				temp_int2 = temp_int / 100;
				Str1[7] = btoa(temp_int2);
				temp_int = temp_int - (100 * temp_int2);
				temp_int2 = temp_int / 10;
				Str1[9] = btoa(temp_int2);
				temp_int = temp_int - (10 * temp_int2);
				Str1[10] = btoa(temp_int);
				LCD_PrString(Str1);
			#endif
			
			#ifdef LCD_Lambda_Graph
				temp_int = ip - ip_to_Lambda_Lookup_Start;
				
				if (temp_int < 0) {
					temp_int = 0;
				} else if (temp_int > (ip_to_Lambda_Lookup_Size-1)) {
					temp_int = (ip_to_Lambda_Lookup_Size - 1);
				}

				Lambda_x100 = ip_to_Graph_Lookup[temp_int];
				LCD_DrawBG(0, 0, 16, Lambda_x100);
			#endif
			
			#ifdef LCD_Temperature_Text
				temp_int = Ri_Delta-Ri_Delta_to_Temperature_C_Start;

				if (temp_int < 0) {
					temp_int = 0;
				} else if (temp_int > (Ri_Delta_to_Temperature_C_Size - 1)) {
					temp_int = (Ri_Delta_to_Temperature_C_Size - 1);
				}

				LSU_Temperature_C = Ri_Delta_to_Temperature_C[temp_int] + Ri_Delta_to_Temperature_C_Offset;
				temp_int = LSU_Temperature_C;
				LCD_Position(1,0);           
				temp_int2 = temp_int / 100;
				Str2[7] = btoa(temp_int2);
				temp_int = temp_int - (100 * temp_int2);
				temp_int2 = temp_int / 10;
				Str2[8] = btoa(temp_int2);
				temp_int = temp_int - (10 * temp_int2);
				Str2[9] = btoa(temp_int);
				LCD_PrString(Str2);
			#endif
			
			#ifdef LCD_Temperature_Graph
				temp_int = Ri_Delta - Ri_Delta_to_Temperature_C_Start;

				if (temp_int < 0) {
					temp_int = 0;
				} else if (temp_int > (Ri_Delta_to_Temperature_C_Size - 1)) {
					temp_int = (Ri_Delta_to_Temperature_C_Size - 1);
				}

				LSU_Temperature_C = Ri_Delta_to_Graph[temp_int];
				LCD_DrawBG(1, 0, 16, LSU_Temperature_C);
			#endif
		}

		if (Heatup_Heater_Output < 255) {   
			if (Heatup_Counter > Heatup_Counter_Set) {
				Heatup_Counter = 0;
				Heatup_Heater_Output++;
			}

			if ((Ri_Min > 50) && (Ri_Max < 475) && (Ri_Delta < Ri_Delta_Target)) {
				Heatup_Heater_Output = 255;
				Ri_Delta_Error_Sum = 0;
			}
		}
	}
Ejemplo n.º 24
0
Archivo: out.cpp Proyecto: nealey/vera
//--------------------------------------------------------------------------
void segstart(ea_t ea)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);
  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;

  const char *align;
  switch ( Sarea->align )
  {
    case saAbs:        align = "at: ";   break;
    case saRelByte:    align = "byte";  break;
    case saRelWord:    align = "word";  break;
    case saRelPara:    align = "para";  break;
    case saRelPage:    align = "page";  break;
    case saRel4K:      align = "4k";    break;
    case saRel64Bytes: align = "64";    break;
    default:           align = NULL;    break;
  }
  if ( align == NULL )
  {
    gen_cmt_line("Segment alignment '%s' can not be represented in assembly",
                 get_segment_alignment(Sarea->align));
    align = "";
  }

  char sname[MAXNAMELEN];
  char sclas[MAXNAMELEN];
  get_true_segm_name(Sarea, sname, sizeof(sname));
  get_segm_class(Sarea, sclas, sizeof(sclas));

  char *ptr = buf + qsnprintf(buf, sizeof(buf),
                              SCOLOR_ON SCOLOR_ASMDIR "%-*s segment %s ",
                              inf.indent-1,
                              sname,
                              align);
  if ( Sarea->align == saAbs )
  {
    ea_t absbase = get_segm_base(Sarea);
    ptr += btoa(ptr, end-ptr, absbase);
    APPCHAR(ptr, end, ' ');
  }
  const char *comb;
  switch ( Sarea->comb )
  {
    case scPub:
    case scPub2:
    case scPub3:    comb = "";        break;
    case scCommon:  comb = "common";  break;
    default:        comb = NULL;      break;
  }
  if ( comb == NULL )
  {
    gen_cmt_line("Segment combination '%s' can not be represented in assembly",
                 get_segment_combination(Sarea->comb));
    comb = "";
  }
  ptr += qsnprintf(ptr, end-ptr, "%s '%s'", comb, sclas);
  tag_off(ptr, end, COLOR_ASMDIR);
  MakeLine(buf, 0);
}