/[VRac]/M6502/perl.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /M6502/perl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 38 by dpavlin, Mon Jul 30 23:28:25 2007 UTC revision 48 by dpavlin, Tue Jul 31 10:47:30 2007 UTC
# Line 5  Line 5 
5    
6  #if DEBUGF  #if DEBUGF
7  #define debugf(x)  do {         \  #define debugf(x)  do {         \
8            PerlIO_stdoutf("#> ");  \
9          PerlIO_stdoutf x ;      \          PerlIO_stdoutf x ;      \
10  } while (0)  } while (0)
11  #else  #else
# Line 46  void push_R(M6502 *R) { Line 47  void push_R(M6502 *R) {
47          XPUSHs( sv_2mortal( newSViv( R->S ) ) );          XPUSHs( sv_2mortal( newSViv( R->S ) ) );
48          XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) );          XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) );
49          PUTBACK;          PUTBACK;
50          call_pv("M6502::_push_R", G_DISCARD );          call_pv("M6502::push_R", G_DISCARD );
51          printf("push_R called\n");          printf("push_R called\n");
52          dump_R;          dump_R;
53          FREETMPS;          FREETMPS;
# Line 111  byte Op6502(register word Addr) { Line 112  byte Op6502(register word Addr) {
112          byte Op;          byte Op;
113          Op = mem(Addr);          Op = mem(Addr);
114          debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W));          debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W));
115            return Op;
116  }  }
117    
118  /** Loop6502() ***********************************************/  /** Loop6502() ***********************************************/
# Line 120  byte Op6502(register word Addr) { Line 122  byte Op6502(register word Addr) {
122  /** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the     **/  /** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the     **/
123  /** emulation loop.                                         **/  /** emulation loop.                                         **/
124  /************************************ TO BE WRITTEN BY USER **/  /************************************ TO BE WRITTEN BY USER **/
125    
126    int hw_int = INT_NONE;
127    
128  byte Loop6502(register M6502 *R) {  byte Loop6502(register M6502 *R) {
129          debugf(("Loop6502\n"));          debugf(("Loop6502\n"));
130          dump_R;          dump_R;
131          return INT_NONE;          return hw_int;
132  }  }
133    
134  /** Patch6502() **********************************************/  /** Patch6502() **********************************************/
# Line 170  int main(int argc, char **argv) { Line 175  int main(int argc, char **argv) {
175                  dSP;                  dSP;
176                  PUSHMARK(SP);                  PUSHMARK(SP);
177                  call_pv("Arch::init", G_DISCARD | G_NOARGS );                  call_pv("Arch::init", G_DISCARD | G_NOARGS );
178                    FREETMPS;
179                    LEAVE;
180    
181                  pull_R(R);                  int cycles = 1;
182                  printf("run CPU\n");                  while ( cycles ) {
183                  dump_R;                          dSP;
184                  //Run6502(R);                          PUSHMARK(SP);
185                  Exec6502(R, 10);                          call_pv("Arch::cli", G_DISCARD | G_NOARGS );
186                  dump_R;                          pull_R(R);
187                  push_R(R);                          FREETMPS;
188                  printf("end of CPU run\n");                          LEAVE;
189                            cycles = SvIV( get_sv("M6502::run_for", FALSE) );
190                            printf("run CPU for %d cycles\n", cycles);
191                            dump_R;
192                            //Run6502(R);
193                            Exec6502(R, cycles);
194                            dump_R;
195                            push_R(R);
196                            printf("end of %d cycles CPU run\n", cycles);
197                    }
198          }          }
199          free(R);          free(R);
200          perl_destruct(my_perl);          perl_destruct(my_perl);

Legend:
Removed from v.38  
changed lines
  Added in v.48

  ViewVC Help
Powered by ViewVC 1.1.26