Page 1 of 1

Author:  gtippery [ Tue Dec 17, 2013 1:48 pm ]
Post subject:  BCHG.L

        BCHG.L    Dn,Address


What is the range of values Dn can contain, and what happens if it's outside of that range?

Author:  profkelly [ Tue Dec 17, 2013 4:43 pm ]
Post subject:  Re: BCHG.L

The assembler does not permit a size code (.B or .L).

BCHG Dn,Address is always byte.
All others are long.


Author:  gtippery [ Wed Dec 18, 2013 9:47 am ]
Post subject:  Re: BCHG.L

These all assemble the same:
00001004  0543                      14              bchg    D2,D3
00001006  0579 00001020             15              bchg    D2,test
0000100C  0579 00001020             16              bchg.B  D2,test
00001012  0579 00001020             17              bchg    D2,test.L

00001020= 00000000 00000000         24  test        dc.l    0,0

For this code:
    ORG    $1000
START:                  ; first instruction of program

* Put program code here
   moveq   #0,D2
   move.l   D2,D3
   bchg   D2,D3
   bchg   D2,test
   ADDQ   #1,D2
   bne   loop

       SIMHALT             ; halt simulator

* Put variables and constants here
test   dc.l   0

       END    START        ; last line of source

as D2 increments, the bit changed walks across D3.L and wraps every 32 iterations. The bit changed in memory (test.L) wraps every 8 bits, affecting only a single byte. Sounds like the opposite of what you describe. Mardell's reference guide is not helpful. Easy 68K Quick Reference v2.1 seems to indicate that there are byte and longword versions for any destination mode.

Author:  profkelly [ Fri Dec 20, 2013 1:24 pm ]
Post subject:  Re: BCHG.L

Sorry, you are correct. I must have been low on caffeine when I responded the first time.

From a 68000 user guide:

    A bit in the destination operand is tested and the state of the specified bit is reflected in the Z condition code. After the test, the state of the specified bit is changed in the destination. If a data register is the destination, then the bit numbering is modulo 32 allowing bit manipulation on all bits in a data register. If a memory location is the destination, a byte is read from that location, the bit operation performed using the bit number modulo 8, and the byte written back to the location with zero referring to the least-significant bit. The bit number for this operation may be specified in two different ways:
    1. Immediate -- the bit number is specified in a second word of the instruction.
    2. Register -- the bit number is contained in a data register specified in the instruction.
    Condition Codes:
    N Not affected.
    Z Set if the bit tested is zero. Cleared otherwise.
    V Not affected.
    C Not affected.
    X Not affected.

Author:  gtippery [ Sat Dec 21, 2013 4:57 am ]
Post subject:  Re: BCHG.L

Thanks. I just found my 68K book and it agrees.

Author:  nkluge [ Mon Jan 27, 2014 2:44 pm ]
Post subject:  Re: BCHG.L

Dear Prof Kelly,

First of all: Thanks for that great tool.
I've a similar question: In the manual the BTST instruction is defined for a data length of byte or long. However, if I put

 BTST.B #0,d0

in the editor, the error message

ERROR: Invalid size code

appears. Am I using it wrong or is it a bug in the tool?

Best regards,
Norman Kluge

Author:  profkelly [ Tue Jan 28, 2014 4:30 pm ]
Post subject:  Re: BCHG.L

When the destination is a data register the size is always .L. This may be specified in the instruction or not with the same result. When the destination is memory the size is always .B. Again the size may be specified in the instruction or omitted with the same result:
00001000  0800 0000                  9      BTST.L  #0,D0
00001004  0800 0000                 10      BTST    #0,D0
00001008  0838 0000 1000            11      BTST.B  #0,$1000
0000100E  0838 0000 1000            12      BTST    #0,$1000

I'm delighted that EASy68K is a useful tool. :cool

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group