1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Can someone check this please

  1. Dec 29, 2009 #1
    1. The problem statement, all variables and given/known data

    If the content of d0 is $30 state in words what each of the following numbered instructions will do when placed immediately after the test instruction below
    tst d0


    2. Relevant equations

    a) bne fred
    b) beq fred
    c) bpl fred
    d) bmi fred


    3. The attempt at a solution

    a) bne fred = [go to label fred] [if d0] [not equal to $30]
    b) beq fred = [go to label fred] [if d0] [equal to $30]
    c) bpl fred = [go to label fred] [if d0] [ plus $30]
    d) bmi fred = [go to label fred] [if d0] [minus $30]

    example

    TST or tst direct against zero instruction.

    This is really the same as compare with zero

    tst <effective address>

    it subtracts 0 from a copy of the location specified and sets the condition flags accordingly.
    If the value to be tested is positive then +N –0 = +N or if negative –N –0= -N or if 0 then 0-0 =0

    tst d0 is d0 equal to 0, greater than zero or less than zero

    beq joe = [go to label joe] [if d0] [equal to 0]
    bgt dan= [go to label dan] [if d0] [greater than 0]
    blt ben= [go to label ben] [if d0] [less than 0]


    iam confused can someone help

    If the content of d0 is $30 state in words what each of the following numbered instruction pairs will do.

    a. cmpi #$30,d0
    beq dan

    b. cmp.l unknown,d0
    bne dan

    c. cmp.w d1,d0
    bgt dan
     
  2. jcsd
  3. Dec 29, 2009 #2

    Mark44

    Staff: Mentor

    These are not right. I'm a little rusty on Motorola 68000 assembly (which is what I think you are using), so I assume these instructions are inspecting the contents of the D0 register.
    bne <label> - means branch to <label> if d0 is not equal to zero.
    beq <label> - means branch to <label> if d0 is equal to zero.
    bpl <label> - means branch to <label> if d0 is positive (plus).
    bmi <label> - means branch to <label> if d0 is negative (minus).
    These all look fine to me.
    These compare instructions subtract the first operand from the second and set the N and Z flags as appropriate. For a, D0 - #$30 = what? Does control branch to label dan?
    For b, you don't know what value is in unknown, but whatever value is in this location, it is either >= $30 or < $30.
    For c, you don't know what is in D1, but you can say what will happen depending on what value is in that register.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook