Professional Documents
Culture Documents
Assignment - 2 - Micro - Complete
Assignment - 2 - Micro - Complete
ELE 3614
Microcontroller Systems Assignments
Learning outcome: 2
Assignment No. :2
Implement the process of development from flowchart to program
Student Name
Student ID Number
Page 1
ELE 3614
1. What is machine language?
Machine language is the language that computers can only understand, or we can say, “It is a collection of binary bits and digits in
form of 0 and 1 that computer is capable of understanding it”.
The example of machine language code using a string of "Hello World." is depicted below:
01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100
2. What is the software or program used to translate high level language into machine language?
Complier is the software or program which is used to translate high level language into machine language. Once a program's code
is compiled from high-level languages like C or C++ etc into machine language by the complier, which itself is in the form of ‘0’
or ‘1’ then it will be comprehended by computers easily and swiftly.
For instance, complier will convert the decimal number 64d into binary number that is 01000000b which is in form of 0s and 1s.
3. What is the software or program used to translate assembly language into machine language?
Assembler is the software or program which is used to convert assembly language into machine language. Its instructions are
based upon the mnemonics and have the one to one correspondence with machine language instructions due to which the process
is called assembly rather than translation.
4. Which of the two programming languages assembly and high level can be used on two different machines?
High-level languages like Java, C++, Python are the machine independent languages. They cannot run directly on the target
machines, but needed to be complied to machine language first by a software or program like complier. Assembly language is
converted into machine code by assembler that totally operates with machine in a direct manner that is easier for OS to
comprehend but program written in assembly language are not machine independent.
Terminator
This symbol in flowchart is used to display Start / Stop of the program or code which is oval START / STOP
in shape.
Decision
This symbol in flowchart is used to display the decision True or False in a program or code which is
diamond in shape.
Initialization DECISION
This symbol in flowchart is used to display the initialization condition of variables in a program or code which is in
hexagon in shape.
PREPARATION
Page 2
ELE 3614
Input / Output
This symbol in flowchart is used to display the input or output of the process variables in a
program or code which is parallelogram in shape.
INPUT / OUTPUT
Process
This symbol in flowchart is used to display the process on the variables in a program or code which
is rectangular in shape.
PROCESS
6. Draw the flowchart sections showing the 3 structures: repetition, selection, and sequence.
1. Sequence
The flowchart showing the specimen of “Sequence operation” has been shown below.
Operation 1
Operation 2
Operation 3
Page 3
ELE 3614
2. Selection
The flowchart showing the specimen of “Selection operation” has been shown below.
TRUE FALSE
Choice 1 Choice 2
3. Repetition
The flowchart showing the specimen of “Repetition operation” has been shown below.
False
True
7. What are the contents of working register W after the following two instructions if Reg1 = 0xEF?
movf Reg1, 0 ; W= 0xEF
addlw 0x01
Page 4
ELE 3614
8. What are the contents of working register W after each of the following instructions if W=0x12, R2 =0x02, and R6 =
0x15?
ADDWF R2, 0
MOVLW D’14’
XORWF R6, 0
Where the resultant value of “W” after execution of instruction,
W = (0xE) XOR (0x15) = 0000 1110 XOR 0001 0101 = 0x1B
9. Fill in the contents of W, PortA and PortB after each of the following instructions assuming no carry.
W PORTA PORT B
CLRW 0x00
MOVLW 24H 0x24
MOVWF PORTA 0x24
MOVWF PORTB 0x24
SWAPF PORTB, 1 0x42
SUBLW 0X08 0x24 - 0x08 = 1C
INCF PORTA,1 0x24 + 0x1 = 0x25
BSF STATUS, 0 carry =1
RRF PORTB,0 0xA1 1 0100 0010 -> 0 10100001 = 0xA1
ANDLW 2FH 10100001
00101111
00100001 = 0x21
COMF PORTA, 1 0010 0101 = 0x25
10. Draw a flowchart to load two values 53H and 32H from PORTA and PORTB respectively. Add them and store the result
in PORTC.
Start
Page 5
ELE 3614
PORTC = 0x00
PORTA = 0x53
PORTB = 0x32
PORTC
End
End
Page 6
ELE 3614
Assembly Language:
ORG 0x00
MOVF Reg1, 0 ; move input to W where Reg1 = 0xEF
ADDLW 0x01 ; Where the resultant value of “W” after execution W = 0xEF + 0x01 = F0
MOVWF Reg1 ; move it to output
END
12. Draw a flowchart for a system to turn on/off LEDs on PORTB when a switch ON PORTC is pressed with a delay of 1s
between.
Start
Page 7
ELE 3614
True False
Switch Pressed
End
Assembly Language:
Page 8
ELE 3614
ORG 0x00
CLRW
MOVLW 24H
MOVWF PORTA
MOVWF PORTB
SWAPF PORTB, 1 ; Swap on PORTB
SUBLW 0X08
INCF PORTA, 1
BSF STATUS, 0 ; Carry =1
RRF PORTB, 0
ANDLW 2FH
COMF PORTA, 1
ADDLW 0X02
END
Page 9