Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial: How to put inline assembly functions into ZX Basic
#25
Up on WOS, someone schooled me.

This code will apparently mirror a byte as well. Still trying to get my head round the logic! (and if it works)

Code:
;17 bytes and 66 clock cycles
Reverse:
    ld b,a         ;b=ABCDEFGH
    rrca         ;a=HABCDEFG
    rrca         ;a=GHABCDEF
    xor b \ and %10101010 \ xor b     ;a=GBADCFEH
    ld b,a         ;b=GBADCFEH
    rrca         ;a=HGBADCFE
    rrca         ;a=EHGBADCF
    rrca         ;a=FEHGBADC
    rrca         ;a=CFEHGBAD
    xor b \ and %01100110 \ xor b     ;a=GFEDCBAH
    rrca         ;a=HGFEDCBA


n=0
n A B
0 0 0 -> 0 = B
0 0 1 -> 1 = B
0 1 0 -> 0 = B
0 1 1 -> 1 = B

n=1
1 0 0 -> 0 = A
1 0 1 -> 0 = A
1 1 0 -> 1 = A
1 1 1 -> 1 = A

a XOR b and n xor b


aaaaaaaa xor bbbbbbbb and 10101010 xor bbbbbbbb = abababab
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)