1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Please, I really need your help. Branch command...

Discussion in 'Assembly Language Programming (ALP) Forum' started by kaja_love, Mar 11, 2007.

  1. kaja_love

    kaja_love New Member

    Joined:
    Mar 11, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    greetings


    I've quit highschool few years ago and now I decided to finish it. So I'm learning stuff by myself at home and then go and take exams.

    Even though the purpose of a text book I'm using is not to teach us how to write anything more advanced than the most basic programs, book is still useless. It only explains each command very briefly and that's it. No examples, nada...

    The following questions are all related to Motorola 6803.
    When I talk about C ( carry ), V ( overflow ), Z (Zero) and N ( negative ) flags, I'm reffering to the flags in CCR register.


    1) In assembly command BGE can give you IF..THEN.. statement.


    Code:
    BGE 40 -->PC gets increased 42 by if N != V. 
                   But if N==V then PC gets increased by 2.
    
    - So if signed number overflows and if this number is also positive, then PC will be increased by 40.

    - But if number doesn't overflow ( V = 0 ) and if number is positive ( N = 0 ) OR if number overflows ( N = 1 ) and if number is also negative ( N = 1 ), then PC gets increased by 2?!
    I don't follow this logic.



    Can you show me an example(s) of condition we must include into "if ( condition ) then.." statement using BGE 40 command:

    a) What kind of IF ( CONDITION ) THEN .. statement would be TRUE and would fulfill the following criteria:

    * signed number overflows ( V = 1 ) and is also positive ( N = 0 )



    b) Can you show me an example of IF ( CONDITION ) THEN conditional statement, that would be FALSE and would fulfill the following criteria:

    * number doesn't overflow ( V = 0 ) and number is positive ( N = 0 )

    OR

    * number overflows( V = 1 ) and number is also negative ( N = 1 )


    I just can't figure out "why N flag must not be equal to V flag" relation.





    2)
    BVS 40 --> PC increases by 42 if overflow happens( V = 1 ).

    Huh?! So if resulting value is either greater than 127 or smaller than -128, then statement is true?! Can you show me an example of this ( in both assembly and higher language code )?



    thank you
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Because when a negative number increases in magnitude (-1 becomes -2), it doesn't get larger, it gets smaller. Increasing its magnitude until it overflows means it got 'less', not 'greater'.
     

Share This Page