Docsity

Objectives on Introducing the Binary Numbers - Assignment 10 | EMCH 367, Assignments of Mechanical Engineering

Toggle sidebar
bg1
EMCH 367 Fundamentals of Microcontrollers Exercise 10
EXERCISE 10
GENERAL NOTE
Before starting this exercise, read Example 10 and work through it using the THRSim11 simulator.
Then, read this exercise. You will notice that the present exercise is practically identical with this
example, only that is uses different numbers, at times.
'Save As' this Word file in the personalized format indicated in the course pack.
To complete the exercise, you will have to do the following:
Type in text
Insert screen/window captures from the THRSim11 simulator.
The exercise has 15 sections. Do them in sequence.
OBJECTIVE
This exercise has the following objectives:
Introduce 8-bit binary numbers
Introduce connection between 8-bit binary numbers and 2-digit hex numbers.
Introduce 8-bit binary arithmetic
Introduce binary 8-bit logic
PROGRAM
You have to write .asm code to do the following:
i) Represent numbers one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen,
fourteen, fifteen, sixteen, seventeen in decimal, binary, and hex
ii) Perform 5 + 4 = 9 in binary and hex using LDAA, LDAB, ABA
iii) Perform 15 – 7 = 8 in binary and hex using LDAA, LDAB, SBA
iv) Perform $1f + $01 = $ in binary and hex using LDAA, ADDA (bit 3 carry)
v) Perform $20 -$01 = $ in binary and hex using LDAA, SUBA
vi) Perform $ff + $01 = $ in binary and hex using LDAA, ADDA (MSB carry)
vii) Perform $00 - $01 = $ in binary and hex using LDAA, SUBA
viii) 0 AND 1 = using LDAA, ANDA
ix) 0 OR 1 =using LDAA, ORAA
x) 0 XOR 1 = using LDAA, EORA
xi) 1 OR 1 =using LDAA, ORAA
xii) 1 XOR 1 = using LDAA, EORA
xiii) %00000000 NAND %11111111 = % using LDAA, ANDA, COMA
xiv) %11111111 NOR %00000000 = % using LDAA, ORAA, COMA
Dr. Victor Giurgiutiu Page 1 11/30/2020
pf3
pf4
pf5

Partial preview of the text

Download Objectives on Introducing the Binary Numbers - Assignment 10 | EMCH 367 and more Assignments Mechanical Engineering in PDF only on Docsity!

EXERCISE 10

GENERAL NOTE

 Before starting this exercise, read Example 10 and work through it using the THRSim11 simulator.  Then, read this exercise. You will notice that the present exercise is practically identical with this example, only that is uses different numbers, at times.  'Save As' this Word file in the personalized format indicated in the course pack.  To complete the exercise, you will have to do the following:  Type in text  Insert screen/window captures from the THRSim11 simulator. The exercise has 15 sections. Do them in sequence.

OBJECTIVE

This exercise has the following objectives:  Introduce 8-bit binary numbers  Introduce connection between 8-bit binary numbers and 2-digit hex numbers.  Introduce 8-bit binary arithmetic  Introduce binary 8-bit logic

PROGRAM

You have to write .asm code to do the following: i) Represent numbers one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen in decimal, binary, and hex ii) Perform 5 + 4 = 9 in binary and hex using LDAA, LDAB, ABA iii) Perform 15 – 7 = 8 in binary and hex using LDAA, LDAB, SBA iv) Perform $1f + $01 = $ in binary and hex using LDAA, ADDA (bit 3 carry) v) Perform $20 -$01 = $ in binary and hex using LDAA, SUBA vi) Perform $ff + $01 = $ in binary and hex using LDAA, ADDA (MSB carry) vii) Perform $00 - $01 = $ in binary and hex using LDAA, SUBA viii) 0 AND 1 = using LDAA, ANDA ix) 0 OR 1 =using LDAA, ORAA x) 0 XOR 1 = using LDAA, EORA xi) 1 OR 1 =using LDAA, ORAA xii) 1 XOR 1 = using LDAA, EORA xiii) %00000000 NAND %11111111 = % using LDAA, ANDA, COMA xiv) %11111111 NOR %00000000 = % using LDAA, ORAA, COMA

