EASy68Khttp://www.easy68k.com/EASy68Kforum/ I have got some problemhttp://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1033 Page 1 of 1

 Author: wangyimang [ Wed Jun 08, 2011 12:12 pm ] Post subject: I have got some problem (a) Consider the following code segment, and answer the questions below:Code:start org \$1000    move.l  #\$7ffe,sp    sub.l   #4,sp    move.w  #3,-(sp)    move.w  #2,-(sp)    bsr     p    add.l   #4,sp    move.l  (sp)+,ans    move.b  #228,d7    trap    #14p   move.w  4(sp),d0    move.w  6(sp),d1    mulu    d0,d0    mulu    d1,d1    add.l   d0,d1    move.l  d1,8(sp)    ; ***    rtsans ds.l    1    end (i) What is the value of ans at the end of the execution?(ii) Give a general formula for the calculation that this code performs.(iii) What does the last move.l instruction (which is commented with ; ***) do?(iv) What instruction or instructions clean up the stack?look forward the answer

 Author: lee [ Wed Jun 08, 2011 3:34 pm ] Post subject: (i) Run the code and you will find out.(ii) It's three instructions, just write down what they do.(iii) Step through the code and you will find out.(iv) look for lines with sp in them.Lee.

 Author: wangyimang [ Thu Jun 09, 2011 6:52 am ] Post subject: (1) i saw the value is 1036 but the reason for this is?plz exlain little(2) formular which i see its only subtract, is there more?(3) still dont konw move.l does(4) is that rts?

 Author: clive [ Thu Jun 09, 2011 7:30 am ] Post subject: Static analysis suggests the answer should be 13. Also the use of TRAP#14 suggests the program has been written for the MECB not Easy68K. http://www.classiccmp.org/cini/pdf/Motorola/mecb05.pdfWhat about the pair of multiplies and the add? You don't see those? (ans = p1*p1 + p2*p2)MOVE.L, moves a LONG word, ie 32-bits, between memory and/or registers.RTS Returns from subroutine (pg 273), in this case the one called 'p'Have you not looked at ANY books or manuals on the 68K? Go download a 68K programmers manual of the net. http://www.freescale.com/files/archives ... 000PRM.pdfThe programs is a pretty poor example of stack parameter passing, there is little point in passing back the value in this manner.

 Author: profkelly [ Thu Jun 09, 2011 11:52 am ] Post subject: M68K Programmers Reference manual is also available on the easy68k site:http://www.easy68k.com/paulrsm/index.html.There is a functional MECB Tutor program on the EASy68K examples page if you want to run the program using EASy68K: http://www.easy68k.com/applications.htm