0.2.38-pre1 implements AVR instructions
authordrdani <drdani@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 6 Nov 2000 08:52:34 +0000 (08:52 +0000)
committerdrdani <drdani@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 6 Nov 2000 08:52:34 +0000 (08:52 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@488 4a8a32a2-be11-0410-ad9d-d568d2c75423

48 files changed:
sim/ucsim/.version
sim/ucsim/avr.src/Makefile.in
sim/ucsim/avr.src/arith_cl.h
sim/ucsim/avr.src/arith_inst.cc
sim/ucsim/avr.src/avr.cc
sim/ucsim/avr.src/avrcl.h
sim/ucsim/avr.src/inst.cc
sim/ucsim/avr.src/jump_inst.cc
sim/ucsim/avr.src/move_inst.cc
sim/ucsim/avr.src/savr.cc
sim/ucsim/avr.src/simavr.cc
sim/ucsim/avr.src/simavrcl.h
sim/ucsim/avr.src/test_call.asm [new file with mode: 0644]
sim/ucsim/cmd.src/(c).1
sim/ucsim/cmd.src/Makefile.in
sim/ucsim/cmd.src/bp.cc
sim/ucsim/cmd.src/clean.mk
sim/ucsim/cmd.src/cmdset.cc
sim/ucsim/cmd.src/cmdsetcl.h
sim/ucsim/cmd.src/cmdutil.cc
sim/ucsim/cmd.src/cmdutil.h
sim/ucsim/cmd.src/conf.mk
sim/ucsim/cmd.src/get.cc
sim/ucsim/cmd.src/info.cc
sim/ucsim/cmd.src/infocl.h
sim/ucsim/cmd.src/newcmd.cc
sim/ucsim/cmd.src/newcmdcl.h
sim/ucsim/cmd.src/set.cc
sim/ucsim/cmd.src/syntax.cc
sim/ucsim/cmd.src/syntaxcl.h
sim/ucsim/cmd.src/timer.cc
sim/ucsim/configure
sim/ucsim/configure.in
sim/ucsim/s51.src/cmd.cc
sim/ucsim/s51.src/cmd51.cc
sim/ucsim/s51.src/cmd_brk.cc
sim/ucsim/s51.src/dump.cc
sim/ucsim/s51.src/dump.h
sim/ucsim/s51.src/go.cc
sim/ucsim/s51.src/set.cc
sim/ucsim/s51.src/show.cc
sim/ucsim/s51.src/uc51.cc
sim/ucsim/s51.src/where.cc
sim/ucsim/sim.src/option.cc
sim/ucsim/sim.src/optioncl.h
sim/ucsim/sim.src/sim.cc
sim/ucsim/sim.src/simcl.h
sim/ucsim/sim.src/uc.cc

index aa0499977881eca251df814088febe93466d61df..4381ddad7a48f443c246918459a2c302dadc2450 100644 (file)
@@ -1 +1 @@
-0.2.37
+0.2.38-pre1
index 123456898aec0269d98b129927594d8f3679eb62..d1cefecce866cd43ea2f048532c9a98cef962f4a 100644 (file)
@@ -43,7 +43,7 @@ OBJECTS         = savr.o glob.o \
 
 AVRASM         = tavrasm
 TEST_OBJ       = test_bit.hex test_dis.hex test_mov.hex test_jmp.hex \
-                 test_arith.hex
+                 test_arith.hex test_call.hex
 
 
 # Compiling entire program or any subproject
index 24bc86ee5074fe6fa1519ddb7a67eac7ba980a1d..8d43b88f05d4bdd1c8717ea3c22c333fa88f6dbe 100644 (file)
@@ -23,5 +23,5 @@
   virtual int dec_Rd(t_mem code);
   virtual int mul_Rd_Rr(t_mem code);
   virtual int adiw_Rdl_K(t_mem code);
-
+  virtual int sbiw_Rdl_K(t_mem code);
 /* End of avr.src/arith_cl.h */
index 11f7e1681835619bab9a07445bba754c489fc679..566797d0a31ba4febc015671b7bb7978d34aa310 100644 (file)
@@ -29,23 +29,153 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "regsavr.h"
 
 
+/*
+ * Compare with Immediate
+ * CPI Rd,K 16<=d<=31, 0<=K<=255
+ * 0011 KKKK dddd KKKK
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::cpi_Rd_K(t_mem code)
 {
+  t_addr d;
+  t_mem D, K, result, res;
+
+  d= 16+(code&0xf0)>>4;
+  K= (code&0xf) | ((code&0xf00)>>8);
+  D= ram->read(d);
+
+  if (K & 0x80)
+    K|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  t_mem sreg= ram->get(SREG);
+  (signed)result= (signed)D-(signed)K;
+  res= result & 0xff;
+  
+  sreg= sreg & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_C|BIT_Z);
+  if (0x08 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~K)&(~res)) | ((~D)&K&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  if (0x80 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
 
+/*
+ * Substract Immediate with Carry
+ * SBCI Rd,K 16<=d<=31, 0<=K<=255
+ * 0100 KKKK dddd KKKK
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::sbci_Rd_K(t_mem code)
 {
+  t_addr d;
+  t_mem D, K, result, res;
+
+  d= 16+(code&0xf0)>>4;
+  K= (code&0xf) | ((code&0xf00)>>8);
+  D= ram->read(d);
+
+  if (K & 0x80)
+    K|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  t_mem sreg= ram->get(SREG);
+  (signed)result= (signed)D-(signed)K-(sreg&BIT_C)?1:0;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  sreg= sreg & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_C);
+  if (0x08 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~K)&(~res)) | ((~D)&K&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (res)
+    sreg&= ~BIT_Z;
+  if (0x80 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
 
+/*
+ * Substract Immediate
+ * SUBI Rd,K 16<=d<=31, 0<=K<=255
+ * 0101 KKKK dddd KKKK
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::subi_Rd_K(t_mem code)
 {
+  t_addr d;
+  t_mem D, K, result, res;
+
+  d= 16+(code&0xf0)>>4;
+  K= (code&0xf) | ((code&0xf00)>>8);
+  D= ram->read(d);
+
+  if (K & 0x80)
+    K|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  (signed)result= (signed)D-(signed)K;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  t_mem sreg= ram->get(SREG) & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  if (0x08 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~K)&(~res)) | ((~D)&K&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  if (0x80 & (((~D)&K) | (K&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
@@ -85,16 +215,103 @@ cl_avr::fmulsu_Rd_Rr(t_mem code)
 }
 
 
+/*
+ * Compare with Carry
+ * CPC Rd,Rr 0<=d<=31, 0<=r<=31
+ * 0000 01rd dddd rrrr
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::cpc_Rd_Rr(t_mem code)
 {
+  t_addr r, d;
+  t_mem R, D, result, res;
+
+  d= (code&0x1f0)>>4;
+  r= ((code&0x200)>>5)|(code&0xf);
+  R= ram->read(r);
+  D= ram->read(d);
+  if (R & 0x80)
+    R|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  t_mem sreg= ram->get(SREG);
+  (signed)result= (signed)D-(signed)R-(sreg&BIT_C)?1:0;
+  res= result & 0xff;
+  
+  sreg= sreg & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_C);
+  if (0x08 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~R)&(~res)) | ((~D)&R&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (res)
+    sreg&= ~BIT_Z;
+  if (0x80 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
 
+/*
+ * Substract with Carry
+ * SBC Rd,Rr 0<=d<=31, 0<=r<=31
+ * 0000 10rd dddd rrrr
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::sbc_Rd_Rr(t_mem code)
 {
+  t_addr r, d;
+  t_mem R, D, result, res;
+
+  d= (code&0x1f0)>>4;
+  r= ((code&0x200)>>5)|(code&0xf);
+  R= ram->read(r);
+  D= ram->read(d);
+  if (R & 0x80)
+    R|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  t_mem sreg= ram->get(SREG);
+  (signed)result= (signed)D-(signed)R-(sreg&BIT_C)?1:0;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  sreg= sreg & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_C);
+  if (0x08 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~R)&(~res)) | ((~D)&R&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (res)
+    sreg&= ~BIT_Z;
+  if (0x80 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
@@ -151,16 +368,101 @@ cl_avr::add_Rd_Rr(t_mem code)
 }
 
 
+/*
+ * Compare
+ * CP Rd,Rr 0<=d<=31, 0<=r<=31
+ * 0001 01rd dddd rrrr
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::cp_Rd_Rr(t_mem code)
 {
+  t_addr r, d;
+  t_mem R, D, result, res;
+
+  d= (code&0x1f0)>>4;
+  r= ((code&0x200)>>5)|(code&0xf);
+  R= ram->read(r);
+  D= ram->read(d);
+  if (R & 0x80)
+    R|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  (signed)result= (signed)D-(signed)R;
+  res= result & 0xff;
+  
+  t_mem sreg= ram->get(SREG) & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  if (0x08 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~R)&(~res)) | ((~D)&R&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  if (0x80 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
 
+/*
+ * Substract without Carry
+ * SUB Rd,Rr 0<=d<=31, 0<=r<=31
+ * 0001 10rd dddd rrrr
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::sub_Rd_Rr(t_mem code)
 {
+  t_addr r, d;
+  t_mem R, D, result, res;
+
+  d= (code&0x1f0)>>4;
+  r= ((code&0x200)>>5)|(code&0xf);
+  R= ram->read(r);
+  D= ram->read(d);
+  if (R & 0x80)
+    R|= ~0xff;
+  if (D & 0x80)
+    D|= ~0xff;
+  (signed)result= (signed)D-(signed)R;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  t_mem sreg= ram->get(SREG) & ~(BIT_H|BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  if (0x08 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_H;
+  int n= 0, v= 0;
+  if (0x80 & ((D&(~R)&(~res)) | ((~D)&R&res)))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  if (0x80 & (((~D)&R) | (R&res) | (res&(~D))))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
   return(resGO);
 }
 
@@ -217,16 +519,90 @@ cl_avr::adc_Rd_Rr(t_mem code)
 }
 
 
+/*
+ * One's Complement
+ * COM Rd 0<=d<=31
+ * 1001 010d dddd 0000
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::com_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  result= ~D;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  t_mem sreg= ram->get(SREG);
+  if (!res)
+    sreg|= BIT_Z;
+  else
+    sreg&= ~BIT_Z;
+  sreg&= ~BIT_V;
+  if (res & 0x80)
+    sreg|= (BIT_N|BIT_S);
+  else
+    sreg&= ~(BIT_N|BIT_S);
+  sreg|= BIT_C;
+  ram->set(SREG, sreg);
+
   return(resGO);
 }
 
 
+/*
+ * Two's Complement
+ * NEG Rd 0<=d<=31
+ * 1001 010d dddd 0001
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::neg_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  result= (~D)+1;
+  res= result & 0xff;
+  ram->write(d, &res);
+  
+  t_mem sreg= ram->get(SREG);
+  if (res & (~d) & 0x08)
+    sreg|= BIT_H;
+  else
+    sreg&= ~BIT_H;
+  if (res > 0x80)
+    sreg|= BIT_S;
+  else
+    sreg&= ~BIT_S;
+  if (!res)
+    {
+      sreg|= BIT_Z;
+      sreg&= ~BIT_C;
+    }
+  else
+    {
+      sreg&= ~BIT_Z;
+      sreg|= BIT_C;
+    }
+  if (res == 0x80)
+    sreg|= BIT_V;
+  else
+    sreg&= ~BIT_V;
+  if (res & 0x80)
+    sreg|= (BIT_N);
+  else
+    sreg&= ~BIT_N;
+  ram->set(SREG, sreg);
+
   return(resGO);
 }
 
@@ -277,37 +653,202 @@ cl_avr::inc_Rd(t_mem code)
 }
 
 
+/*
+ * Arithmetic Shift Right
+ * ASR Rd 0<=d<=31
+ * 1001 010d dddd 0101
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::asr_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  t_mem sreg= ram->read(SREG) & ~(BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  int n=0, v= 0, c= 0;
+  if (D & 1)
+    {
+      sreg|= BIT_C;
+      c= 1;
+    }
+  result= D>>1;
+  if (result & 0x40)
+    result|= 0x80;
+  res= result & 0xff;
+  ram->write(d, &res);
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ c) & 1)
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  ram->write(SREG, &sreg);
   return(resGO);
 }
 
 
+/*
+ * Logical Shift Right
+ * LSR Rd 0<=d<=31
+ * 1001 010d dddd 0110
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::lsr_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code &0x1f0)>>4;
+  D= ram->read(d);
+  t_mem sreg= ram->read(SREG) & ~(BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  if (D & 1)
+    sreg|= (BIT_C|BIT_V|BIT_S);
+  result= D >> 1;
+  res= result & 0xff;
+  ram->write(d, &res);
+  if (!res)
+    sreg|= BIT_Z;
+  ram->write(SREG, &sreg);
   return(resGO);
 }
 
 
+/*
+ * Rotate Right trough Carry
+ * ROR Rd 0<=d<=31
+ * 1001 010d dddd 0111
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::ror_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  t_mem sreg= ram->read(SREG);
+  int oldc= sreg & BIT_C;
+  sreg= sreg & ~(BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  int n= 0, v= 0, c= 0;
+  if (D & 1)
+    {
+      sreg|= BIT_C;
+      c= 1;
+    }
+  result= (D >> 1) | oldc?0x80:0;
+  res= result & 0xff;
+  ram->write(d, &res);
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ c) & 1)
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  ram->write(SREG, &sreg);
   return(resGO);
 }
 
 
+/*
+ * Decrement
+ * DEC Rd 0<=d<=31
+ * 1001 010d dddd 1010
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::dec_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D, result, res;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  result= D-1;
+  res= result & 0xff;
+  ram->write(d, &res);
+
+  t_mem sreg= ram->get(SREG);
+  if (!res)
+    sreg|= BIT_Z;
+  else
+    sreg&= ~BIT_Z;
+  int n= 0, v= 0;
+  if (res & 0x80)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  else
+    sreg&= ~BIT_N;
+  if (D == 0x80)
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  else
+    sreg&= ~BIT_V;
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  else
+    sreg&= ~BIT_S;
+  ram->set(SREG, sreg);
+
   return(resGO);
 }
 
 
+/*
+ * Multiply
+ * MUL Rd,Rr 0<=d<=31, 0<=r<=31
+ * 1001 11rd dddd rrrr
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::mul_Rd_Rr(t_mem code)
 {
+  t_addr d, r;
+  t_mem D, R, result, resl, resh;
+
+  d= (code>>4) & 0x1f;
+  r= ((code&0x200)>>5) | (code&0xf);
+  D= ram->read(d);
+  R= ram->read(r);
+  result= R*D;
+  resl= result & 0xff;
+  resh= (result>>8) & 0xff;
+  ram->write(0, &resl);
+  ram->write(1, &resh);
+  t_mem sreg= ram->read(SREG) & ~BIT_C;
+  if (resh & 0x80)
+    sreg|= BIT_C;
+  ram->write(SREG, &sreg);
+  tick(1);
   return(resGO);
 }
 
@@ -361,4 +902,55 @@ cl_avr::adiw_Rdl_K(t_mem code)
 }
 
 
+/*
+ * Substract Immediate from Word
+ * SBIW Rdl,K dl={24,26,28,30}, 0<=K<=63
+ * 1001 0111 KK dd KKKK
+ *____________________________________________________________________________
+ */
+
+int
+cl_avr::sbiw_Rdl_K(t_mem code)
+{
+  t_addr dl;
+  t_mem D, K, result, res;
+
+  dl= 24+(2*((code&0x30)>>4));
+  K= ((code&0xc0)>>2)|(code&0xf);
+  D= ram->read(dl+1)*256 + ram->read(dl);
+  if (K & 0x20)
+    K|= ~0x3f;
+  if (D & 0x8000)
+    D|= ~0xffff;
+  (signed)result= (signed)D-(signed)K;
+  res= result & 0xffff;
+  t_mem resl= res&0xff, resh= (res>>8)&0xff;
+  ram->write(dl+1, &resh);
+  ram->write(dl, &resl);
+
+  t_mem sreg= ram->get(SREG) & ~(BIT_S|BIT_V|BIT_N|BIT_Z|BIT_C);
+  int n= 0, v= 0;
+  if (0x8000 & D & (~res))
+    {
+      sreg|= BIT_V;
+      v= 1;
+    }
+  if (res & 0x8000)
+    {
+      sreg|= BIT_N;
+      n= 1;
+    }
+  if ((n ^ v) & 1)
+    sreg|= BIT_S;
+  if (!res)
+    sreg|= BIT_Z;
+  if (0x8000 & res & (~D))
+    sreg|= BIT_C;
+  ram->set(SREG, sreg);
+  tick(1);
+
+  return(resGO);
+}
+
+
 /* End of avr.src/arith_inst.cc */
index 950bd824cbd5ac4f383d526e812437cb1d440f69..6e330f5bf0c2e352d6b8bc1ea04c5235b26b4a55 100644 (file)
@@ -53,6 +53,7 @@ cl_avr::cl_avr(class cl_sim *asim):
   cl_uc(asim)
 {
   type= CPU_AVR;
+  sleep_executed= 0;
 }
 
 int
@@ -84,7 +85,8 @@ cl_avr::get_mem_size(enum mem_class type)
     case MEM_IRAM: return(0x10000);
     default: return(0);
     }
