Jump to content

c3po

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by c3po

  1. 19 hours ago, SvOlli said:

    I was faced with the problem of doing "R minus A", remembering of something I learned at school called "2s complement", I came up with this:

    
    EOR #$FF
    SEC
    ADC R

     

    I like it.

    You can still do a normal "A minus R" then complement it

    SEC
    SBC R
    EOR #$FF
    CLC
    ADC #01

    simplified to:

    CLC
    SBC R
    EOR #$FF

     

    which is useful if the carry is known to be cleared already.

    • Like 2
  2. Well, for the sake of hacks, I think in any long program it's a useful commodity to have a table like this:
     

    NumTab ; values 0-255
    	byte 0, 1, 2, 3, 4, 5, 6, 7
    	byte 8, 9, 10, 11, 12, 13, 14, 15
    	...
    	byte 248, 249, 250, 251, 252, 253, 254, 255


    This allows some interesting "new instructions":

    AND NumTab,X 	; A AND X
    
    ORA NumTab,X	; A OR X
    
    EOR NumTab,X	; A XOR X
    
    CMP NumTab,X	; CMP A with X
    
    CLC
    ADC NumTab,X	; A + X
    
    SEC
    SBC NumTab,X	; A - X
    
    LDY NumTab,X	; TXY
    
    LDX NumTab,Y	; TYX

     

     

    • Like 2
  3. In (timely) response to the initial post...

    lda work	; or ldy work
    clc		;    iny
    adc #1		;    tya
    eor work
    and #$0f
    eor work
    sta work

     

    and if you want any subset of contiguous bits you can do like that:

    lda work
    clc
    adc #4		; value of the lsb of the increment group
    eor work
    and #%00011100	; 3 bits (2...4)
    eor work
    sta work

    this will cycle bits 2...4

    • Thanks 1
×
×
  • Create New...