Author Topic: The new fork of HuC  (Read 14143 times)

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: The new fork of HuC
« Reply #105 on: November 07, 2016, 08:52:34 AM »
I didn't look over load_vram's second argument. Is it expecting a far_ptr as the argument type? Is it just a matter of the expression inside of the second argument not returning a far_ptr type?

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #106 on: November 07, 2016, 09:41:56 AM »
I didn't look over load_vram's second argument. Is it expecting a far_ptr as the argument type? Is it just a matter of the expression inside of the second argument not returning a far_ptr type?

Yes, it was all a problem with converting the second argument into a far_ptr type.

HuC needs to figure out which bank contains the address that you're trying to use for that 2nd parameter.

The code that it uses to figure that out is in arg_to_fptr().

Unfortunately, that code doesn't have full access to the all the syntactic information that it needs, and has to guess at which symbol the programmer wants to use as the base address just from looking at the I-CODE stream (the intermediate code representation).

The old HuC code that was in there couldn't handle the changes that Uli made in the expression parsing to produce a more-optimized I-CODE sequence.

I had to experiment to see what kinds of I-CODE sequences are now produced for the common types of C-usage that are going to be written by HuC programmers.

Then I had to figure out how to determine where the base address is, but still reject the common illegal-parameter errors that programmers often make.

The end-result is very similar to the original HuC code, but it's a bit more flexible in its ability to handle the different I-CODE streams that Uli's changes produce.

************

Even though there are still niggles like these to fix, I'm really impressed with all the work that Uli put into improving the HuC compiler.

It's pretty amazing that it's gone from using 54 different I-CODE functions in the old HuC to 94 now.

That's a lot of new codes to allow him to optimize the output that HuC generates!  :shock:

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #107 on: November 09, 2016, 04:41:16 PM »
Just in case I was actually spending some time looking at the HuC code generation to see what improvements Uli had made, then, well, I might just have noticed the processing for the "switch" statement.

WTF ... how come nobody has rewritten that darned thing in real assembly-language in the last decade ... it's a monstrosity!!!  ](*,)

I know that I've ragged on HuC a bit (well, too much, in truth) ... but really ... it's absolutely amazing the amount of work that Dave Shadoff and the others put into HuC; and their love of the PCE shows.

But someone should have re-written that crazy ___case function *years* ago!!!  :shock:


Gredler

  • Guest
Re: The new fork of HuC
« Reply #108 on: November 09, 2016, 04:43:41 PM »
Just in case I was actually spending some time looking at the HuC code generation to see what improvements Uli had made, then, well, I might just have noticed the processing for the "switch" statement.

WTF ... how come nobody has rewritten that darned thing in real assembly-language in the last decade ... it's a monstrosity!!!  ](*,)

I know that I've ragged on HuC a bit (well, too much, in truth) ... but really ... it's absolutely amazing the amount of work that Dave Shadoff and the others put into HuC; and their love of the PCE shows.

But someone should have re-written that crazy ___case function *years* ago!!!  :shock:



Sounds like a volunteer offer to me! :D

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #109 on: November 09, 2016, 04:52:19 PM »
Sounds like a volunteer offer to me! :D

Ah ... but if *I* do it, then you'd have to take all the other things that I'm interested in, like the small-but-incredibly-fast zero-page stack.

And that goes along with a re-arrangement of CPU register usage that will piss-off anyone that's got lots of inline assembly, or who calls assembly-language functions that they've written from HuC.  #-o

The benefits of rearranging the registers are too positive to ignore.  :wink:

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #110 on: November 11, 2016, 04:10:29 AM »
But someone should have re-written that crazy ___case function *years* ago!!!  :shock:

Sounds like a volunteer offer to me! :D

OK, you got me, it wasn't hard to change it from the new register layout to the old one, so here's a new build with the faster switch/case processing ...  :)

<Removed link to obsolete version.>

This build also fixes the compiler test suite that Uli added to deal with the changes that I've made in the last week, and all the tests pass (including today's changes to switch/case).

The changes are checked into github as usual.


I've rewritten the arg_to_fpt() function to deal with the optimizations that Uli made in the expression parsing.

It would be really nice to get some confirmation from HuC users that things are working (or not) with their projects.
« Last Edit: November 20, 2016, 01:57:09 AM by elmer »

Gredler

  • Guest
