1998 Quiz 3



NAME __________________________ ID # __________________

ENEL415 Post-Lab #3 Quiz B 3rd October, 1998

This is a closed book exam, except that students may make use of their OWN, CLEAN copies of the Motorola 68000 processor and SDS Quiz 1 reference cards.

Answer in the space provided. Please ensure that you answer the question asked and not the question you think was asked. Provide appropriate documentation/explanation for your code and answers.

After completing each question, write in this table what you believe will be the mark you will receive for that question. This will allow me to keep track of student expectations

|Question Number |Maximum Mark Available |Student Mark Estimate |Actual Mark |

| | | |Awarded by T.A. |

|Q1 |8 |/ 8 |/ 8 |

|Q2 |13 |/ 13 |/ 13 |

|Q3 |6 |/ 6 |/ 6 |

|Q4 |18 |/ 18 |/ 18 |

| | | | |

|Total Marks |45 |/ 45 |/ 45 |

Don’t forget to use the answer sheet handed out at the end of the quiz to calculate your estimated mark for this quiz. Follow the information on the web about what needs to be submitted by the web (by Thursday) and handed in (Friday morning 9 am in class)

Q1) Total of 8 marks

A) I am working in Task 2 of Laboratory 3. I find a mistake in my code that allows Task 1 to work correctly, but will stop Task 2 from working correctly.

Did I find an ERROR or a DEFECT in my code? ________________ 2 marks

B) According to the results found when developing industrial programs, which

type of mistake take longer to correct – DEFECT or ERROR? _______________ 1 marks

C) During which phase of a JSR instruction would we expect the

RETURN ADDRESS to be stored onto the stack? ______________ 1 mark

D) I want to TURN ON 1 bit in a device register, leaving other current bits in the register unchanged, which instruction do I use? ADD, AND, OR, SUB ? ____________ 1 mark

E) I want to TURN OFF 1 bit in a device register, leaving other current bits in the register unchanged, which instruction do I use? ADD, AND, OR, SUB ? _____________ 1 mark

F) What is the result of the following code sequence?

MOVE.W #0x1234, D0

OR.W #0x7000, D0 _____________ 2 marks

Q2) [pic]

You will need to write on the image from the SDS simulator which shows source, register and memory windows.

The subroutine mycode() calls another subroutine long int ReturnValue(void) many times. The only information you are given about ReturnValue() is that it does stuff and always returns a 1 or a 2. The code ReturnValue() does not call any other routines, nor does it modify the stack. Total of 13 marks

A) Circle, and label with an A, the button/menu option that will allow you to specify what files are to be linked together to form an executable file 1 mark

B) Circle, and label with a B, the stack pointer in the register window 1 mark

C) What memory location (expressed in hex)

is the Stack Pointer pointing to? __________ 1 mark

D) What value (expressed in hex) does the memory location

pointed to by the stack pointer contain? __________ 2 mark

Assume that program is currently executing one of the calls to ReturnValue() shown on the screen dump. YOU DO NOT NEED ANY OTHER DETAILS ABOUT THE CODE BEING EXECUTED.

E) Circle, and label with an E, the line of code on the screen that will be executed when the current call to ReturnValue() completes its execution. This means – where will the program return to? 2 marks

F) When the program finally reaches the NOP instruction at memory location 0x1034

i) What will be the hexadecimal value in the Stack Pointer register? ________ 1.5 marks

ii) What will be the hexadecimal value in register D0? _______ 1.5 marks

iii) What will be the hexadecimal value in register D3? _________ 1 mark

iv) This code will probably work okay. In two lines or less, explain why there is a hidden mistake in the code that might stop it from working 2 marks

Q3) There are many errors that students will make when developing assembly code subroutines. VERY BRIEFLY explain the 3 most serious errors that students can be expected to make.

NOTE: If you make one of the errors that you have mentioned here during Q4, you will lose the mark here too!!!!! 2 marks each for a total of 6.0 marks

i) _____________________________________________________________________

_____________________________________________________________________

ii) _____________________________________________________________________

_____________________________________________________________________

iii) _____________________________________________________________________

_____________________________________________________________________

Q4 –

Here is a BIG print version of what is asked in Q4 -- TURN OVER FOR Q4

