views:

255

answers:

1

I'm using shift operations to divide a long word in register D3 by three and storing the result in memory address specified by A2:

Move.L  D1, D2, D3, -(SP)
        CLR.L   D5
        MOVE.B  #1, D4

Loop    LSR.L   D2, D3
        ROXR.L  #1,D5
        BCS     DONE
        SUBI.B  #1, D2
        BLT     Loop
        CLR.B   D4

DONE    MOVE.L  (SP)+, D3, D2, D1
        RTS

        END

Is this correct?

+4  A: 

Let's ask a couple of questions first:

  1. What is your assignment, really?
  2. If it's to implement division by hand, then you're taking a funny approach. If it's simply to divide by 3, why not use the divs (divide signed) instruction and be done with it?
  3. How come you don't do anything with the result?
  4. You're going to the trouble of saving and restoring registers d1-d3, but you're torching d4 and d5 - why is that?
  5. Do you understand the 68K's indirect addressing?
  6. Is the result expected to be a word or a long word?
plinth
I AM FINDING IT DIFFICULT TO UNDERSTAND mC68000 PROGRAMS, I HAVE BEEN WORKING ON THIS ALMOST ALL DAY. AND I AM GETTING CONFUSE. pLEASE IF YOU CAN HELP ME CURRECT IT, SO THAT I CAN COMPARE AND SEE WHAT IS THE CURRECT WAY TO DO IT.
kIngcross
Talk to your TA.
plinth
plinth...i understand that you knew it, but you didnt want to help. Is not that i didnt try to do the problem by myself but you are even making it difficult to get help from here. Most people are here to learn program....if everyone knew it, some people shouldn't come here then....thanks for you help
kIngcross
You joined SO today, you're asking in apparent desperation, you probably have an assignment that is due or overdue, you asked 4 SO questions in short order that indicate that you are far behind in understanding, you didn't even touch on any of the six questions I posed. Trust me, when I say that you NEED to talk to a TA. You need to SIT DOWN and have a dialog where someone can patiently direct you to understanding.
plinth