Re: The new fork of HuC
« Reply #111 on: November 11, 2016, 05:33:03 AM »
Wow - I was only teasing with my comment, but thank you for your time and energy to further improve the toolsets for us all. I hope this helps the programmers - I have still not gotten into the coding yet outside of a basic hello world :P

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #112 on: November 11, 2016, 09:01:22 AM »
Wow - I was only teasing with my comment, but thank you for your time and energy to further improve the toolsets for us all. I hope this helps the programmers - I have still not gotten into the coding yet outside of a basic hello world :P

I'd rewritten it anyway, and the old-register version is 99% the same as the new one ... so it worked out.  :wink:

I've been meaning to see how Uli's testsuite stuff worked, and it was a convenient time to figure that out, as well.

The real questions come moving forwards ... does anyone actually *want* a better performing version of HuC if it's not 100% identical to the current version (i.e. the register usage changes)?

Then there's the question of the current multiply function which uses the standard slow shift-then-add algorithm.

Would people be willing to give up 2KB of ROM space and 8-bytes of ZP for a super-fast version that's actually usable?

Most 6502 programmers just avoid things like multiplies and divides, so I'm not sure that it's worth it.  :-k

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: The new fork of HuC
« Reply #113 on: November 11, 2016, 09:58:12 AM »
Does HuC call a function to do the multiply? If so, maybe it can be handled via backend lib and passing a switch via command line (if <> defined, else - etc). But I think the 2k method should have been in there to begin with (such a brilliant method).

 Is the shift handling in HuC still really slow in the new build? The old build would call a function and do a loop - ugh. A little bit of bloat from a variable length macro in the trade off for speed would be worth it IMO.
 

DarkKobold

  • Hero Member
  • *****
  • Posts: 1200
Re: The new fork of HuC
« Reply #114 on: November 11, 2016, 10:21:02 AM »

The real questions come moving forwards ... does anyone actually *want* a better performing version of HuC if it's not 100% identical to the current version (i.e. the register usage changes)?

Would people be willing to give up 2KB of ROM space and 8-bytes of ZP for a super-fast version that's actually usable?



As a noob programmer, would I even notice these being used up? I'm pretty sure HuC's target audience would benefit more from increased performance, than they'd ever notice how you are changing these aspects.

Additionally, most HuC programmers don't set what is in the zero page versus not. I just declare my variables, and they go in ram wherever they go. Maybe more advanced HuC users, such as Arkhan or Cabbage have more input.
Hey, you.

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #115 on: November 11, 2016, 10:28:35 AM »
Does HuC call a function to do the multiply? If so, maybe it can be handled via backend lib and passing a switch via command line (if <> defined, else - etc). But I think the 2k method should have been in there to begin with (such a brilliant method).

Yep, there are both a mulu, and a muls function.

I agree, if you're going to use a darned multiply, then it *should* be fast, and it *could* probably be included conditionally.


Quote
Is the shift handling in HuC still really slow in the new build? The old build would call a function and do a loop - ugh. A little bit of bloat from a variable length macro in the trade off for speed would be worth it IMO.

Uli already inlined fast code for shifts by a constant 1, 2 and 8. Other immediate values drop through to a routine that's a streamlined version of the general variable-shift code.

So it's about as improved as it can be for the time being.

Seriously ... this new version of HuC has so many improvements over the old version that I'm kinda shocked that there seems to be so little interest in it.

If folks don't kick the tires and give it a spin, then we'll never find out if there's anything else broken like the farptr stuff was (but isn't anymore).

Gredler

  • Guest
Re: The new fork of HuC
« Reply #116 on: November 11, 2016, 10:36:29 AM »
DK I'll buy you a beer if you give it a whirl and post feedback about what differences you notice :P

DarkKobold

  • Hero Member
  • *****
  • Posts: 1200
Re: The new fork of HuC
« Reply #117 on: November 11, 2016, 10:42:39 AM »

If folks don't kick the tires and give it a spin, then we'll never find out if there's anything else broken like the farptr stuff was (but isn't anymore).


I'll give it a try this weekend. Did the conflict with squirrel get taken out, or do I still need to solve that before I can continue?
Hey, you.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: The new fork of HuC
« Reply #118 on: November 11, 2016, 01:20:29 PM »
Seriously ... this new version of HuC has so many improvements over the old version that I'm kinda shocked that there seems to be so little interest in it.
Yeah. I was impressed by the code generation for the a lot of stuff in Uli's updated HuC.

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: The new fork of HuC
« Reply #119 on: November 11, 2016, 01:44:09 PM »
Did the conflict with squirrel get taken out, or do I still need to solve that before I can continue?

Not by me ... I don't have an example that "breaks".

It should just take a trivial multi-file search-n-replace within the Squirrel directory (or wherever the files are).

If you don't have the tools to do that, then I can do it if you send me the files.