Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92192961
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As