Do you see any areas of improvement here?

Go To Last Post
64 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will try it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Running the test now.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Valgrind is an EXTENSIVE dev tool for PC software.
embedded too

Hardware and software tools for embedded developers | Static Analysis and Metrics Tools by Jack Ganssle

[near bottom]

...

I [Matthew MacClary] implement the core of my functionality for embedded systems as regular Linux programs, and then just pass a define variable to the compiler when I want to to pull in the microcontroller specific functionality. 

...

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to get a real idea of where the time is spend, you could show all the ASM code the AVR get through (single step) to emulate a simple NOP instruction.

 

If I would do it in ASM I would probably fix Y to PC and Z to a page with 256 ijmp so a nop would be

 

top:

LD r30,Y+

IJMP

 

 

;Code for  nop

rjmp top

 

So that is 6 clk

7 if r31 should be loaded.

 

 

   

Last Edited: Sat. May 23, 2020 - 11:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>One small test could be to place A in r16 , and perhaps F in r17

 

A bit faster...

 

moved A to R16 and	23803464422/9753.30/1e6 = 2.44055 MHz
flags to R17, also
unioned flags for
pop/push

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do you deal with all the flags? 

Other than P there is a close relation between the other flags on a 8080 and a AVR 

 

8080 : AVR

CY    : C

AC    : H

Z      : Z

S      : N

 

So it could make sense to get those from SREG if there is a safe way with your compiler. 

But they are placed different. So perhaps a look up with those where there is 0 on P's bit, and then lookup P and or it on (0 or 4 in LUT)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've gone back and forth with various things with them.  I've kept them as independent uint8_t's, I've tried dealing with them all together as a uint8_t using masks like flags|=_BV(CARRY_bp), and I've tried bit fields.  The zero and sign are easy enough to calculate, but I pull the parity from the table.  I also tried bringing in the zero/sign/parity all in from the table at once.  Now that I have them back in a union so they can be accessed as a byte or as a bitfield, I should probably try the combined parity-sign-zero table again and see if that shaves any time off.

 

Your point is very on spot, if one were coding an emulator like this in assembly, you can take advantage of the similarities between instruction types.  I was actually thinking this when I was writing it in C that not having things like flags exposed works against you when coding something like this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I once started to write an AVR simulator in AVR C (hopefully not as mad as that sounds - the real idea being able to fetch and execute AVR code from SRAM) and one if the reasons I gave up was trying to get the flag values from the run of the C simulated opcode into the virtual flag register. It's quite a challenge. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Absolutely clawson.  It is an odd thing because you always hear how close to the hardware that C is, but it is really abstracted from it when you think in terms of registers and flags.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know it's kind of old but here is a thread with some thoughts:

 

https://www.avrfreaks.net/commen...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had a Commodore PET with a whopping 8k of memory comprised of 64 2102 chips. It had a little bitty CRT built in (about 9 inch with green P1 phosphor), a built in cassette tape for saving and loading programs and a horrible "chicklet" keyboard. I put a fan inside it because the 2102 chips would get hot and then the display would go crazy and the computer locked up.

 

I had the "Programmer's Toolbox" rom for it - always used it's "renum" statement for Basic programming.

 

The good ole days(?)

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Was that a prototype ?

 

A normal PET used 16  6550 SRAM (or 2114.) 

 

And the later versions with DRAM (rare here in only 8 k ), used  8 2108 DRAM

(I remember that the board layout was so you could add more RAM, to prevent people from doing that they drilled holed in the PCB, so we soldered the extra chips on top of the existing chips (two pins bend out) and fished extra signals elsewhere. I can't remember exactly how it was, but I have done it a lot to make Atari ST520 to 1040)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

Pages