rotating HL left through Carry

2»

Comments

  • edited March 2012
    zxbruno wrote: »
    Although I have no idea what this topic is all about, it's nice to watch all these WOSsers compare code. Looks like you're having a lot of fun. :)

    You should all get together at a pub meet!

    What I like about these threads is that it seems that if you post any code, as well as a solution to your problem you'll also get as a bonus:

    (a) a version which uses the least memory
    (b) a version which uses the fewest T states..! :smile:

    I do find stuff like this useful, as I still haven't fully grasped "RL" vs "ADC", for example, that probably comes naturally for a lot of the programmers on here.
  • edited March 2012
    i know that contribution is over, but for curious people ;]

    with different aproach (but according to Battle Bunny's conditions - not using instructions like add hl,hl nor using memory arrays nor loops)
    it is possible to get 3T faster routine compared to Gedlion's #11 with the same byte size:
    ld      a,h
    rlca
    rlca  
    rlca
    rlca
    ld      h,a
    
    ld      a,l
    rlca
    rlca
    rlca
    rlca
    ld      l,a
    
    and     15
    xor     h  
    ld      h,a
    
    and     15 
    xor     l  
    ld      l,a
    
    and     15 
    xor     h  
    ld      h,a
    

    it is the same to antoniovillena's #29 - first part (which is faster and smaller than this one), but it doesn't use other register (B) to swap nibbles

    idea is:
    1) rotate H and L by 4 bits (each register on its own) - we start with H=ab L=cd and we get H=ba L=dc
    2) swap lower nibble of H and L - in three steps by famous xor way (a=a^c; c=a^c; a=a^c)
  • edited March 2012
    Great improvement. Altering the order (first nibble swap between bytes and second nibble rotation) you can save 4 tstates more:
            ld      a,l
            and     $f0
            xor     h  
            ld      h,a
            and     $f0
            xor     l  
            ld      l,a
            and     $f0
            xor     h  
            rlca
            rlca  
            rlca
            rlca
            ld      h,a
            ld      a,l
            rlca
            rlca
            rlca
            rlca
            ld      l,a
    
  • edited March 2012
    These things are tricky, which is the reason I took the time to prepare this table before starting to work on BIFROST*. I hope this table will be useful for someone else.

    Any chance of adding a function on the MISC page of the XLS version of that file so that a sequence of commands can be entered and then it uses VLOOKUP or MATCH or something to get the timings for the sequence and adds them up? Otherwise I'll do one sometime.
  • edited March 2012
    Any chance of adding a function on the MISC page of the XLS version of that file so that a sequence of commands can be entered and then it uses VLOOKUP or MATCH or something to get the timings for the sequence and adds them up? Otherwise I'll do one sometime.

    It's a good idea, but I don't think this will work so well, since it won't consider loops and you will have to type all instructions using "nn" instead of their actual parameters. Besides, I prefer all formats (XLS, PDF, HTML) to have exactly the same content, so I'm not planning to add this feature to the "official" version... but you are welcome to implement this yourself!
    Creator of ZXDB, BIFROST/NIRVANA, ZX7/RCS, etc. I don't frequent this forum anymore, please look for me elsewhere.
Sign In or Register to comment.