Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

68000 question

  • 21-04-2010 9:19pm
    #1
    Registered Users, Registered Users 2 Posts: 74 ✭✭


    Im teaching myself 68000 from a book and im having some trouble with the Branch Equal to instruction (BEQ) The book says its really a Branch on the Z-bit in the condition code register being set.

    In another part of the book it explains this as the source is taken away from the destination, and if the answer is zero , the Z bit is set.

    Here's the first few lines of the example.
    =================================================

    ReadAgain MOVE.B $00008000,D0
    MOVE.B D0,D1
    AND.B #%10000000,D0
    BEQ ReadAgain



    ==============================================

    This is just a small piece of the code.
    But my question is - what does the "BEQ ReadAgain" instruction do?
    What is equal to what?


Comments

  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    BEQ usually compare one register with another.

    So, in the code above, an AND function is being performed between the contents of D0 and the value 10000000 (em, or is it the contents of memory location 10000000? I am not 100% sure).

    So after the AND function is performed, the Branch if EQual jumps back to ReadAgain if the contents of D0 is the same as the contents of D1.

    (It's been a long, long time since I looked at this stuff, so above may not be 100% accurate)


  • Closed Accounts Posts: 1,397 ✭✭✭Herbal Deity


    Tom Dunne wrote: »
    em, or is it the contents of memory location 10000000? I am not 100% sure
    Nope. # means immediate value and % means binary format.

    OP, if AND.B #%10000000,D0 results in a 0, the Z bit in the CCR is set. When you call BEQ, it checks the Z bit and if set, branches to the label specified.


  • Registered Users, Registered Users 2 Posts: 354 ✭✭AndrewMc


    Obviously enough, the AND instructions ands #%10000000 and register D0 storing the result in D0. But as a less obvious side-effect, it also apparently sets the Z bit of the condition code register to 1 if the result of the AND was zero. BEQ will, as you said, jump to the given location if Z is 1.

    So it seems like this loop will continue until the top bit of D0 is 1. Since D0 came from a fixed memory address, I'm guessing this corresponds to some external device, and we're waiting for some input or status change?

    Found this by reading http://www.tigernt.com/onlineDoc/68000.pdf and http://www.vintagecomputermanuals.com/Retro%20Vintage%20Computer%20Sytem%20Manuals/Corvus%20Systems/Concept/Assembler%2068000%20Programmers%20Reference%20Manual.pdf

    [edit: late reply, Herbal got there first :)]


  • Registered Users, Registered Users 2 Posts: 74 ✭✭ArPharazon


    Yes that is correct AndrewMc , it was for modeling some device. Thanks everybody for the help. Its "clicked" with me.


Advertisement