simulavr-devel
[Top][All Lists]
Advanced

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

Re: [Simulavr-devel] OxFFFF opcodes


From: ken restivo
Subject: Re: [Simulavr-devel] OxFFFF opcodes
Date: Sat Sep 14 23:40:04 2002
User-agent: Mutt/1.3.25i

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

Works great. Much cleaner.

Thanks.

- -ken
- ---------
On Sat, Sep 14, 2002 at 11:42:46AM -0700, Theodore A. Roth wrote:
> Actually, I think the avr treats all unknown opcodes as a nop.
> 
> The attached patch handles this a bit more generically. Give it a try and if 
> you are satisfied that it solves your problem, I'll commit it later.
> 
> As for wrapping the PC back to 0x0000 on an overflow: I agree that 
> simulavr isn't doing the right thing right now, but that's a bit more 
> sticky to handle right. The problem is proper handling devices which have 
> more the 128K of insn space (thus PC is more than 16 bit). It's not 
> impossible to fix this, but I've got to think about it some more.
> 
> Ted Roth
> 
> On Fri, 13 Sep 2002, ken restivo wrote:
> 
> :)I've noticed that my "real" Atmel part seems to skip over 0xFFFF opcodes, 
> :)and just proceed on to the next instruction. I've noticed this in testing 
> :)my bootloader, and it also is hinted at in the Atmel databook, which 
> :)mandates the insertion of .word 0xFFFF after any SPM instruction 
> :)(to aid in pipelining, it says).
> :)
> :)I've added the attached patch to simulate this behaviour of the real part. 
> :)
> :)This is closer to what the actual chip does, but not 100% complete yet. 
> :)It looks like the real chip also will roll the PC off the end of the 
> :)flash and back to 0x0000 if a bug sends it into FFFF territory, i.e. 
> :)past the end of the program. Haven't found any documentation of that, 
> :)but so far it looks pretty reproductible.
> :)
> :)-ken
> :)

> 2002-09-14  Theodore A. Roth  <address@hidden>
> 
>       * src/avrcore.c, src/decoder.c, src/op_names.h:
>       Handle unknown opcodes as NOP's.
> 
> Index: src/avrcore.c
> ===================================================================
> RCS file: /cvsroot/simulavr/simulavr/src/avrcore.c,v
> retrieving revision 1.53
> diff -u -r1.53 avrcore.c
> --- src/avrcore.c     5 Sep 2002 06:41:08 -0000       1.53
> +++ src/avrcore.c     14 Sep 2002 18:35:51 -0000
> @@ -772,6 +772,9 @@
>  
>      op_handler = decode_opcode( opcode );
>  
> +    /* FIXME: This should go away, since the decode should never return NULL
> +       because unknown opcodes are now treated as NOP's. */
> +
>      if (op_handler == NULL)
>          return INVALID_OPCODE;
>  
> Index: src/decoder.c
> ===================================================================
> RCS file: /cvsroot/simulavr/simulavr/src/decoder.c,v
> retrieving revision 1.26
> diff -u -r1.26 decoder.c
> --- src/decoder.c     28 Aug 2002 18:53:40 -0000      1.26
> +++ src/decoder.c     14 Sep 2002 18:35:52 -0000
> @@ -3143,6 +3143,16 @@
>      return opcode_WDR;
>  }
>      
> +static int avr_op_UNKNOWN( AvrCore *core, word opcode )
> +{
> +    /*
> +     * An unknown opcode was seen. Treat it as a NOP, but return the UNKNOWN
> +     * so that the main loop can issue a warning.
> +     */
> +    avr_op_NOP( core, opcode );
> +    return opcode_UNKNOWN;
> +}
> +
>  
> /******************************************************************************\
>   *
>   * Decode an opcode into the opcode handler function.
> @@ -3328,7 +3338,7 @@
>          } /* default */
>      } /* first switch */
>  
> -    return NULL;
> +    return avr_op_UNKNOWN;
>  
>  } /* decode opcode function */
>  
> @@ -3372,7 +3382,7 @@
>  
>      func = *(global_opcode_lookup_table + opcode);
>  
> -    if (func == NULL)
> +    if (func == avr_op_UNKNOWN)
>          avr_warning("Unknown opcode: 0x%04x\n", opcode);
>  
>      return func;
> Index: src/op_names.h
> ===================================================================
> RCS file: /cvsroot/simulavr/simulavr/src/op_names.h,v
> retrieving revision 1.2
> diff -u -r1.2 op_names.h
> --- src/op_names.h    18 Mar 2002 23:48:23 -0000      1.2
> +++ src/op_names.h    14 Sep 2002 18:35:52 -0000
> @@ -149,6 +149,8 @@
>      opcode_RCALL,       /* 0xD000 - 1101 kkkk kkkk kkkk | RCALL */
>      opcode_RJMP,        /* 0xC000 - 1100 kkkk kkkk kkkk | RJMP */
>  
> +    opcode_UNKNOWN,
> +
>      NUM_OPCODE_HANLDERS,
>  
>      BREAK_POINT    = -2,


- -- 
- ---------------
The world's most affordable web hosting.
http://www.nearlyfreespeech.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9hADQe8HF+6xeOIcRAgxOAJ0UlEnu/ozbNAIryMWL/6pjmRYyHgCeNRQi
KaziVQxsd8JSZR0mG0qgVkY=
=8lZc
-----END PGP SIGNATURE-----




reply via email to

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