Write a subroutine addabc that performs the given operation

Assignment Help Computer Engineering
Reference no: EM131383139

Assignment: Parts A and B

For "written" questions, please type your answers, use your very best English, and carefully consider the material from the chapters. I am usually only looking for a few sentences for each question, not an essay that goes on for pages. So choose your words carefully and thoughtfully.

PART A

[1] Does a computer need data registers (like D0-D7 in an M68K)? Defend your answer!

[2] Textbook question 5.35. If your student number is even, do parts (a), (c), (e) and (g). Otherwise do parts (b), (d), (f) and (h). Note that (b) should read "[[[4]]]", (c) should read "[[[0]]]" and
(h) should start with "[0]".

[3] Explain why the following assembly language and RTL constructs are incorrect.
a. MOVE    D3,#4
b. MOVE    [D3],D2
c. MOVE    (D3),D2
d. [D3] ←  A0 + 3
e. [D3] ←  #3
f. 3      ←  [D3]

[4] Create a simple M68K program called ADDER. Your program should add together the numbers: 6, 4, 12, 16, 17, and 50. The program should leave the answer in register D0 when it terminates.

The program is to be assembled with the M68K cross-assembler and then run on the M68K simu- lator. You can either install the cross-assembler and simulator given with the textbook (windows) or you can use the Linux one available on the course web site. Doing a trace (to hand in) with the windows version is much more painful than the Linux version, so make your choice carefully (and you have to figure out the windows one without my help).

To use the Linux assembler ("68kasm") and simulator ("bsvc"), follow the instructions in my mail message of January 26, if you have not already done so.

IMPORTANT NOTE: if you are using the Linux simulator, the instructions for creating a program are slightly different than those in the book. You should have the following at the start of each program:

ORG      $0
DC.L     $8000     This is the stack pointer value after a "reset"
DC.L     START      This is the first instruction to execute

You can then follow that with something like

ORG     $1000    START MOVE ...

You should still have a STOP instruction and END assembler directive, as described in the book, but also use a BREAK instruction right before your STOP instruction.

Create your program (ADDER.s) in your (for example) comp2213/bsvc-master directory using your favourite text editor and assemble it with the command 68kasm -l ADDER.s. If you had no assembly errors you should now have a file called ADDER.h68 (which is your executable program) and ADDER.lis (your program listing). Then start up the simulator by typing bsvc. Select File/Open Setup, drill down to samples/m68000, select serial.setup and click Open; a new window should pop up on your screen. Now choose File/Load Program, come back up to your bsvc-master directory, and open your ADDER.h68 program. Now click the GUI's Reset button and then the Run button. (Alternatively, instead of Run click Single Step and watch the result of each instruction.)

After you get your program working, create something to hand in by single-stepping through your program until it finishes, and then use the Trace menu to insert the register values into the trace window, and then save that window (again from the Trace menu). Hand that file and your program listing in. If you are using the windows software, do whatever it takes to hand the same information in. The tutors have looked at the Linux software and should be able to help you with it, but you are really on your own with the windows software.

There are some sample programs in the samples/m68000 directory. To learn how to use bsvc, you might find it instructive to run the MatrixMultiply.h68 program using the serial setup.

PART B

[5] What is wrong with each of the following M68K assembly language operations?

a. MOVE         Temp,#4
b. ADD.B        #1,A3
c. CMP.L          D0,#9
d. MOVE.B      #500,D5

[6] Translate the following fragment of high-level language into M68K assembly language. Then create a complete M68K program containing your code, and use a M68K simulator to test your program.

IF T = 5
       THEN X = 4
       ELSE Y = 6
END_IF
Hand in the program listing and program trace as in Question 4.

[7] A sequence (string) of one-byte ASCII characters is stored at memory location $600 onward. A second sequence of equal length is stored at memory location $700 onward. Each sequence ends with the character $0 (i.e., the ASCII NUL character). Write a M68K assembly language program to determine whether or not these two strings are identical. If they are identical, place the value
$00 in data register D0. If they are not, place the value $FF in D0.

Use the M68K cross-assembler and simulator to test your program (make up a couple of your own strings, using the DC.B assembler directive). Hand in the program listing and program trace as in Question 4.

[8] Write a subroutine ADDABC that performs the operation C = A + B. Variables A, B, and C are all word (i.e., 16-bit) values. Test your program on the M68K simulator by writing a main program which sets up values in A and B and then calls your main program.

Your calling code and subroutine should have the following features:

? Parameters A and B should be passed on the stack to the procedure by reference (i.e., by address). Parameter C should be passed back to the calling program on the stack by value.

? Before you call the subroutine, make room on the stack for the returned parameter (i.e., parameter C). After calling the subroutine, read the parameter off the stack into data register D0 (i.e., D0 should end up containing the value of A + B).

? The subroutine ADDABC must not corrupt any registers. Save all working registers on the stack on entry to the subroutine and restore them before returning from the subroutine.