xv) %10101110 AND %00001000 = % using LDAA, ANDA (masking) (Note: the NAND and NOR instructions do not exist in the MC6811 instruction set, but can be obtained by using the COM instruction after the AND and OR instructions .)

CODING AND EXECUTION

Open THRSim11. Maximize THRSim11 window. Close the Commands window. Open the template.asm file and save it with the personalized name LASTNAME_Firstname_Ex10 (Please respect the upper and lower conventions.). Type your program in the .asm window after the line saying *Begin typing your code. Assemble your file, tile the windows, set the breakpoint, and reset the registers.

SECTION: REPRESENT NUMBERS ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN,

ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN, SIXTEEN, SEVENTEEN IN DECIMAL, BINARY, AND

HEX Reset accA. Place PC at the beginning of section i) of your code. Set display of accA to binary. Perform first step. Explain what happened during this operation. 4 point(s) Perform the rest of the steps. Step through the rest of the operations, incrementing each time accA by one. At each step, observe the binary representation, then switch to hex, then to decimal, and back to binary. When incrementing, observe how the binary bits either increment from 0 to 1, or increment from 1 to 0 with a binary carry to the left. While binary numbers experience a carry at each step, the decimal and hex numbers do not. Watch out for decimal and hex carries! You will only need to capture and paste below those situations when a decimal or a hex carry happened. Paste here your screen capture when a decimal carry happened. 10 point(s) Type in the decimal, binary and hex equivalents of the number in accA: Decimal:_________ binary:%____________ hex:$___________6 point(s) Paste here your screen capture when a hex carry happened. 10 point(s) Type in the decimal, binary and decimal equivalents of the number in accA: Decimal:_________ binary:%____________ hex:$___________6 point(s)

Perform the operation in the THRSIM11 simulator. Type in the binary and hex equivalents of the results: %______________________________________2 point(s) $_________ 2 point(s)

SECTION: 0 AND 1 = USING LDAA, ANDA

Predict the result of 0 AND 1 = _________2 point(s) Perform the operation in the THRSIM11 simulator. 0 AND 1 = ______2 point(s)

SECTION: 0 OR 1 = USING LDAA, ORAA

Predict the result of 0 OR 1 =___________2 point(s) Perform the operation in the THRSIM11 simulator. 0 OR 1 =___________2 point(s)

SECTION: 0 XOR 1 =USING LDAA, EORA

Predict the result of 0 XOR 1 =__________2 point(s) Perform the operation in the THRSIM11 simulator. 0 XOR 1 =__________2 point(s)

SECTION: 1 OR 1 = USING LDAA, ORAA

Predict the result of 1 OR 1 =__________2 point(s) Perform the operation in the THRSIM11 simulator. 1 OR 1 =__________2 point(s)

SECTION: 1 XOR 1 =USING LDAA, EORA

Predict the result of 1 XOR 1 =__________2 point(s) Perform the operation in the THRSIM11 simulator. 1 XOR 1 =__________2 point(s)

SECTION: %00000000 NAND %11111111 = % USING LDAA, ANDA, COMA

Predict the result of %00000000 NAND %11111111 = %____________________2 point(s) Perform the operation in the THRSIM11 simulator.

%00000000 NAND %11111111 = %____________________2 point(s)

SECTION: %11111111 NOR %00000000 = % USING LDAA, ORAA, COMA

Predict the result of %11111111 NOR %00000000 = %____________________2 point(s) Perform the operation in the THRSIM11 simulator. %11111111 NOR %00000000 = %____________________2 point(s)

SECTION: %10101110 AND %00001000 = % USING LDAA, ANDA (MASKING)

Predict the result of %10101110 AND %00001000 = %____________________2 point(s) Perform the operation in the THRSIM11 simulator. %10101110 AND %00001000 = %____________________2 point(s)

WHAT YOU HAVE LEARNED

In this exercise, you have learned:  The 8-bit binary numbers  The connection between 8-bit binary numbers and 2-digit hex numbers.  The 8-bit binary arithmetic  The 1-bit and 8-bit binary logic  The fact that logic operations are performed bit-by-bit  Boolean inversion using the complement opcode (e.g., COMA).  Masking, i.e., the selection of bits using masks  New words and notations: 8-bit binary arithmetic, 8-bit binary logic; complement opcode; masking, flags.