Re: #define (from C) in Python

2009-11-15 Thread Santiago Romero
> Python IS slower than perl, especially since you are dealing with > objects. However, I'd suggest go the cPickle route - have a Z80Cpu > module, and its C equivalent, cZ80, and use that one if available. This > way, the emulator will be actually usable everywhere. Thanks for the advice but ...

Re: #define (from C) in Python

2009-11-15 Thread garabik-news-2005-05
Santiago Romero wrote: >> Hey, I got 100% with ASM ZX Spectrum emulator on a low end 386 :-) (I do >> not remember the CPU freqeuncy anymore, maybe 25MHz). > > Yes, in ASM a simple 25 or 33Mhz 386 computer was able to emulate > the > Spectrum. At least, under MSDOS, like did Warajevo, Z80, x128 a

Re: #define (from C) in Python

2009-11-13 Thread Rhodri James
On Fri, 13 Nov 2009 08:43:14 -, Ulrich Eckhardt wrote: Santiago Romero wrote: Well, In the above concrete example, that would work, but I was talking for multiple code lines, like: #define LD_r_n(reg) (reg) = Z80ReadMem(r_PC++) #define LD_rr_nn(reg) r_opl = Z80ReadMem(r_PC); r_PC++;

Re: #define (from C) in Python

2009-11-13 Thread Santiago Romero
> Hey, I got 100% with ASM ZX Spectrum emulator on a low end 386 :-) (I do > not remember the CPU freqeuncy anymore, maybe 25MHz). Yes, in ASM a simple 25 or 33Mhz 386 computer was able to emulate the Spectrum. At least, under MSDOS, like did Warajevo, Z80, x128 and "Spectrum" from Pedro Gimeno.

Re: #define (from C) in Python

2009-11-13 Thread garabik-news-2005-05
Santiago Romero wrote: > >> > #define STORE_nn_rr(dreg) \ >> >                         r_opl = Z80ReadMem(r_PC); r_PC++;\ >> >                         r_oph = Z80ReadMem(r_PC); r_PC++; \ >> >                         r_tmp = dreg; \ >> >                         Z80WriteMem((r_op),r_tmpl, regs); \

Re: #define (from C) in Python

2009-11-13 Thread Bearophile
Santiago Romero: >Obviously, I prefer to write well structured code but I had to sacrifize SIZE >by SPEED< In C99 you have "inline" (and gcc/gcc-llvm usually inline small functions anyway) that helps avoid many macros. >  Now I'm porting the emulator to a scripted language, so I need > even mo

Re: #define (from C) in Python

2009-11-13 Thread Santiago Romero
> > #define STORE_nn_rr(dreg) \ > >                         r_opl = Z80ReadMem(r_PC); r_PC++;\ > >                         r_oph = Z80ReadMem(r_PC); r_PC++; \ > >                         r_tmp = dreg; \ > >                         Z80WriteMem((r_op),r_tmpl, regs); \ > >                         Z80

Re: #define (from C) in Python

2009-11-13 Thread Ulrich Eckhardt
Santiago Romero wrote: > Well, In the above concrete example, that would work, but I was > talking for multiple code lines, like: > > > #define LD_r_n(reg) (reg) = Z80ReadMem(r_PC++) > > #define LD_rr_nn(reg) r_opl = Z80ReadMem(r_PC); r_PC++; \ > r_oph = Z80ReadMem(r_PC

Re: #define (from C) in Python

2009-11-12 Thread greg
TerryP wrote: If it's such a big hairy deal, just recompile a copy of the C Pre Processor to use something other then #, and hook it up to your python scripts in a pipe line from a shell wrapper. Or use a different preprocessor, such as m4, that doesn't clash with the # character. -- Greg -- h

Re: #define (from C) in Python

2009-11-12 Thread TerryP
If it's such a big hairy deal, just recompile a copy of the C Pre Processor to use something other then #, and hook it up to your python scripts in a pipe line from a shell wrapper. Personally, I'd rather have Lisps lambda or perls sub then Cs preprocessor, and even in those cases, Python suffices

Re: #define (from C) in Python

2009-11-12 Thread Stefan Behnel
Santiago Romero, 12.11.2009 18:23: > #define LD_r_n(reg) (reg) = Z80ReadMem(r_PC++) > > #define LD_rr_nn(reg) r_opl = Z80ReadMem(r_PC); r_PC++; \ > r_oph = Z80ReadMem(r_PC); r_PC++; \ > reg = r_op > > #define LOAD_r(dreg, saddreg) (dreg)=Z80Read

Re: #define (from C) in Python

2009-11-12 Thread Santiago Romero
On 12 nov, 18:16, Stefan Behnel wrote: > Santiago Romero, 12.11.2009 17:43: > > > Is there a Python version of C's language #define statements? > > > Example: > > > #define ReadMem( (x) )    memory[ (x) ] > > Yes: > >         ReadMem = memory.__getitem__ > > Stefan Well, In the above concrete e

Re: #define (from C) in Python

2009-11-12 Thread Stefan Behnel
Santiago Romero, 12.11.2009 17:43: > Is there a Python version of C's language #define statements? > > Example: > > #define ReadMem( (x) )memory[ (x) ] Yes: ReadMem = memory.__getitem__ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: #define (from C) in Python

2009-11-12 Thread Michele Simionato
On Nov 12, 5:43 pm, Santiago Romero wrote: > Is there a Python version of C's language #define statements? > > Example: > > #define ReadMem( (x) )    memory[ (x) ] > >  Instead of using a function, when you call to ReadMem(), the code is > INCLUDED, (no function is called, the "compiler" just subs

Re: #define (from C) in Python

2009-11-12 Thread Diez B. Roggisch
Santiago Romero schrieb: Is there a Python version of C's language #define statements? Example: #define ReadMem( (x) )memory[ (x) ] Instead of using a function, when you call to ReadMem(), the code is INCLUDED, (no function is called, the "compiler" just substitues the ReadMem( expression

#define (from C) in Python

2009-11-12 Thread Santiago Romero
Is there a Python version of C's language #define statements? Example: #define ReadMem( (x) )memory[ (x) ] Instead of using a function, when you call to ReadMem(), the code is INCLUDED, (no function is called, the "compiler" just substitues the ReadMem( expression ) with memory[ (expressio