? When you write your code, preset the stack pointer to a value like $1500 (by using either MOVEA.L #$1500,A7 or LEA $1500,A7). Doing this will make it easier to follow the movement of the stack while your program is running.

? Make certain that you are operating with the correct operand sizes! Use .W for data values and .L for addresses/pointers.

? Some of the important instructions you might need are provided below. Make sure you understand exactly what they do.

           MOVEM.L            RegList, -(A7)            Push a group of registers on stack
           MOVEM.L            (A7)+, RegList            Pop a group of registers off stack
           LEA                    X(Ai), Aj                    Load Aj with the contents of Ai + X
           MOVEA.L            (Ai),Aj                       Load Aj with  longword pointed at by Ai

Your program should be of the general form:

 

ORG

$0

 




START

DC.L
DC.L
ORG
LEA
...
BSR
...
...
STOP

$8000
START
$400
$1500,A7

ADDABC


#$2700

Initial value of stack pointer
First instruction here

Set up the stack pointer with an easy value
Pass the parameters
Call the subroutine
Get the result, C, in D0
Clean up the stack
Halt execution

*
ADDABC      ...
                   ...
                 RTS
*
                 ORG          $1200              Put the test data here
A               DC.W        $1234              This is the first parameter
B               DC.W        $ABAB             This is the second parameter
                 END          START

This is not an easy or trivial problem. You will need to draw a map of the stack at every stage and take very great care not to confuse pointers (addresses) and actual parameters.

Hand in a listing and trace of your program as descried in question 4.

NOTE: a lot of the other questions in Chapters 5 and 6 look like good midterm and/or final exam questions to me.

Reference no: EM131383139

Questions Cloud

Identify the competitive strategies : Identify which of the competitive strategies that is used by Metropolitan State University. Then create and explain the value chain at Metropolitan State University. Based on your analysis, does Metropolitan State University have a competitive adv..
Culture of ethical business behavior : Identify an organization that you have worked for or know about that has successfully implemented a culture of ethical business behavior. Alternatively, identify one that has not successfully implemented a culture of ethical business behavior.
Positioning and perceptual mapping : Choose one of the following companies and respective brands bulleted below. Then create a perceptual map using TWO important characteristics you think are important to customers.
Evolved from training as an event to learning : In your own words, define training, and explain how training has evolved from training as an event to learning. Discuss the difference between learning and knowledge in your response. 200 word minimum.
Write a subroutine addabc that performs the given operation : COMP 2213X2- Explain why the following assembly language and RTL constructs are incorrect. Write a subroutine ADDABC that performs the operation C = A + B. Variables A, B, and C are all word (i.e., 16-bit) values.
Find apsidal angle for a nearly circular orbit of radius a : Find the apsidal angle for a nearly circular orbit of radius a. When ∈ is small, show that the perihelion of the orbit advances by approximately π? on each revolution.
Draw a constellation pattern for a modem : Draw a constellation pattern for a modem that uses eight equallyspaced phase angles and four equally-spaced amplitude levels. If the modem operates at 4800 baud, what is its bit rate?
Strating the effects of the federal courts on terrorism : What effect have the federal courts had the government's ability to enforce national security? Find a court case or news article from the last two months is strating the effects of the federal courts on terrorism
What is its maximum data rate ignoring noise : A microwave radio system uses 256-QAM, that is, there are 256 possible amplitude and phase combinations.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Questionhocolate delights candy company manufactures

questionhocolate delights candy company manufactures several types of candy. graph a flowchart or pseudocode for

  Use a wep enabled phone to perform stock trades

will you utilize a WEP enabled phone to perform stock trades? Why or why not?

  Describe virtual and augmented reality

Describe virtual and augmented reality. Suggest a way in which this technology could be used in the future , either to improve a current process / procedure or create a new process / procedure.

  Find out a description of a software development process

Find out a description of a software development process,preferably with a description on the web.

  Determine the best manner to encode each character

Suppose a document contains 22 A, 12 B, 24 C, 6 D, 27 E, 9 F. Determine the best manner to encode each character with the least number of bits by a greedy approach.

  How can you make sure that the proper indexes have been put

As an analyst, how can you make sure that the proper indexes have been put in place so that users are not waiting for weeks to receive the answers to their questions?

  Write down a 3- to 5-page paper which gives a detailed

write a 3- to 5-page paper that provides a detailed technical analysis comparing the advantages and disadvantages of

  Calculate the stress and strain in a steel rod of diameter d

Write down a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads p of 10,000 to 1,000,000 pounds in increments of 100,000 pounds. T..

  Questionon modern networked computers maintaining the

questionon modern networked computers maintaining the correct time on each machine is important. computers on a lan or

  Is this an ethical question or just a matter of office

as a new systems analyst at premier financial services you are getting quite an education. youreport to mary the it

  Define three approaches to organizing programming teams

How does implementing a maintenance change differ from the new system development project.

  Find the minimum number of multiplexer and gates

find the minimum number of multiplexer and gates to realize the given function.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd