0% found this document useful (0 votes)
12 views7 pages

EEET2505 - Introduction To Embedded Systems Assessment 1 - Early Feedback Individual Quiz (15 Marks)

Uploaded by

khoioisp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

EEET2505 - Introduction To Embedded Systems Assessment 1 - Early Feedback Individual Quiz (15 Marks)

Uploaded by

khoioisp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

RMIT Classification: Trusted

EEET2505 – Introduction to Embedded Systems


Assessment 1 – Early Feedback Individual Quiz (15 Marks)

Problem Set: 1B
Total Available Mark: 15 marks

Important Notes:
1. You have 120 minutes to complete the quiz (including questions reading + assessment work + result
submission). You only have 01 attempt to solve it.
2. All problems solving with calculations must be HAND-WRITTEN, do not type. On your own paper, you
don’t need to redraw the table, you just need to write down your answer as shown in the example below:
Example: Blank (1): ABC; Blank (2): XYZ, etc.
3. Each submitted quiz solving page must have your name and your ID. Failure to include your name and
student ID number in your submitted pictures will be classified as "plagiarism".
4. All pictures must be clearly taken, and that the problem solving must be readable.
5. Submit 1 file for 1 question only. No tolerance. You can put all pages into a single PDF file.
6. This is an open book quiz. You are permitted to use your written notes and Internet sources during the
quiz.
7. Please give the details of your solutions in the spaces provided on the paper itself.
8. You are recommended to attempt all of questions provided.
9. Your solution should be detailed.
RMIT Classification: Trusted

This question has three tasks


A Microcontroller (MCU) is given with:
• An Accumulator A (8 bit)
• Program Counter (PC)
• 8 general purpose registers from R0 to R7 (8 bit)
The initial instruction set is listed in the following table:

No Instruction Mnemonic code Opcode Description


1 No Operation NOP 0000 No effect on internal registers.
2 Add Accumulator with Register ADD A, Rn 0001 Add the register Rn to the Accumulator, then leaving the
For example result in the Accumulator.
ADD A, R3 (A)  (A) + (Rn)

3 Add Accumulator with a data ADD A, addr 0010 Add a data stored at the indicated address addr to the
from memory For example Accumulator, then leaving the result in the Accumulator.
ADD A, 0b10011 (A)  (A) + mem[addr]
(addr here is in Note – if the Sum is overflow (over 8 bit), a Carry flag C
Binary) will be set to 1.

