Hi Richard,

Richard Erlacher schrieb:
> What is it that you fellows use to simulate 805x ASM code?  I've found that 
> the simulator bundled with SDCC for Windows doesn't operate on code that 
> spans over 2 KB of memory, and I find I can't buy a "full" version of that 
> simulator, as the company that owns/owned it no longer exists.

Can you be more explicit? - which simulator?

> I'm trying to produce some precisely timed code that uses large tables, 
> don't want a compiler fiddling with my cycle counts, yet want, later, to be 
> able to incorporate this code with other code written in 'C'.

Don't know whether you like it/whether the proposal below meets
your requirements (could f.e. be good enough for 1-wire timing).
Somewhat ugly but would this do?



-------8<-----------------------------------------------------------------

/* 8051 timer example. noninvasive. no cumulative errors. untested. untested.
  */
#include <8052.h>

extern void timer0_init ( void );

#define DELTA_T_SHORT 32;
#define DELTA_T_LONG  48;

/* Macro loops while (signed char)(x - TL0) is >= 0
    So longest intervall is about 0x80 TL0 units.
    Macro introduces a jitter of about y instructions
    (z cycles), depending on memory area of (x). */
#define WAIT_EXPIRED_TL0(x) do{ while(!(0x80 & (char)((x)-TL0))) ; } while(0)


void main()
{
     unsigned char next_event_tl0;

     timer0_init();

     /* next event to happen DELTA_T_SHORT (in TL0 ticks) from NOW */
     next_event_tl0 = TL0 + DELTA_T_SHORT;

     while ( 1 )
     {
         WAIT_EXPIRED_TL0( next_event_tl0 );

         /* just to do something */
         P3_1 = 1;

         /* by adding to next_event_tl0 there is NO cumulative error.
            Things look nice on an oscilloscope even if a (short)
            IRQ interfered */
         next_event_tl0 += DELTA_T_SHORT;


         WAIT_EXPIRED_TL0( next_event_tl0 );
         P3_1 = 0;
         next_event_tl0 += DELTA_T_LONG;

         /* note, we have NOT reset or otherwise modified
            Timer0, or claimed usage of its overflow bit,
            so actually we are pretty harmless while still
            achieving "reasonable" accuracy. */
     }
}
------->8-----------------------------------------------------------------

-------8<-----------------------------------------------------------------
                             361 _main:
                             370 ;       timer.c:21: timer0_init();
    0000 12s00r00            371         lcall   _timer0_init
                             372 ;       timer.c:24: next_event_tl0 = TL0 + 
DELTA_T_SHORT;
    0003 74 20               373         mov     a,#0x20
    0005 25 8A               374         add     a,_TL0
    0007 FA                  375         mov     r2,a
                             376 ;       timer.c:28: WAIT_EXPIRED_TL0( 
next_event_tl0 );
    0008                     377 00101$:
    0008 EA                  378         mov     a,r2
    0009 C3                  379         clr     c
    000A 95 8A               380         subb    a,_TL0
    000C 30 E7 F9            381         jnb     acc.7,00101$
                             382 ;       timer.c:31: P3_1 = 1;
    000F D2 B1               383         setb    _P3_1
                             384 ;       timer.c:36: next_event_tl0 += 
DELTA_T_SHORT;
    0011 74 20               385         mov     a,#0x20
    0013 2A                  386         add     a,r2
    0014 FA                  387         mov     r2,a
                             388 ;       timer.c:39: WAIT_EXPIRED_TL0( 
next_event_tl0 );
    0015                     389 00107$:
    0015 EA                  390         mov     a,r2
    0016 C3                  391         clr     c
    0017 95 8A               392         subb    a,_TL0
    0019 30 E7 F9            393         jnb     acc.7,00107$
                             394 ;       timer.c:40: P3_1 = 0;
    001C C2 B1               395         clr     _P3_1
                             396 ;       timer.c:41: next_event_tl0 += 
DELTA_T_LONG;
    001E 74 30               397         mov     a,#0x30
    0020 2A                  398         add     a,r2
    0021 FA                  399         mov     r2,a
    0022 80 E4               400         sjmp    00101$
------->8-----------------------------------------------------------------


If you have to do cycle counting you are probably aware of
http://www.8052.com/users/disasm/
which can produce disassembled code along with the needed
instruction cycles (at least as long no prefetch/cache/spi
reads are involved).

Greetings,
Frieder

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to