- return(cl_uc::get_mem_size(type));
+  //return(0);
+  //return(cl_uc::get_mem_size(type));
 }
 
 int
@@ -471,6 +473,8 @@ cl_avr::exec_inst(void)
        return(ijmp(code));
       if ((code & 0xff00) == 0x9600)
        return(adiw_Rdl_K(code));
+      if ((code & 0xff00) == 0x9700)
+       return(sbiw_Rdl_K(code));
       switch (code & 0xfc00)
        {
        case 0x9000:
@@ -571,6 +575,91 @@ cl_avr::exec_inst(void)
 }
 
 
+/*
+ */
+
+int
+cl_avr::push_data(t_mem data)
+{
+  t_addr sp;
+  t_mem spl, sph;
+  
+  spl= ram->read(SPL);
+  sph= ram->read(SPH);
+  sp= 0xffff & (256*sph + spl);
+  ram->write(sp, &data);
+  sp= 0xffff & (sp-1);
+  spl= sp & 0xff;
+  sph= (sp>>8) & 0xff;
+  ram->write(SPL, &spl);
+  ram->write(SPH, &sph);
+  return(resGO);
+}
+
+int
+cl_avr::push_addr(t_addr addr)
+{
+  t_addr sp;
+  t_mem spl, sph, al, ah;
+  
+  spl= ram->read(SPL);
+  sph= ram->read(SPH);
+  sp= 0xffff & (256*sph + spl);
+  al= addr & 0xff;
+  ah= (addr>>8) & 0xff;
+  ram->write(sp, &ah);
+  sp= 0xffff & (sp-1);
+  ram->write(sp, &al);
+  sp= 0xffff & (sp-1);
+  spl= sp & 0xff;
+  sph= (sp>>8) & 0xff;
+  ram->write(SPL, &spl);
+  ram->write(SPH, &sph);
+  return(resGO);
+}
+
+int
+cl_avr::pop_data(t_mem *data)
+{
+  t_addr sp;
+  t_mem spl, sph;
+
+  spl= ram->read(SPL);
+  sph= ram->read(SPH);
+  sp= 256*sph + spl;
+  sp= 0xffff & (sp+1);
+  *data= ram->read(sp);
+  spl= sp & 0xff;
+  sph= (sp>>8) & 0xff;
+  ram->write(SPL, &spl);
+  ram->write(SPH, &sph);
+
+  return(resGO);
+}
+
+int
+cl_avr::pop_addr(t_addr *addr)
+{
+  t_addr sp;
+  t_mem spl, sph, al, ah;
+
+  spl= ram->read(SPL);
+  sph= ram->read(SPH);
+  sp= 256*sph + spl;
+  sp= 0xffff & (sp+1);
+  al= ram->read(sp);
+  sp= 0xffff & (sp+1);
+  ah= ram->read(sp);
+  *addr= ah*256 + al;
+  spl= sp & 0xff;
+  sph= (sp>>8) & 0xff;
+  ram->write(SPL, &spl);
+  ram->write(SPH, &sph);
+  
+  return(resGO);
+}
+
+
 /*
  * Set Z, N, V, S bits of SREG after logic instructions and some others
  */
