It is currently Mon Mar 30, 2020 10:00 am

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: I have got some problemPosted: Wed Jun 08, 2011 12:12 pm

Joined: Thu May 26, 2011 9:00 am
Posts: 10
(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
move.l  (sp)+,ans
move.b  #228,d7
trap    #14
p   move.w  4(sp),d0
move.w  6(sp),d1
mulu    d0,d0
mulu    d1,d1
move.l  d1,8(sp)    ; ***
rts
ans 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?

Top

 Post subject: Posted: Wed Jun 08, 2011 3:34 pm

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
(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.

Top

 Post subject: Posted: Thu Jun 09, 2011 6:52 am

Joined: Thu May 26, 2011 9:00 am
Posts: 10
(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?

Top

 Post subject: Posted: Thu Jun 09, 2011 7:30 am

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
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.pdf

What 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.pdf

The programs is a pretty poor example of stack parameter passing, there is little point in passing back the value in this manner.

Top

 Post subject: Posted: Thu Jun 09, 2011 11:52 am

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
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

_________________
Prof. Kelly

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects