I thought following yesterday's post you might want to see what exclusive or on a TMS1000 is like. This is it :)
(It isn't the most incomprehensible thing I've ever written. That goes to my multi-way scrolling and sprite engine for the TI83 calculator - about half the code was self modifying just to make it run fast enough)
tcy XORResult ; clear XOR Result
tcy XORCounter ; set counter to 4
tcy XORResult ; shift the result one bit left.
tam ; store it back.
tcy XORNibble1 ; read Nibble 1
tcy XORNibble2 ; point at Nibble 2
tbit1 3 ; if bit 3 of Nibble 2 is set
br XOBit3Set ; add 8 to A, eg xor of MSB of Nibble
br XOBit3Unchanged ; because add = exor with no carry in
XOBit3Set: ; no carry in is why we cant just add
XOBit3Unchanged: ; bit 3 of A is XOR bit 3 of N1,N2.
alec 7 ; if it is set, set LSB of result
tcy XORResult ; this bit will be shifted into place
tcy XORNibble1 ; shift nibble 1 left
tcy XORNibble2 ; shift nibble 2 left
tcy XORCounter ; Decrement XOR Counter
tam ; write back
mnez ; check counter not zero
br ExclusiveOrLoop ; and keep going till all four bits.
tcy XORResult ; Load the result into A
Saturday, 29 June 2013
If you ever want an entertaining read and you are a 70s/80s computer geek, it's highly recommended.
Actually a lot of the book could be about me, (if you cross out where it says "Atari" and replace it with "Sharp MZ-80K and BBC Micro.", I never owned any Atari kit before an Atari ST.