4 Subtract Register from SUBB A, Rn 0011 Subtract the register Rn from the Accumulator, then
Accumulator leaving the result in the Accumulator.
(A)  (A) - (Rn)
5 Subtract an immediate data SUBB A,#data 0100 Subtract an immediate data from the Accumulator, then
from Accumulator For example leaving the result in the Accumulator.
SUBB A, 0x12 (A)  (A) - #data
(#data is in HEX) Note – if the resultant Accumulator is Zero, a Zero flag Z
will be set to 1
6 Bitwise AND with Register ANL A, Rn 0101 Perform the bitwise logical-AND operation between the
For example Register Rn and the Accumulator, then store the results in
the Accumulator.
ANL A, R4
(A)  (A) & (Rn)
RMIT Classification: Trusted

7 Copy an immediate data to MOV A,#data 0110 Copy an immediate data to the Accumulator.
Accumulator (#data is in HEX) (A)  #data
8 Jump if Carry flag is set JC addr 0111 If the Carry flag is 1 (see instruction 3 above), JC will
For example branch to the indicated address; otherwise, it proceeds
with the next instruction
JC, 0b10011
IF (C) = 1
THEN (PC)  addr
ELSE (PC)  (PC) + 1
9 Load Register with an MOV Rn,#data 1000 Copy an immediate data to the Register Rn
immediate data (Rn)  #data
For example Note –The data for this instruction is only 5-bit long and
MOV R3, 0b10011 represented in binary instead of HEX. Three Zeros “000”
will be added to the data before being copied to the
(this instruction
Register.
#data is in Binary)
RMIT Classification: Trusted

The generic instruction (12-bit) has the format as follows:

11 10 9 8 7 6 5 4 3 2 1 0

Instruction Data
Opcode
(Address, Data, Register)
Couple notes for the instructions:
• The CPU work with data that is 8 bit long (or 2 Hexadecimal digit).
• The address is 5-bit long.
• For instructions where we don’t need operands or data instructions, the remaining least significant bits of the instruction will be Zeros.
o For example, ADD A, Rn

0 0 0 1 N2 N1 N0 0 0 0 0 0

Opcode Register Remaining bits are Zeros


o For example, ADD A, 10011 s

0 0 1 0 1 0 0 1 1 0 0 0

Opcode Address Remaining bits are Zeros

• For each instruction, after the instruction is fetched from the memory, the Program Counter (PC) will increase by 1 to point to the next
instruction, except for the instruction JC, which will make the Program Counter will point to a designated address.
RMIT Classification: Trusted

1.1 – Program 1 (5 marks)


With N is the last digit of your Student ID. Assume that N is in hexadecimal. You are given with a simple program as follows. Do:
• Write the corresponding mnemonic code for each instruction.
• Translate the instruction into corresponding machine code.
• Indicate the PC for the instruction that will be executed next.
• Determine the value of Accumulator once the program is over.
Assume that initially PC = 0b0000, all the registers and Accumulator are reset to Zero. Write your answers in the designated space (highlighted in
Orange).

Address Tasks Mnemonic code (Assembly code) Machine code (in HEX)
Each correct answer is worth 0.2 marks Each correct answer is worth 0.2 marks
0b00000 Copy 0xCN to Accumulator (1) (2)
00001 Load Register R3 with 0b01001 (3) (4)
00010 No Operation NOP 0x000
00011 Add Register R3 to Accumulator (5) (6)
00100 No Operation NOP 0x000
00101 Load Register R2 with 0b01101 (7) (8)
00110 Bitwise AND with Register R2 (9) (10)
00111 Copy 0xFC to Accumulator (11) (12)
01000 Add Register R2 to Accumulator (13) (14)
Check if the Carry is 1 then jump to (15)
01001 address 0b01110 (16)
01010 Copy 0x9N to Accumulator (17) (18)
01110 Subtract 0x05 from Accumulator (19) (20)

Accumulator at the end of the program in Binary, write the bits in the following box (0.5 marks)

(21)
RMIT Classification: Trusted

1.2 – Designing new instructions (3 marks)


Add two couple of new instructions (their opcodes are given) to the previous MCU. The effects of the instructions are listed in the following table
You are required to:

• Assign mnemonic codes for these new instructions. Hint – you can adopt the way the mnemonic codes of the previous
instructions.
• Define their specific instruction format (which still needs to meet the generic instruction format of the MCU).
The instruction 10 has been filled as an example

No Instruction Opcode Mnemonic code Instruction Format Description


Each correct answer Each correct answer is Each right answer is worth 0.5
is worth 0.25 marks worth 0.25 marks marks
10 Add Accumulator with an 1001 Example Example Add an immediate data to the
immediate data ADD A,#data 1001 D7 D6 D5 D4 D3 D2 D1 D0 Accumulator, then leaving the
(12 bits) result in the Accumulator
(A)  (A) + #data
11 Write the value of (22) (23) (24) Write an immediate data to a
Accumulator to memory location in memory which
indicated by an address.
mem[addr]  (A)
12 Load Register Rn with a (25) (26) (27) Copy data from a location in a
memory data memory to the Register Rn
(Rn)  mem[addr]
13 Check the content of the (28) (29) (30) If Acc = 0 then PC =
S5S4S3S2S1S0
Accumulator register
If Accumulator is Zero, then
Jump to the address
S5S4S3S2S1S0
RMIT Classification: Trusted

1.3 – Program 2 (7 marks)


Using the full instructions set with the newly added ones for the following program. At reset, registers and PC will be Zero as stated in the
Program 1. Repeat the steps as you did in Program 1 to complete the table (highlighted in Orange). Some memory data is also included in the
table. Each correct answer is worth 0.5 marks

Address Tasks Mnemonic code (Assembly code) Machine code (in HEX) Values after
Instructions

Copy 0x06H to Accumulator (31) (33)


00000 (32)
00001 Load Register R7 from the address of (34) (36)
0b11010 in the memory (35)
Bitwise XOR between the Accumulator (37) (39)
00010 and Register R7 (38)
00011 Write the value of Accumulator to the (40) (42)
address of 0b11011 in the memory (41)
………..
11010 0x05
(43)
11011
End of program

Value of R7 at the end of the program, write the bits in the following box (0.5 marks)

(44)

You might also like