index 34fdc3ed011c90fb179d644199274ce851aadae3..73e7f43f72a3cf0fc0bcf359332100d5784099e5 100644 (file)
@@ -40,6 +40,7 @@ class cl_avr: public cl_uc
 public:
   cl_mem *ram;
   cl_mem *rom;
+  int sleep_executed;
 public:
   cl_avr(class cl_sim *asim);
   virtual int init(void);
@@ -58,6 +59,11 @@ public:
 
   virtual int exec_inst(void);
 
+  virtual int push_data(t_mem data);
+  virtual int push_addr(t_addr addr);
+  virtual int pop_data(t_mem *data);
+  virtual int pop_addr(t_addr *addr);
+
   void set_zn0s(t_mem data);
 #include "arith_cl.h"
 #include "logic_cl.h"
index 32809dec91c63cf45920edab8f8226a4965d7f32..3e9382c9452e50ced52b8e345ecf27ea74752663 100644 (file)
@@ -46,16 +46,32 @@ cl_avr::nop(t_mem code)
 }
 
 
+/*
+ * Sleep
+ * SLEEP
+ * 1001 0101 100X 1000
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::sleep(t_mem code)
 {
+  sleep_executed= 1;
   return(resGO);
 }
 
 
+/*
+ * Watchdog Reset
+ * WDR
+ * 1001 0101 101X 1000
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::wdr(t_mem code)
 {
+  //FIXME
   return(resGO);
 }
 
index 4b300b3a50adbbff0857e1afc29d2c61a04d237b..706b6935a8ce8bc54baf765e67d038a86c28bee5 100644 (file)
@@ -43,6 +43,7 @@ cl_avr::ijmp(t_mem code)
 
   z= ram->get(ZH)*256 + ram->get(ZL);
   PC= ((PC & ~0xffff) | z) % rom->size;
+  //FIXME: analyze
   return(resGO);
 }
 
@@ -54,9 +55,26 @@ cl_avr::eijmp(t_mem code)
 }
 
 
+/*
+ * Indirect Call to Subroutine
+ * ICALL
+ * 1001 0101 XXXX 1001
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::icall(t_mem code)
 {
+  t_mem zl, zh;
+  t_addr z;
+  
+  push_addr(PC);
+  zl= ram->read(ZL);
+  zh= ram->read(ZH);
+  z= zh*256 + zl;
+  PC= (PC & ~0xffff) | (z & 0xffff);
+  //FIXME: analyze
+  tick(2);
   return(resGO);
 }
 
@@ -68,16 +86,43 @@ cl_avr::eicall(t_mem code)
 }
 
 
+/*
+ * Return from Subroutine
+ * RET
+ * 1001 0101 0XX0 1000
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::ret(t_mem code)
 {
+  t_addr a;
+
+  pop_addr(&a);
+  PC= a % rom->size;
+  tick(3);
   return(resGO);
 }
 
 
+/*
+ * Return from Interrupt
+ * RETI
+ * 1001 0101 0XX1 1000
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::reti(t_mem code)
 {
+  t_addr a;
+
+  pop_addr(&a);
+  PC= a % rom->size;
+  t_mem sreg= ram->read(SREG);
+  sreg|= BIT_I;
+  ram->write(SREG, &sreg);
+  tick(3);
   return(resGO);
 }
 
@@ -105,9 +150,26 @@ cl_avr::rjmp_k(t_mem code)
 }
 
 
+/*
+ * Relative Call to Subroutine
+ * RCALL k
+ * 1101 kkkk kkkk kkkk -1K<=k<=+1k
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::rcall_k(t_mem code)
 {
+  t_addr k;
+
+  push_addr(PC);
+  k= code & 0xfff;
+  if (k & 0x800)
+    k|= ~0xfff;
+  PC= (signed)PC + (signed)k;
+  PC= PC % rom->size;
+  tick(2);
+
   return(resGO);
 }
 
@@ -161,8 +223,7 @@ cl_avr::jmp_k(t_mem code)
 
   k= ((code&0x1f0)>>3)|(code&1);
   k= (k<<16)|fetch();
-  PC= k;
-  //FIXME: analyze
+  PC= k % rom->size;
   tick(2);
   return(resGO);
 }
@@ -183,7 +244,8 @@ cl_avr::call_k(t_mem code)
 
   k= (((code&0x1f0)>>3)|(code&1))*0x10000;
   k= k + fetch();
-
+  push_addr(PC);
+  PC= k % rom->size;
   tick(3);
   return(resGO);
 }
@@ -209,7 +271,7 @@ cl_avr::brbs_s_k(t_mem code)
     {
       if (code&0x200)
        k|= -128;
-      PC= (PC+k) % get_mem_size(MEM_ROM);
+      PC= (PC+k) % rom->size;
       tick(1);
     }
   return(resGO);
@@ -236,7 +298,7 @@ cl_avr::brbc_s_k(t_mem code)
     {
       if (code&0x200)
        k|= -128;
-      PC= (PC+k) % get_mem_size(MEM_ROM);
+      PC= (PC+k) % rom->size;
       tick(1);
     }
   return(resGO);
@@ -266,7 +328,7 @@ cl_avr::sbrc_Rr_b(t_mem code)
        i++;
       if (dt[i].mnemonic != NULL)
        {
-         PC= (PC + dt[i].length) % get_mem_size(MEM_ROM);
+         PC= (PC + dt[i].length) % rom->size;
          tick(1);
        }
       else
@@ -299,7 +361,7 @@ cl_avr::sbrs_Rr_b(t_mem code)
        i++;
       if (dt[i].mnemonic != NULL)
        {
-         PC= (PC + dt[i].length) % get_mem_size(MEM_ROM);
+         PC= (PC + dt[i].length) % rom->size;
          tick(1);
        }
       else
index b8271f5adc841c702997e5b7aa6e3ba0a809b42b..7ad3a005e975cd6895929c99d1f7b5314b95fdef 100644 (file)
@@ -411,9 +411,24 @@ cl_avr::ld_Rd_$X(t_mem code)
 }
 
 
+/*
+ * Pop Register from Stack
+ * POP Rd 0<=d<=31
+ * 1001 000d dddd 1111
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::pop_Rd(t_mem code)
 {
+  t_addr d;
+  t_mem D;
+
+  d= (code&0x1f0)>>4;
+  pop_data(&D);
+  ram->write(d, &D);
+  tick(1);
+  
   return(resGO);
 }
 
@@ -609,9 +624,24 @@ cl_avr::st_$X_Rr(t_mem code)
 }
 
 
+/*
+ * Push register on Stack
+ * PUSH Rr 0<=r<=31
+ * 1001 001d dddd 1111
+ *____________________________________________________________________________
+ */
+
 int
 cl_avr::push_Rr(t_mem code)
 {
+  t_addr d;
+  t_mem D;
+
+  d= (code&0x1f0)>>4;
+  D= ram->read(d);
+  push_data(D);
+  tick(1);
+
   return(resGO);
 }
 
