patchSimulavr: an AVR simulator - Patches: patch #7079, Trace fixes and better memory...


You are not allowed to post comments on this tracker with your current authentication level.

patch #7079: Trace fixes and better memory access

Submitted by:  Petr Hluzin <petrh>
Submitted on:  Sun 31 Jan 2010 10:13:47 PM UTC  
Category:  bug fix Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  simulavrxx

Sat 19 Nov 2011 12:11:59 AM UTC, comment #2:

The patch is almost completely already incorporated in the current code. (Who did that? Me? When? I am weak with git.) I do not recall committing it.

The only remaining thing had been the removal of redundant HWStackSram::mem - which has just been committed:

Petr Hluzin <petrh>
Project Member
Sun 07 Feb 2010 07:20:47 PM UTC, comment #1:

Submitting version 2 of the patch.

Some incorrect assertions were removed. (It turned out to be legal to access registers and IO by a STD instruction.)

(file #19641)

Petr Hluzin <petrh>
Project Member
Sun 31 Jan 2010 10:13:47 PM UTC, original submission:

avr_op_ADIW::Trace( ) - did print register and the constant swapped (see ctor)
avr_op_BRBS::Trace( ) - printed bogus value as a destination (BRBS is 2B instruction)
avr_op_BSET::Trace( ) - printed using bogus index (get_reg_bit vs get_sreg_bit in ctor)
avr_op_CALL::Trace( ) - printed uninitialized value as address
avr_op_DEC::Trace( ) - printed bogus second argument
avr_op_LPM_Z::Trace() - did not print the written-to register

(Remaining changes are not user-visible.)

These were found while adjusting the code for different handling of memory access: reading/writing (after this patch) goes through device first. (I have to tinker with it and RWMemoryWithOwnMemory would be ugly.)


  • nicer ctors
  • easier peeking into simulavr while debugging
  • smaller DecodedInstruction instances (by ~3*4B)
  • reduced cache pressure
  • allows more efficient (cache friendly) storage of data memory (not yet in this patch)
  • less chance for wrong *::Trace() code or wrong X,Y,Z read


  • uglier *::operator()
  • 1 more hot field in AvrDevice
  • unaligned access to fields in instructions

HWStack::HWStack() has one less argument, all devices have to be trivially adjusted.

Some instructions still have HWSreg* status - we can get rid of that. (I do not need that though.)

The DecodedInstruction ctor still accepts the extra arguments after this patch.
I would remove them but one my diff tool gets confused by that many changes (yours may too).
I can prepare another patch that just removes the extra arguments if you like.

Petr Hluzin <petrh>
Project Member


Attached Files
file #19641:  memory-access-v2.patch added by petrh (105KiB - text/x-diff)
file #19586:  memory-access.patch added by petrh (105KiB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by tomk (Updated the item)
  • -email is unavailable- added by petrh (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    10/06/2014 tomk Open/ClosedOpen => Closed
    11/19/2011 petrh StatusNone => Done
    02/07/2010 petrh Attached File- => Added memory-access-v2.patch, #19641
    01/31/2010 petrh Attached File- => Added memory-access.patch, #19586

    Back to the top

    Powered by Savane 3.3