0% found this document useful (0 votes)
50 views

Ali Ganbarov 2049146 EEE 347 Lab 1 Prework 1.2.2) A)

The document contains code for an assembly language program that will run on a microcontroller. The program defines constants for zeros, ones, and memory locations. It initializes ports, reads inputs from pins, stores the values in memory, adds them, checks for overflow, stores the result and overflow value, and loops continuously. It also provides brief explanations of RAM, ROM, and flash memory and describes the role of the control unit in fetching and decoding instructions to direct the ALU.

Uploaded by

Emre Onursoy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Ali Ganbarov 2049146 EEE 347 Lab 1 Prework 1.2.2) A)

The document contains code for an assembly language program that will run on a microcontroller. The program defines constants for zeros, ones, and memory locations. It initializes ports, reads inputs from pins, stores the values in memory, adds them, checks for overflow, stores the result and overflow value, and loops continuously. It also provides brief explanations of RAM, ROM, and flash memory and describes the role of the control unit in fetching and decoding instructions to direct the ALU.

Uploaded by

Emre Onursoy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ali Ganbarov

2049146

EEE 347

Lab 1 Prework

1.2.2) a)
.INCLUDE "m128def.inc"
.EQU ZEROS = 0x00 ;define ZEROS as 0x00
.EQU ONES = 0xFF ;define ONES as 0xFF
.EQU MEMNUM1 = 0x100 ;define MEMNUM1 as 0x100
.EQU MEMNUM2 = 0x101 ;define MEMNUM2 as 0x101
.EQU MEMSUM = 0x102 ;define MEMSUM as 0x102
.EQU MEMOVF = 0x103 ;define MEMOVF as 0x103
.CSEG ;label for code section
.ORG 0x0050 ;set program counter to 0x0050
ldi r16, ZEROS ;load value of ZEROS into r16
out ddra, r16 ;out value of r16 to register port A
out ddrb, r16 ;out value of r16 to register port B
ldi r17, ONES ;load value of ONES into r17
out ddrc, r17 ;out value of r17 to register port C
out ddrd, r17 ;out value of r17 to register port D
capture: in r18, pina ;label for loop, get input from pin a into r18
sts MEMNUM1, r18 ;set r18 to location MEMNUM1
in r19, pinb ;get input from pin b into r19
sts MEMNUM2, r19 ;set r19 to location MEMNUM2
add r18, r19 ;add r18 and r19 and store into r18
brvc no_ovrflw ;if no overflow branch to no_ovrflw label
ovrflw: com r16 ;label for ovrflw, take one's complement of r16
no_ovrflw: sts MEMSUM, r18 ;label for no_ovrflw, set r18 to location MEMSUM
out portc, r18 ;output value of r18 to register port C
sts MEMOVF, r16 ;set r16 to location MEMOVF
out portd, r16 ;output r16 to register port r16
ldi r16, ZEROS ;load values of ZEROS into r16
jmp capture ;jump to label capture(loop)

b)
Overflow:
No overflow:
c)
1.2.3)

RAM(Random access memory) accessed randomly at any time, allows reading and writing. RAM is fast
and expensive. ROM(read only memory) can’t be easily rewritten, generally used for reading only. It’s
slower compared to RAM and much cheaper.

Flash is a type of EEPROM. Flash is faster because it writes data in chunks.

1.2.4)

Control unit controls the work of CPU. It controls the flow of program and manipulates data. Fetches
instructions and sends instructions to ALU to perform required tasks. Additionally, it takes data from
ALU, inputs and can send them to memory or output.

The location of each instruction in memory is identified by address. The address numbers of locations is
remaining same but the content can be different. Control unit fetches the instruction from memory
using its address. Then it decodes the data and sends it to ALU according to data stored in memory.

The number of bytes is fixed by the system requirements, so it depends on system specifications.

You might also like