Professional Documents
Culture Documents
Mechatronics Engineering
Practice 3
"Adder and subtractor
Abstract In this practice, the student will get acquainted with the basic assembler instructions for moving data
and performing some basic arithmetic operations.
I. REQUIREMENTS
Develop and implement an algorithm in assembler for the PIC16F628A to calculate the addition and
subtraction (A-B) of two 3-bit operands. The operands A and B must be read from port A; each operand will be
defined with a 4-bit dip switch connected to this port (A<RA2:RA0> and B<RA5:RA4>). The pin RA7 allows
the user to select the desired operation, in this case, when is read a 0 level from this pin, the microcontroller
must calculate the addition, otherwise the subtraction. The result of the operation must be shown in 4 LEDs
connected in PORTB <RB3:RB0>. Consider the fourth bit (RB3) as the carry and as the negative flag depending
on the operation executed.
I. REQUIREMENTS
Design and implement an algorithm for a decoder, which input is a 5-bit number connected in port A
<RA4:RA0>. The decimal number must be shown in two 7-segments displays to display tens and units. Both
displays must be connected to port B <PB6:PB0>, so they are multiplexed by two additional outputs from the
MCU <RA7:RA6>. E. g. If the user defines an input of 01110, the displays must show a 1 and a 4 to form
the number 14.