A processor is counting objects passing past on an assembly line. Each time an object passes a sensor a signal is sent to the processor. The sensor signal is ASSERTED (on) when there is an object passing the sensor. The signal is NEGATED (off) when there is no object passing the sensor. The sensors are attached to pins on an "read port" on the processor. The processor reads the port -- which means it gathers all the information about all the input pins at the same time as a single number (long int). Based on the information in this word (a series of bits set to 1 or 0) the processor then makes decisions. Assume that device has already been RESET

There are at least 20 marks available – 18 marks mean 100%

// Device information -- all device registers are 32 bits – NOTE “C/C++ offsets” divided by

// sizeof(long int) == 4

CONTROL_REG SET 0x10 // Offset of Control Register from the Base-Address

READ_READY_BIT SET 0x8000 // Definition of Control Register

// READ_READY_BIT

READ_DATA_REG SET 0x00 // Offset of Read Data Register from the Base

// Address

YELLOW_BALL_BIT SET 0x4000 // Definition of bits that read

RED_BALL_BIT SET 0x2000 // RED and YELLOW BALL sensors

Write a 68K assembly code subroutine long int DoSomething(unsigned long intr *pt ) where you are passed the base address of a device as a parameter.

In this subroutine, you must check the READ_READY_BIT until this becomes a 1, and then read the READ_DATA_REGISTER.

The READ_DATA_REG has two bits in it which tell you if a YELLOW ball has gone past or a RED ball has gone past the sensor. If the YELLOW_BALL_BIT is HIGH then call subroutine void DoYellow(void);

When the subroutine DoSomething() exits, return the value that had been stored in the READ_DATA_REG.

Q4 A processor is counting objects passing past on an assembly line. Each time an object passes a sensor a signal is sent to the processor. The sensor signal is ASSERTED (on) when there is an object passing the sensor. The signal is NEGATED (off) when there is no object passing the sensor. The sensors are attached to pins on an "read port" on the processor. The processor reads the port -- which means it gathers all the information about all the input pins at the same time as a single number (long int). Based on the information in this word (a series of bits set to 1 or 0) the processor then makes decisions. Assume that device has already been RESET

There are at least 20 marks available – 18 marks mean 100%

Write a 68K assembly code subroutine long int DoSomething(unsigned long intr *pt ) where you are

passed the base address of a device as a parameter. In this subroutine, you must check the

READ_READY_BIT until this becomes a 1, and then read the READ_DATA_REGISTER. The READ_DATA_REG has two bits in it which tell you if a YELLOW ball has gone past or a RED ball has gone past the sensor. If the YELLOW_BALL_BIT is HIGH then call subroutine void DoYellow(void);

When the subroutine DoSomething() exits, return the value that had been stored in the READ_DATA_REG.

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

DoSomething: // long int DoSomething(unsigned long int *pt) {

temp SET ???? // register long int temp;

temp2 SET ???? // register long int temp2

ptDEVICE SET A0 // register long int *ptDEVICE;

____________________________________//

____________________________________// All device registers are 32 bits

// Device information -- all device registers are 32 bits – NOTE “C/C++ offsets” divided by

// sizeof(long int) == 4

CONTROL_REG SET 0x10 // Offset of Control Register from the Base-Address

READ_READY_BIT SET 0x8000 // Definition of Control Register

// READ_READY_BIT

READ_DATA_REG SET 0x00 // Offset of Read Data Reg from the Base Address

YELLOW_BALL_BIT SET 0x4000 // Definition of bits that read

RED_BALL_BIT SET 0x2000 // RED and YELLOW BALL sensors

// ptDEVICE = pt;

MOVE.L CONTROL_REG(ptDEVICE), temp // temp = *(ptDEVICE + CONTROL_REG / 4)

// temp = temp & READ_READY_BIT;

______________________________________________________________________________

// while (temp != READ_READY_BIT) {

______________________________________________________________________________

Don’t worry about coding this line // temp = *(ptDEVICE + CONTROL_REG / 4);

Don’t worry about coding this line // temp = temp & READ_READY_BIT;

// }

______________________________________________________________________________

// temp = *(ptDEVICE + READ_DATA_REG/ 4)

___________________________________________________________________________________

// temp2 = temp & YELLOW_BALL_BIT

___________________________________________________________________________________

// if (temp2 != YELLOW_BALL_BIT) {

// DoYellow()

// }

___________________________________________________________________________________ //

// return(temp2)

//

// }

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download