simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] 13-pre3 patch


From: ken restivo
Subject: Re: [Simulavr-devel] 13-pre3 patch
Date: Mon, 7 Jan 2002 09:29:01 -0800
User-agent: Mutt/1.3.25i

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

my apologies if this is a "repeat". i didn't see it come back on the list, 
guess it went into the bitbucket.

i was able to update to 13-pre3, no prob. great job on the build system, too, 
very clean.

but i found a strange bug.  this test program outputs the bytes 0, 0, 7, 0 to 
PORTC, when it actually should output 0, 0, 4, 0. 


/* test program for 4 != 7 bug */
#include <timer.h>
#include <io.h>
#include <pgmspace.h>

volatile int useless;

/****************
    PRINTUNSIGNED
    does unsigned hex. 
********************/
volatile void
printUnsigned(unsigned int x, unsigned char maxbuf)
{
    int xlen = 0;
    /* XXX volatile for debugging. so gcc -O3 doesn't remove it */
    volatile unsigned char realnum;
    do {
        realnum =  (x >> (xlen * 4)) & 0xf ;
        outp(realnum, PORTC);
        xlen++;
    } while( xlen < maxbuf);

} /* END PRINTUNSIGNED */

/************
*  MAIN
*************/
int
main( void )
{

    useless = 0x0400;

    outp(0xFF, DDRD);
    outp(0xFF, DDRC);

    printUnsigned(useless, 4);
    while(1);

    return(0);

} /* end main */

/* EOF */

an .avrgdbinit that i use to look at the variables is:
        set print pretty
        target remote localhost:1212
        load
        b printUnsigned
        display/x $sp
        display/x $pc
        c
        display realnum
        display xlen


the same routines (with outp replaced by printf's) does the expected behaviour 
when run on linux, but not in simulavr.


the damage seems to occur here:
       realnum =  (x >> (xlen * 4)) & 0xf ;
  7c:   8e 2f           mov r24, r30
  7e:   9f 2f           mov r25, r31
  80:   04 2e           mov r0, r20
  82:   02 c0           rjmp    .+4         ; 0x88
  84:   96 95           lsr r25
  86:   87 95           ror r24
  88:   0a 94           dec r0
  8a:   e2 f7           brpl    .-8         ; 0x84


i looked through the ror, lsr, dec, and brpl instructions in decoder.c and 
found nothing amiss. 

bizarre. any idea what is going on here? my apologies in advance if i'm just 
doing something stoopid.

- -ken

- -- 
- ------------------
One world. Many gods. Plenty for everyone.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8Odrbe8HF+6xeOIcRAotgAKDlLrDGdODiMBoHyZUTrp/Lvlm0wgCfbr3X
y0MkeZTdJkbt2kjzuKn53nM=
=nyiM
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]