index f092b65df356de2472a85cf30dd7ebdbe19440a3..9b3d7ca2532694abe368b450561a9aa6a21b1c75 100644 (file)
@@ -35,7 +35,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 int
 main(int argc, char *argv[])
 {
-  simulator= new cl_simavr(0, argc, argv);
+  simulator= new cl_simavr(argc, argv);
   simulator->init();
   simulator->main();
   delete simulator;
index b125f7d6e361de4007481e99ec54a7de4ead8c26..bb885512f3c4cfe422fa5c936443268de3aef947 100644 (file)
@@ -26,14 +26,80 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 /*@1@*/
 
 
+#include <ctype.h>
+
 #include "simavrcl.h"
 #include "avrcl.h"
 
 
-cl_simavr::cl_simavr(char *more_args, int iargc, char *iargv[]):
-  cl_sim(more_args, iargc, iargv)
+cl_simavr::cl_simavr(int iargc, char *iargv[]):
+  cl_sim("h", iargc, iargv)
 {}
 
+
+static void
+print_help(char *name)
+{
+  printf("%s: %s\n", name, VERSIONSTR);
+  printf("Usage: %s [-hHVvP] [-p prompt] [-t CPU] [-X freq[k|M]]\n"
+        "       [-c file] [-s file] [-S optionlist]"
+#ifdef SOCKET_AVAIL
+        " [-Z portnum]"
+#endif
+        "\n"
+        "       [files...]\n", name);
+  printf
+    (
+     "Options:\n"
+     "  -t CPU       Type of CPU: etc.\n"
+     "  -X freq[k|M] XTAL frequency\n"
+     "  -c file      Open command console on `file'\n"
+#ifdef SOCKET_AVAIL
+     "  -Z portnum   Use localhost:portnumber for command console\n"
+#endif
+     "  -s file      Connect serial interface to `file'\n"
+     "  -S options   `options' is a comma separated list of options\n"
+     "               according to serial interface. Know options are:\n"
+     "                  in=file   serial input will be read from file named `file'\n"
+     "                  out=file  serial output will be written to `file'\n"
+     "  -p prompt    Specify string for prompt\n"
+     "  -P           Prompt is a null ('\\0') character\n"
+     "  -V           Verbose mode\n"
+     "  -v           Print out version number\n"
+     "  -H           Print out types of known CPUs\n"
+     "  -h           Print out this help\n"
+     );
+}
+
+
+int
+cl_simavr::proc_arg(char optopt, char *optarg)
+{
+  switch (optopt)
+    {
+    
+    case 'h':
+      
+      print_help("savr");
+      exit(0);
+      break;
+    
+    case '?':
+
+      if (isprint(optopt))
+       fprintf(stderr, "Unknown option `-%c'.\n", optopt);
+      else
+       fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
+      return(1);
+      break;
+      
+    default:
+      // should never happen...
+      abort();
+    }
+}
+
+
 class cl_uc *
 cl_simavr::mk_controller(void)
 {
index b7e2af7815ae2dd719b948a9971364bc84f4f67d..34bbe94aaf1263d27c5d801893006fc6b9552c28 100644 (file)
@@ -34,7 +34,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 class cl_simavr: public cl_sim
 {
 public:
-  cl_simavr(char *more_args, int iargc, char *iargv[]);
+  cl_simavr(int iargc, char *iargv[]);
+  virtual int proc_arg(char optopt, char *optarg);
 
   virtual class cl_uc *mk_controller(void);
 };
diff --git a/sim/ucsim/avr.src/test_call.asm b/sim/ucsim/avr.src/test_call.asm
new file mode 100644 (file)
index 0000000..753a686
--- /dev/null
@@ -0,0 +1,14 @@
+       nop
+       ldi     r16,$ff
+       out     $3d,r16
+       ldi     r16,$01
+       out     $3e,r16
+       nop
+       call    sub1
+       nop
+
+sub1:  nop
+       ret
+       
+copyright:
+       .db     "(c) 2000 talker Bt."
index d673f9fd8225014fb78e9a791cf42659714024d5..3fbc039411e4a0255729eaf76b6bbcd35c7de767 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (@@F@@)
+ * Simulator of microcontrollers (cmd.src/@@F@@)
  *
  * Copyright (C) @@S@@,@@Y@@ Drotos Daniel, Talker Bt.
  * 
index 09344f23d3deaee55a4c115a4521ada871a0b589..da32d8bb8ca28dc6acd1c14dfd078cb0635c3e82 100644 (file)
@@ -1,5 +1,5 @@
 #
-# S51 mcs51/Makefile
+# ucsim cmd.src/Makefile
 #
 # (c) Drotos Daniel, Talker Bt. 1997
 #
@@ -114,4 +114,4 @@ checkconf:
          $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\
        fi
 
-# End of mcs51/Makefile.in
+# End of cmd.src/Makefile.in
index d926e3259beba358a85a4b95913d67818db70cb7..51c7ed68fd49a47140dc06ffab48fc6897e540d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (bp.cc)
+ * Simulator of microcontrollers (cmd.src/bp.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -116,4 +116,4 @@ cl_clear_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
 }
 
 
-/* End of bp.cc */
+/* End of cmd.src/bp.cc */
index 68b487238046bb81982d8db48dda658ec3b29bdf..490293453816534e5730d61e3776cf760c1080c5 100644 (file)
@@ -1,3 +1,7 @@
+#
+# ucsim cmd.src/clean.mk
+#
+
 # Deleting all files created by building the program
 # --------------------------------------------------
 clean:
@@ -21,3 +25,5 @@ mostlyclean: clean
 # everything deleted by distclean plus files created by bison, etc.
 # -----------------------------------------------------------------------
 realclean: distclean
+
+# End of cmd.src/clean.mk
index 68a8e1eff951cd2e0ba4b2d16a2e0aa37fceb19f..d9496996032c04cf267fb92f313c126693ccd085 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (cmdset.cc)
+ * Simulator of microcontrollers (cmd.src/cmdset.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -464,4 +464,4 @@ cl_kill_cmd::do_work(class cl_cmdline */*cmdline*/, class cl_console */*con*/)
 }
 
 
-/* End of cmdset.cc */
+/* End of cmd.src/cmdset.cc */
index b62026933e3269aa752841fe276182c95da85c41..fd2434323c26ef78feb0709a9a6e7fe8c5e09872 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (cmdsetcl.h)
+ * Simulator of microcontrollers (cmd.src/cmdsetcl.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -25,8 +25,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA. */
 /*@1@*/
 
-#ifndef CMDSETCL_HEADER
-#define CMDSETCL_HEADER
+#ifndef CMD_CMDSETCL_HEADER
+#define CMD_CMDSETCL_HEADER
 
 #include "newcmdcl.h"
 
@@ -337,4 +337,4 @@ public:
 
 #endif
 
-/* End of cmdsetcl.h */
+/* End of cmd.src/cmdsetcl.h */
index 90bb15dccc81539471f085050acac339873ece36..84c2be54a540b587798906983f8f75f59c517b0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (cmdutil.cc)
+ * Simulator of microcontrollers (cmd.src/cmdutil.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -86,18 +86,18 @@ make_server_socket(unsigned short int port)
  * Printing out an integer in binary format
  */
 
-void
-print_bin(long data, int bits, FILE *f)
+/*void
+print_bin(long data, int bits, class cl_console *con)
 {
   long mask= 1;
 
   mask= mask << ((bits >= 1)?(bits-1):0);
   while (bits--)
     {
-      fprintf(f, "%c", (data&mask)?'1':'0');
+      con->printf("%c", (data&mask)?'1':'0');
       mask>>= 1;
     }
-}
+}*/
 
 
 /*
@@ -283,4 +283,4 @@ proc_escape(char *string, int *len)
 }
 
 
-/* End of cmdutil.cc */
+/* End of cmd.src/cmdutil.cc */
index 8bc02d2a86207bfa0a6f3833eeaff44e937912d4..679e6967887268981d90802d58ce2a6018258a9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (cmdutil.h)
+ * Simulator of microcontrollers (cmd.src/cmdutil.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -25,8 +25,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA. */
 /*@1@*/
 
-#ifndef CMDUTIL_HEADER
-#define CMDUTIL_HEADER
+#ifndef CMD_CMDUTIL_HEADER
+#define CMD_CMDUTIL_HEADER
 
 #include "ddconfig.h"
 
@@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 
 extern int make_server_socket(unsigned short int port);
-extern void print_bin(long data, int bits, FILE *f);
+//extern void print_bin(long data, int bits, class cl_console *con);
 extern struct name_entry *get_name_entry(struct name_entry tabl[],
                                         char *name,
                                         class cl_uc *uc);
@@ -47,4 +47,4 @@ extern char *proc_escape(char *string, int *len);
 
 #endif
 
-/* End of cmdutil.h */
+/* End of cmd.src/cmdutil.h */
index 879e9bc8ad388e192c0c0849fde78cd7cba43a4f..4bb2a6e256a38379a2c8c146b4ab13bf591138c4 100644 (file)
@@ -1,4 +1,6 @@
 #
+# ucsim cmd.src/conf.mk
+#
 # Makefile targets to remake configuration
 #
 
@@ -7,4 +9,4 @@ freshconf: Makefile
 Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in
        cd $(PRJDIR) && $(SHELL) ./config.status
 
-# End of conf.mk
+# End of cmd.src/conf.mk
index ab2888bc29880365775614e5e501a9783be9c5c5..8fa1bb278efa9cb97032ec7782607ff38467f776 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (get.cc)
+ * Simulator of microcontrollers (cmd.src/get.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -76,4 +76,4 @@ cl_get_cmd::timer(class cl_cmdline *cmdline, class cl_console *con)
 }
 
 
-/* End of get.cc */
+/* End of cmd.src/get.cc */
index f53f8701cc5c2c0d9b1011b2da25f887afc01a46..f21fc9663c72b8760541a13d44c0aee57d913d3d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (info.cc)
+ * Simulator of microcontrollers (cmd.src/info.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -153,4 +153,4 @@ cl_info_hw_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
 }
 
 
-/* End of info.cc */
+/* End of cmd.src/info.cc */
index 5b3af267d88f4c4e557789807649969b90fc3efb..87d6501535e77a0d9d5c9b0ea64a6d1b5ab5dfe3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (infocl.h)
+ * Simulator of microcontrollers (cmd.src/infocl.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -25,8 +25,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA. */
 /*@1@*/
 
-#ifndef INFOCL_HEADER
-#define INFOCL_HEADER
+#ifndef CMD_INFOCL_HEADER
+#define CMD_INFOCL_HEADER
 
 #include "newcmdcl.h"
 
@@ -70,4 +70,4 @@ public:
 
 #endif
 
-/* End of infocl.h */
+/* End of cmd.src/infocl.h */
index a401bc54521fc19559d2c5442567286db10acda4..be85ad80a4c6812b773b93ee4b8130da4be15937 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (newcmd.cc)
+ * Simulator of microcontrollers (cmd.src/newcmd.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -1122,4 +1122,4 @@ cl_commander::proc_input(void)
 }
 
 
-/* End of newcmd.cc */
+/* End of cmd.src/newcmd.cc */
index 255a8578e732be7ca213e1ae1edaf60a66786015..19512133544c05360a379d45b96028f4ba2bd93c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (cmdcl.h)
+ * Simulator of microcontrollers (cmd.src/cmdcl.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -25,8 +25,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA. */
 /*@1@*/
 
-#ifndef CMDCL_HEADER
-#define CMDCL_HEADER
+#ifndef CMD_NEWCMDCL_HEADER
+#define CMD_NEWCMDCL_HEADER
 
 
 #include "ddconfig.h"
@@ -136,9 +136,11 @@ public:
 
 class cl_console: public cl_base
 {
+  friend class cl_commander;
+protected:
+  FILE *in, *out;
 public:
   class cl_sim *sim;
-  FILE *in, *out;
   char *last_command;
   int flags; // See CONS_XXXX
   char *prompt;
@@ -227,4 +229,4 @@ public:
 
 #endif
 
-/* End of cmdcl.h */
+/* End of cmd.src/cmdcl.h */
index 26ed424b04433819eb595842cf49c46268d09de0..0ea5509ecc701119c52ffa2125add55f4ede45d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (set.cc)
+ * Simulator of microcontrollers (cmd.src/set.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -70,4 +70,4 @@ cl_set_cmd::timer(class cl_cmdline *cmdline, class cl_console *con)
 }
 
 
-/* End of set.cc */
+/* End of cmd.src/set.cc */
index 76841e25d8f0adb5ddda0e78f8a63e29db7996a2..d99f09b5b2f285b8138ea49892ccd54be78d9b6a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (syntax.cc)
+ * Simulator of microcontrollers (cmd.src/syntax.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -28,4 +28,4 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 // local
 #include "syntaxcl.h"
 
-/* End of syntax.cc */
+/* End of cmd.src/syntax.cc */
index 57a2e0157372e9b3b061fca70e2cc889a2f89530..c49d047a35b19c1cd2ea45fcbc10d4af5790d6b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (syntaxcl.h)
+ * Simulator of microcontrollers (cmd.src/syntaxcl.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -25,9 +25,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA. */
 /*@1@*/
 
-#ifndef SYNTAXCL_HEADER
-#define SYNTAXCL_HEADER
+#ifndef CMD_SYNTAXCL_HEADER
+#define CMD_SYNTAXCL_HEADER
 
 #endif
 
-/* End of syntaxcl.h */
+/* End of cmd.src/syntaxcl.h */
index 51f88748d2d5537716e7fffd407a2347836a37b0..90f879608d7c4f48e125e54cb81ce954ac5655f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (timer.cc)
+ * Simulator of microcontrollers (cmd.src/timer.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -263,4 +263,4 @@ cl_timer_cmd::val(class cl_cmdline *cmdline, class cl_console *con)
 }
 
 
-/* End of timer.cc */
+/* End of cmd.src/timer.cc */
index 95b548d5e3374fc4cb06f78be28d86e752360e75..c32c027cccf6eccdafc270dea7a74eaa9d5515e0 100755 (executable)
@@ -2112,13 +2112,13 @@ fi
 
 
 
-echo $ac_n "checking for type of accept's length pointer parameter""... $ac_c" 1>&6
-echo "configure:2117: checking for type of accept's length pointer parameter" >&5
-if eval "test \"`echo '$''{'dxpc_cv_accept_length_type'+set}'`\" = set"; then
+echo $ac_n "checking for type of length pointer parameter of accept""... $ac_c" 1>&6
+echo "configure:2117: checking for type of length pointer parameter of accept" >&5
+if eval "test \"`echo '$''{'s51_cv_accept_length_type'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_CPPFLAGS="$CPPFLAGS"
-    dxpc_cv_accept_length_type=no
+    s51_cv_accept_length_type=no
     for ac_val in int size_t socklen_t; do
       CPPFLAGS="$ac_save_CPPFLAGS -DACCEPT_SOCKLEN_T=$ac_val"
       cat > conftest.$ac_ext <<EOF
@@ -2132,7 +2132,7 @@ struct sockaddr a; $ac_val len; accept (0, &a, &len);
 EOF
 if { (eval echo configure:2134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  dxpc_cv_accept_length_type=$ac_val; break
+  s51_cv_accept_length_type=$ac_val; break
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -2142,11 +2142,11 @@ rm -f conftest*
     CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-echo "$ac_t""$dxpc_cv_accept_length_type" 1>&6
+echo "$ac_t""$s51_cv_accept_length_type" 1>&6
 
-  if test $dxpc_cv_accept_length_type != no; then
+  if test $s51_cv_accept_length_type != no; then
     cat >> confdefs.h <<EOF
-#define ACCEPT_SOCKLEN_T $dxpc_cv_accept_length_type
+#define ACCEPT_SOCKLEN_T $s51_cv_accept_length_type
 EOF
 
   fi
index 579cad788e59118286d5439f763a2e9b9bf4f415..00c0b354b1b222a70bb474d7497e8a0eb9252044 100644 (file)
@@ -172,29 +172,28 @@ if test "$s51_cv_getcwd" = "yes"; then
   AC_DEFINE(GNU_GETCWD)
 fi
 
-AC_DEFUN(dxpc_ACCEPT_LENGTH_T,
- [AC_CACHE_CHECK([for type of accept's length pointer parameter],
-   dxpc_cv_accept_length_type,
+AC_DEFUN(s51_ACCEPT_LENGTH_T,
+ [AC_CACHE_CHECK([for type of length pointer parameter of accept],
+   s51_cv_accept_length_type,
    [ac_save_CPPFLAGS="$CPPFLAGS"
-    dxpc_cv_accept_length_type=no
+    s51_cv_accept_length_type=no
     for ac_val in int size_t socklen_t; do
       CPPFLAGS="$ac_save_CPPFLAGS -DACCEPT_SOCKLEN_T=$ac_val"
       AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/socket.h>],
         [struct sockaddr a; $ac_val len; accept (0, &a, &len);],
-        [dxpc_cv_accept_length_type=$ac_val; break])
+        [s51_cv_accept_length_type=$ac_val; break])
     done
     CPPFLAGS="$ac_save_CPPFLAGS"])
 
-  if test $dxpc_cv_accept_length_type != no; then
-    AC_DEFINE_UNQUOTED(ACCEPT_SOCKLEN_T, $dxpc_cv_accept_length_type,
-      [Define to be the type of accept's length parameter (without
-the \*').])
+  if test $s51_cv_accept_length_type != no; then
+    AC_DEFINE_UNQUOTED(ACCEPT_SOCKLEN_T, $s51_cv_accept_length_type,
+      [Define to be the type of length parameter of accept (without the \*').])
   fi
  ]
 )
 
-dxpc_ACCEPT_LENGTH_T
+s51_ACCEPT_LENGTH_T
 
 # Macro definitions
 ###################
index 5be88f2c223ecbee71191d79a6fcc46ec5140cfc..cf4af45445cd81eb41b9bd33e34e7a16dce57608 100644 (file)
@@ -94,9 +94,9 @@ cmd_get_option(char *cmd, class cl_uc *uc, class cl_sim *sim)
       if (!s ||
          !strcmp(s, o->id))
        {
-         fprintf(sim->cmd_out(), "%s ", o->id);
-         o->print(sim->cmd_out());
-         fprintf(sim->cmd_out(), " %s\n", o->help);
+         sim->cmd->printf("%s ", o->id);
+         o->print(sim->cmd->actual_console);
+         sim->cmd->printf(" %s\n", o->help);
        }
     }
   return(DD_FALSE);
@@ -116,12 +116,12 @@ cmd_set_option(char *cmd, class cl_uc *uc, class cl_sim *sim)
 
   if ((id= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Name of option has not given.\n");
+      sim->cmd->printf("Name of option has not given.\n");
       return(DD_FALSE);
     }
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Value has not given.\n");
+      sim->cmd->printf("Value has not given.\n");
       return(DD_FALSE);
     }
   for (i= 0; i < uc->options->count; i++)
index 5dd3c9390f6611ff0695177aee8eea1594389d48..8bc9bdbac5b49e93593c4d2f3183e7daea5387b8 100644 (file)
@@ -97,7 +97,7 @@ cl_51cons::interpret(char *cmd)
     i++;
   if (cmd_table[i].name == NULL)
     {
-      fprintf(sim->cmd_out(), "Unknown command.\n");
+      sim->cmd->printf("Unknown command.\n");
       if (last_command)
        {
          free(last_command);
index 0602cd49a4d75c159cf044127a4d22394346c6bf..700b4d162049260d0f6e2e0d56cc46ca87ce104d 100644 (file)
@@ -192,16 +192,16 @@ cmd_brk_dele(char *cmd, class t_uc51 *uc, class cl_sim *sim)
 
   if ((id= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Event has not given.\n");
+      sim->cmd->printf("Event has not given.\n");
       return(DD_FALSE);
     }
   if ((s= strtok(NULL, delimiters)) == NULL)
-    fprintf(sim->cmd_out(), "Address has not given.\n");
+    sim->cmd->printf("Address has not given.\n");
   else
     {
       addr= (uint)strtol(s, NULL, 0);
       if (uc->ebrk_at(addr, id) == NULL)
-       fprintf(sim->cmd_out(), "No %s breakpoint at %06x\n", id, addr);
+       sim->cmd->printf("No %s breakpoint at %06x\n", id, addr);
       else
        uc->rm_ebrk(addr, id);
     }
index 8ff7743f20811a7b17a3e0894beeae5489f1e60e..113183231b63de28572ad16837e5b5df5eb0b5ed 100644 (file)
@@ -46,7 +46,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 void
 dump_memory(cl_mem *mem,
-           t_addr *start, t_addr stop, int bpl, FILE *f,
+           t_addr *start, t_addr stop, int bpl, class cl_console *con,
            class cl_sim *sim)
 {
   int i;
@@ -54,7 +54,7 @@ dump_memory(cl_mem *mem,
   while ((*start <= stop) &&
         (*start < mem->size))
     {
-      sim->cmd->printf("%06x ", *start);
+      con->printf("%06x ", *start);
       for (i= 0; (i < bpl) &&
             (*start+i < mem->size) &&
             (*start+i <= stop);
@@ -62,20 +62,20 @@ dump_memory(cl_mem *mem,
        {
          char format[10];
          sprintf(format, "%%0%dx ", mem->width/4);
-         fprintf(f, format/*"%02x "*/, mem->get(*start+i));
+         con->printf(format/*"%02x "*/, mem->get(*start+i));
        }
       while (i < bpl)
        {
-         fprintf(f, "   ");
+         con->printf("   ");
          i++;
        }
       for (i= 0; (i < bpl) &&
             (*start+i < mem->size) &&
             (*start+i <= stop);
           i++)
-       fprintf(f, "%c",
-               isprint(mem->get(*start+i))?(char)mem->get(*start+i):'.');
-      fprintf(f, "\n");
+       con->printf("%c",
+                   isprint(mem->get(*start+i))?(char)mem->get(*start+i):'.');
+      con->printf("\n");
       (*start)+= bpl;
     }
 }
@@ -144,66 +144,68 @@ cmd_dump_port(char *cmd, class t_uc51 *uc, class cl_sim *sim)
 {
   uchar data;
 
+  if (sim->cmd->actual_console == 0)
+    return(DD_FALSE);
   data= uc->get_mem(MEM_SFR, P0);
   sim->cmd->printf("P0    ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->get_mem(MEM_SFR, P1);
   sim->cmd->printf("    P1    ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[0];
   sim->cmd->printf("Pin0  ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[1];
   sim->cmd->printf("    Pin1  ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[0] & uc->get_mem(MEM_SFR, P0);
   sim->cmd->printf("Port0 ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[1] & uc->get_mem(MEM_SFR, P1);
   sim->cmd->printf("    Port1 ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   sim->cmd->printf("\n");
 
   data= uc->get_mem(MEM_SFR, P2);
   sim->cmd->printf("P2    ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->get_mem(MEM_SFR, P3);
   sim->cmd->printf("    P3    ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[2];
   sim->cmd->printf("Pin2  ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[3];
   sim->cmd->printf("    Pin3  ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[2] & uc->get_mem(MEM_SFR, P2);
   sim->cmd->printf("Port2 ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c", data, data, isprint(data)?data:'.');
 
   data= uc->port_pins[3] & uc->get_mem(MEM_SFR, P3);
   sim->cmd->printf("    Port3 ");
-  print_bin(data, 8, sim->cmd_out());
+  sim->cmd->actual_console->print_bin(data, 8);
   sim->cmd->printf(" 0x%02x %3d %c\n", data, data, isprint(data)?data:'.');
 
   return(DD_FALSE);
@@ -243,7 +245,8 @@ cmd_dump_sfr(char *cmd, class t_uc51 *uc, class cl_sim *sim)
       }
   else
     // dump all
-    dump_memory(uc->mem(MEM_SFR), &start, 255, 16, sim->cmd_out(), sim);
+    dump_memory(uc->mem(MEM_SFR), &start, 255, 16, sim->cmd->actual_console,
+               sim);
   return(DD_FALSE);
 }
 
index 6350782e968615ea59e4afe068fef6775f1f802a..9d0319ce5bf0a5340a3bf39231b5cb85a5fabcd0 100644 (file)
@@ -38,7 +38,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 
 extern void dump_memory(cl_mem *mem, t_addr *start, t_addr stop,
-                       int bpl, FILE *f, class cl_sim *sim);
+                       int bpl, class cl_console *con,
+                       class cl_sim *sim);
 
 extern bool cmd_disass(char *cmd, class t_uc51 *uc, class cl_sim *sim);
 extern bool cmd_dump_port(char *cmd, class t_uc51 *uc, class cl_sim *sim);
index d7b3289ca7485df0a950c3a05cf71d20a3bd9d8d..704aa7dcc84239f41093df021da135f8b96ca067 100644 (file)
@@ -54,8 +54,7 @@ cmd_go(char *cmd, class t_uc51 *uc, class cl_sim *sim)
 
   if (sim->state & SIM_GO)
     {
-      fprintf(sim->cmd_out(),
-             "Execution is already running.\n");
+      sim->cmd->printf("Execution is already running.\n");
       return(0);
     }
   if ((start_str= strtok(NULL, delimiters)) != NULL)
@@ -68,15 +67,14 @@ cmd_go(char *cmd, class t_uc51 *uc, class cl_sim *sim)
     {
       if (!uc->inst_at(start) &&
          uc->debug)
-       fprintf(sim->cmd_out(),
-               "Warning: maybe not instruction at 0x%06lx\n", start);
+       sim->cmd->printf("Warning: maybe not instruction at 0x%06lx\n", start);
       uc->PC= start;
     }
   if (stop >= 0)
     {
       if (start == (t_addr)stop)
        {
-         fprintf(sim->cmd_out(), "Addresses must be different.\n");
+         sim->cmd->printf("Addresses must be different.\n");
          return(DD_FALSE);
        }
       if ((b= uc->fbrk_at(stop)))
@@ -200,15 +198,14 @@ cmd_pc(char *cmd, class t_uc51 *uc, class cl_sim *sim)
   if (p &&
       ((p == s) ||
        *p))
-    fprintf(sim->cmd_out(), "Wrong parameter, PC unchanged.\n");
+    sim->cmd->printf("Wrong parameter, PC unchanged.\n");
   else
     {
       if (pc >= EROM_SIZE)
        pc= 0;
       if (!uc->inst_at(pc) &&
          uc->debug)
-       fprintf(sim->cmd_out(),
-               "Warning: maybe not instruction at %06lx\n", pc);
+       sim->cmd->printf("Warning: maybe not instruction at %06lx\n", pc);
       uc->PC= pc;
       uc->print_disass(uc->PC, sim->cmd->actual_console);
     }
index d8bc2e3f634e4a07f7b6161680f2444f5b02d4e7..09a3deac44f52fd10a6e46c91cf6425739e61b33 100644 (file)
@@ -59,7 +59,7 @@ set_memory(cl_mem *mem, t_addr first,
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Address has not given.\n");
+      sim->cmd->printf("Address has not given.\n");
       return;
     }
   if (tabl)
@@ -72,28 +72,26 @@ set_memory(cl_mem *mem, t_addr first,
       if (p &&
          *p)
        {
-         fprintf(sim->cmd_out(), "Bad address.\n");
+         sim->cmd->printf("Bad address.\n");
          return;
        }
     }
   start= addr;
   if (start >= mem->size)
     {
-      fprintf(sim->cmd_out(),
-             "Address %ld(0x%lx) is bigger than %ld(0x%lx).\n",
-             start, start, mem->size-1, mem->size-1);
+      sim->cmd->printf("Address %ld(0x%lx) is bigger than %ld(0x%lx).\n",
+                      start, start, mem->size-1, mem->size-1);
       return;
     }
   if (!(start >= first))
     {
-      fprintf(sim->cmd_out(),
-             "Address %ld(0x%lx) is less than %ld(0x%lx).\n",
-             start, start, first, first);
+      sim->cmd->printf("Address %ld(0x%lx) is less than %ld(0x%lx).\n",
+                      start, start, first, first);
       return;
     }
   if ((s= strtok(NULL, " \t\v")) == NULL)
     {
-      fprintf(sim->cmd_out(), "Data has not given.\n");
+      sim->cmd->printf("Data has not given.\n");
       return;
     }
   while (s &&
@@ -105,7 +103,7 @@ set_memory(cl_mem *mem, t_addr first,
          if (p &&
              *p)
            {
-             fprintf(sim->cmd_out(), "Bad data %s\n", s);
+             sim->cmd->printf("Bad data %s\n", s);
              break;
            }
          mem->set(addr, data);
@@ -142,7 +140,7 @@ set_memory(cl_mem *mem, t_addr first,
        }
       s= strtok(NULL, " \t\v");
     }
-  dump_memory(mem, &start, addr-1, 16, sim->cmd_out(), sim);
+  dump_memory(mem, &start, addr-1, 16, sim->cmd->actual_console, sim);
 }
 
 
@@ -209,25 +207,25 @@ cmd_set_bit(char *cmd, class cl_uc *uc, class cl_sim *sim)
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Address has not given.\n");
+      sim->cmd->printf("Address has not given.\n");
       return(DD_FALSE);
     }
   if (!interpret_bitname(s, uc, &cell, &addr, &bitaddr, &bitmask, NULL))
     {
-      fprintf(sim->cmd_out(), "Bad address %s\n", s);
+      sim->cmd->printf("Bad address %s\n", s);
       return(DD_FALSE);
     }
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Data has not given.\n");
+      sim->cmd->printf("Data has not given.\n");
       return(DD_FALSE);
     }
   while (s)
     {
       if (!isdigit(*s))
        {
-         fprintf(sim->cmd_out(), "Bad data %s\n", s);
+         sim->cmd->printf("Bad data %s\n", s);
          return(DD_FALSE);
        }
       if (*s == '0')
@@ -254,26 +252,26 @@ cmd_set_port(char *cmd, class cl_uc *uc, class cl_sim *sim)
   
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Port number has not given.\n");
+      sim->cmd->printf("Port number has not given.\n");
       return(DD_FALSE);
     }
   port= strtol(s, &p, 0);
   if ((p && *p) ||
       (port > 3))
     {
-      fprintf(sim->cmd_out(), "Port number %s is wrong.\n", s);
+      sim->cmd->printf("Port number %s is wrong.\n", s);
       return(DD_FALSE);
     }
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Date has not given.\n");
+      sim->cmd->printf("Date has not given.\n");
       return(DD_FALSE);
     }
   data= strtol(s, &p, 0);
   if (p && *p)
     {
-      fprintf(sim->cmd_out(), "Data %s is wrong.\n", s);
+      sim->cmd->printf("Data %s is wrong.\n", s);
       return(DD_FALSE);
     }
   uc->port_pins[port]= data;
@@ -300,7 +298,7 @@ fill_memory(uchar *what, int size, int first, class cl_uc *uc,
       (start < 0) ||
       (start < first) ||
       (start >= size))
-    fprintf(sim->cmd_out(), "Start address %s is wrong.\n", s);
+    sim->cmd->printf("Start address %s is wrong.\n", s);
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     return;
@@ -308,13 +306,13 @@ fill_memory(uchar *what, int size, int first, class cl_uc *uc,
   if ((p && *p) ||
       (stop < start) ||
       (stop >= size))
-    fprintf(sim->cmd_out(), "Stop address %s is wrong.\n", s);
+    sim->cmd->printf("Stop address %s is wrong.\n", s);
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     return;
   data= strtol(s, &p, 0);
   if (p && *p)
-    fprintf(sim->cmd_out(), "Data %s is wrong.\n", s);
+    sim->cmd->printf("Data %s is wrong.\n", s);
   
   while (start <= stop)
     {
index ef29bcd5f0bd746b4568227ffc35b553b50cec37..7bf7f429bc9bee6718ea1ab1401c244c274c22a9 100644 (file)
@@ -328,17 +328,15 @@ cmd_show(char *cmd, class cl_uc *uc, class cl_sim *sim)
 
   if ((s= strtok(NULL, delimiters)) == NULL)
     {
-      fprintf(sim->cmd_out(), "Parameter is not given.\n");
+      sim->cmd->printf("Parameter is not given.\n");
       return(DD_FALSE);
     }
   if (*s == 'c')
-    {
-      fprintf(sim->cmd_out(), "%s\n", copying);
-    }
+    sim->cmd->printf("%s\n", copying);
   else if (*s == 'w')
-    fprintf(sim->cmd_out(), "%s\n", warranty);
+    sim->cmd->printf("%s\n", warranty);
   else
-    fprintf(sim->cmd_out(), "Unknown parameter.\n");
+    sim->cmd->printf("Unknown parameter.\n");
   return(DD_FALSE);
 }
 
index eab37892c9362e909d961be763e6f776bb4b9de9..b7b13a487a1d01ea8f497e1de9944de5f6177147 100644 (file)
@@ -405,7 +405,7 @@ t_uc51::print_regs(class cl_console *con)
   uchar data;
 
   start= sfr->get(PSW) & 0x18;
-  dump_memory(iram, &start, start+7, 8, sim->cmd_out(), sim);
+  dump_memory(iram, &start, start+7, 8, /*sim->cmd_out()*/con, sim);
   start= sfr->get(PSW) & 0x18;
   data= iram->get(iram->get(start));
   con->printf("%06x %02x %c",
index ba5d3b7d83edf9b80e990a96cda53725f018a088..ab305f31d45d904a174b76373549ae7e1135017d 100644 (file)
@@ -70,7 +70,7 @@ where_memory(cl_mem *mem, bool cs, class cl_sim *sim)
        found= str[i] == (cs?mem->get(start+i):toupper(mem->get(start+i)));
       if (found)
        {
-         dump_memory(mem, &tmp, start+len-1, 8, sim->cmd_out(), sim);
+         dump_memory(mem, &tmp, start+len-1, 8, sim->cmd->actual_console,sim);
          start+= len;
        }
       else
index 47cce11fe35ec8840ffb4de59755cfacb4200c03..ff151da1441a852491b3c47c577da8c3efd7a225 100644 (file)
@@ -70,12 +70,12 @@ cl_bool_opt::cl_bool_opt(bool *opt, char *Iid, char *Ihelp):
 {}
 
 void
-cl_bool_opt::print(FILE *f)
+cl_bool_opt::print(class cl_console *con)
 {
   if (*(bool *)option)
-    fprintf(f, "TRUE");
+    con->printf("TRUE");
   else
-    fprintf(f, "FALSE");
+    con->printf("FALSE");
 }
 
 bool
@@ -121,13 +121,13 @@ cl_cons_debug_opt::cl_cons_debug_opt(class cl_sim *Asim,
 }
 
 void
-cl_cons_debug_opt::print(FILE *f)
+cl_cons_debug_opt::print(class cl_console *con)
 {
   if (sim->cmd->actual_console &&
       sim->cmd->actual_console->flags & CONS_DEBUG)
-    fprintf(f, "TRUE");
+    con->printf("TRUE");
   else
-    fprintf(f, "FALSE");
+    con->printf("FALSE");
 }
 
 bool
index ded278d7808b522ed1ffe11ccdc5497962733efd..5345d322db5e02638cffb6789e21439467692645 100644 (file)
@@ -48,7 +48,7 @@ public:
   cl_option(void *opt, char *Iid, char *Ihelp);
   ~cl_option(void);
 
-  virtual void print(FILE *f)= 0;
+  virtual void print(class cl_console *con)= 0;
 
   virtual bool get_value(void)= 0;
 
@@ -62,7 +62,7 @@ class cl_bool_opt: public cl_option
 public:
   cl_bool_opt(bool *opt, char *Iid, char *Ihelp);
 
-  virtual void print(FILE *f);
+  virtual void print(class cl_console *con);
   virtual bool get_value(void);
   virtual void set_value(bool);
   virtual void set_value(char *s);
@@ -75,7 +75,7 @@ public:
 public:
   cl_cons_debug_opt(class cl_sim *Asim, char *Iid, char *Ihelp);
 
-  virtual void print(FILE *f);
+  virtual void print(class cl_console *con);
 
   virtual bool get_value(void);
 
index ed68c7524b51c3527eb31ad82105fd1c4ee05e88..836e4d420d524c21b251b025bcc792ee5e821dc4 100644 (file)
@@ -467,7 +467,7 @@ cl_sim::stop(int reason)
  * Obsolete methods for old commander
  */
 
-FILE *
+/*FILE *
 cl_sim::cmd_in(void)
 {
   if (!cmd ||
@@ -477,9 +477,9 @@ cl_sim::cmd_in(void)
     return(cmd->actual_console->in?cmd->actual_console->in:stdin);
   class cl_console *con= (class cl_console *)(cmd->cons->at(0));
   return(con->in?con->in:stdin);
-}
+}*/
 
-FILE *
+/*FILE *
 cl_sim::cmd_out(void)
 {
   if (!cmd ||
@@ -489,7 +489,7 @@ cl_sim::cmd_out(void)
     return(cmd->actual_console->out?cmd->actual_console->out:stdout);
   class cl_console *con= (class cl_console *)(cmd->cons->at(0));
   return(con->out?con->out:stdout);
-}
+}*/
 
 
 /*
index 042b080b58a81b48c4747a31f01d90bb026641f3..21a83a3db62194ae775aea367070722e2834de31 100644 (file)
@@ -88,9 +88,9 @@ public:
   virtual void stop(int reason);
 
   // Obsolete, for old commander
-public:
-  FILE *cmd_out(void);
-  FILE *cmd_in(void);
+  //public:
+  //FILE *cmd_out(void);
+  //FILE *cmd_in(void);
 };
 
 
index f128e8e7c5823521456470414dee5efdc66a5cd3..73ea3d20f2012cf057ecfca2d3897910eed7b541 100644 (file)
@@ -356,7 +356,10 @@ cl_uc::read_hex_file(const char *name)
   uchar low= 0, high;
 
   if (!name)
-    f= sim->/*FIXME*/cmd_in();
+    {
+      sim->cmd->printf("cl_uc::read_hex_file File name not specified\n");
+      return(-1);
+    }
   else
     if ((f= fopen(name, "r")) == NULL)
       {
@@ -426,18 +429,17 @@ cl_uc::read_hex_file(const char *name)
                  else
                    if (sim->get_iarg('V', 0) &&
                        rtyp != 1)
-                     fprintf(sim->cmd_out(),
-                             "Unknown record type %d(0x%x)\n", rtyp, rtyp);
+                     sim->cmd->printf("Unknown record type %d(0x%x)\n",
+                                      rtyp, rtyp);
                }
              else
                if (sim->get_iarg('V', 0))
-                 fprintf(sim->cmd_out(),
-                         "Checksum error (%x instead of %x) in record %ld.\n",
-                         chk, sum, recnum);
+                 sim->cmd->printf("Checksum error (%x instead of %x) in "
+                                  "record %ld.\n", chk, sum, recnum);
            }
          else
            if (sim->get_iarg('V', 0))
-             fprintf(sim->cmd_out(), "Read error in record %ld.\n", recnum);
+             sim->cmd->printf("Read error in record %ld.\n", recnum);
        }
     }
   if (get_mem_width(MEM_ROM) > 8 &&
@@ -447,7 +449,7 @@ cl_uc::read_hex_file(const char *name)
   if (name)
     fclose(f);
   if (sim->get_iarg('V', 0))
-    fprintf(sim->cmd_out(), "%ld records have been read\n", recnum);
+    sim->cmd->printf("%ld records have been read\n", recnum);
   analyze(0);
   return(written);
 }