Recent

Author Topic: Computed goto  (Read 27810 times)

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: Computed goto
« Reply #45 on: December 04, 2016, 04:45:41 pm »
Thaddy:
You don't have to use the @ operator to get the address of the functions?

No, my version of fake6502 compiles in Delphi and with FPC in Delphi mode. Hence @ is superfluous.

Btw that has also step, etc and should also be usable as processor for the Ricoh processor.
It simply reads the bin from a bytestream and feeds it into the 6502. The processor itself is completely hidden in the implementation section.

And note that the compiler will indeed omit the stackframe for parameterless procedures (except maybe below -O2) because it can see that the local stack is never used..
That is good to know! :)

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: Computed goto
« Reply #46 on: September 28, 2018, 10:34:52 pm »
*bump*

1. I found this paper today that discusses interpreters with branch target predictions of modern hardware: https://hal.inria.fr/hal-01100647 (PDF)
Conclusion: if you have at least a Haswell CPU, the single point of dispatch (as with the top of case-of) is no longer much of a problem.

2. Matt Godbolt found that the number of entries in the Branch Target Buffer is 4096 - an impressive number, but keep in mind that every branch instruction, including if-then, takes up one entry. So it'll be full if you have >= 16 branches in every handler of a case-of with 256 cases; much less if you call many subroutines that use branches themselves or if the CPU core your thread runs on has to temporarily switch to another program.

 

TinyPortal © 2005-2018