EASy68K  
It is currently Tue Dec 11, 2018 11:39 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: I have got some problem
PostPosted: Wed Jun 08, 2011 12:12 pm 
Offline

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
    add.l   #4,sp
    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
    add.l   d0,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?

look forward the answer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2011 3:34 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2011 6:52 am 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2011 7:30 am 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2011 11:52 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group