You are on page 1of 4

The hardware simulation requires the origin address to start at 2000H.

LXI SP, 3FF0H will allow


stack pointer to initialize and point to address 3FF0H. In order to set port A and port B as output and
port C as input, the control word 89H (10001001) is created. Next is send the control word to control
register to complete the input output port configure. To let the port A and port B 7-segment perform
“00” at the start of the project, the data value 3FH must be display on both port. LXI D,3100H and LXI
H,3000H is to set the DE and HL as the memory pointer of 3000H and 3100H to store the data value and
much easier to load the data value when the program need the value again. After stored, the data 3FH is
move the accumulator to display out the output (segment“0”) in port A 80H and port B 81H.
After the output “00” is displayed on both 7-segment, we need to configure the port C as switch to let
the 7-segment count after we toggle the switch(on) and pause if we toggle again the switch(off). First,
we need to set port C as switch by using SWITCH: IN 82H. after that compare port C with immediate
data with instruction CPI 01H. there are 2 conditions after compare, which is 0(off) then the program
will continue loop back until the switch is on (with signal 1). So we use JNZ condition to loop back to
continue check switch when the switch is off. Next if the switch is on, then the program will continue
display and count from “1” to “9” in port A 7-segment.
After the port A 7-segment reach “9”, then we need to make the port A 7-segment to become “0” and
port B 7-segment to increase by 1. So after the port A 7-segment display reach “9”, we need to call PLUS
subroutine in order to perform a carry display. After the carry done, the port A 7-segment need to reset
to “0” so we use call ZERO subroutine then jump back to the very first “0” 7-segment and start to count
from “0” to “9”.
For the PLUS subroutine, we store all the data need to display from “1” to “9” into address 3101H to
3109H. After the program call PLUS subroutine, to perform 7-segment “1” we need to increase register
pair by 1 from 3100H (DE that set earlier) to 3101H to take the data out from correct address. These
steps repeat every time the port A 7-segment done 1 loop (from 1 to 9). Next the subroutine will return
to the main program.

You might also like