Download Project Report - Flow Chart - Microcomputers | ECE 441 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!
FLOW CHART
Main Program
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
Start
Display “ECE > “ Read user command Comma nd = “HLP” Comma nd = “MDIS” Comma nd = “MTST” Comma nd = “DR” Comma nd = “GO” Comman d = “BSRCH” Comma nd = “MCHG” A
MDIS_EXE
MTST_EX
E
DR_EXE
GO_EXE
BSRCH_EX
E
MCHG_EXE
B
Display Help Menu
YES
NO
YES
NO
YES
A
Comman d = “HXDEC” Comman d = “DECHX” Comma nd = “QUIT” Display Error message
MCHG_EXE
MCHG_EXE
B
MTST_EXE Subroutine
YES
NO
NO
YES
YES
NO
Read Addr1, Addr2 in ASCII READARGS: Convert ASCII to HEX A1 = Addr (A1) = AA A1 = A1 + 1 A1 <= Addr A1 = Addr (A1) == AA Display Error Massage: Address, expected value, and actual value (A1) = 55 A1 = A1 + 1 A1 <= Addr A1 = Addr MTST 1
MTST
NO
YES
YES
NO
MTST
(A1) ==
MTST
(A1) = FF
A1 = A1 + 1
A1 <=
Addr
GO_EXE Subroutine Read Addr1 in ASCII encoded HEX READARGS: Convert ASCII to HEX Jump to Addr
BSRCH_EXE Subroutine
NO
YES
YES
No
YES
NO
YES
Read Addr1 and Addr2 in ASCII encoded HEX READARGS: Convert ASCII to HEX A1 = Addr A2 = Addr A3 = Starting addr of string A4 = ending addr of string D0 = 00 A0 = A A5 = A (A0)+ == (A5)+
A1 = A1 + 1
A1 >=
A
D0 ==
FF
A5 <=
A
D0 = FF
Display found message Display not found message
NO
YES
YES
NO
YES
NO
MCHG Word:
Read user input Length of input string = 2 Input string = “.” AS2HX, convert input string to HEX D0 = arrd (addr1) = D Input string = NULL Addr1 = Addr1 + 1 Display error message
NO
YES
YES
NO
YES
NO
MCHG Long Word:
Read user input Length of input string <= Input string = “.” AS2HX, convert input string to HEX D0 = arrd (addr1) = D Input string = NULL Addr1 = Addr1 + 2 Display error message
HXDEC_EXE Subroutine
YES
NO
Read Argument in HEX AS2HX: convert Argument to HEX D0 = Argument A5 = addr of buffer A6 = A D0 == 0 D1 = D0 % 10 D0 = D0 / 10 A5 = A5 – 1 (A5) = D Display result stored at buffer
DECHX_EXE Subroutine
NO
YES
Read argument (ASCII encoded DEC D1 = Length of argument – 1 D0 = 0 D 2 = 1 D 3 = 1 A5 = starting addr of the string A6 = ending addr of the string A6 = A6 – D2 = (A6) D2 = D2 – 48 D2 = D2 * D D0 = D 0 + D D3 = D3 * 10 D1 = D1 - 1 D1 == - 1 HX2AS: convert D0 to ASCII Display result
HX2AS conversion Subroutine
Description: Convert HEX to ASCII encoded HEX
Preconditions: D0 – HEX number to be converted.
A5 – Buffer to store the string
A6 – Buffer to store the string (same with A5)
D7 – number of digits to be converted.
Post-conditions: A5 – starting address of number string
A6 – ending address of number string
NO
YES YES
NO
YES
D2 = D
D2 = D2 -
D1 = D
D3 = D
D3 = D3 * 4
D1 = D1 shift right with D bits D1 = D1 F D1 is in betwee n 0 - 9 D1 is in betwee n A - F D1 = D1 + 48 D1 = D 1 + 55 (A6) = D A6 = A6 + 1 D2 = D2 - 1 D2 ==
- Display syntax error message B
READARGS Subroutine
Description: Read the string contains two arguments (addresses)
Preconditions: A0 – pointed at 1 byte before the string
A1 – pointed at I byte behind the string
Post-conditions: A1 – argument 1 (address 1)
A2 – argument 2 (address 2)
YES
NO
NO
YES
YES
NO
YES
NO
NO
YES
A0 = A0 + 1
(A0)+
A0 >= A
A5 = A
A6 = A
Display Syntax error message
B
(A6) == “
A6 = A6 + 1
AS2HX:
convert ASCII to HEX A3 = D A6 = A6 + 1 (A6)+ == “ “
HX2AS
A6 >=
A
METHOD OF IMPLEMENTATION AND TESTING
IMPLEMENTATION APPROACH
This monitor program is implemented using Bottom-up approach, which means that the
subroutines are implemented and tested before the whole monitor program is coded. The
required subroutines are implemented according to the requirements of the main, and integrated
the subroutines together using a main driver program. The only function of the main driven
program is to recognize the user’s command and pass the control to particular subroutine.
The descriptions of each subroutines are as below:
Subroutine Function Description
HLP_EXE Display Help menu.
MDIS_EXE Display the contents of memory. It takes two arguments and displays the byte
size memory between the given range.
MTST_EXE Test the memory. It takes two arguments and test the memory range between
the two memory. It first writes $AA, then $55 and finally $AA again.
DR_EXE Display the content of registers, include the special purpose registers, such as
PC, USP, SSP, SR. This implementation is done by saving all the registers to
stack and popping the registers one by one in order to display them. All the
registers have to be saved since the content of registers will be changed in the
process of ASCII to HEX or HEX to ASCII conversion.
GO_EXE Jump to execute the code specified at the given address.
BSRCH_EXE Search through a given range of memory space to find a string. The range of
memory and the string are given as the arguments of the command. The search
algorithm implemented here is linear search algorithm. This subroutine searches
through the given range of memory one by one. If the string is found, the search
will be terminated, and the search results including address of the string will be
displayed on screed.
MCHG_EXE Change the memory content at the given address. The size is optional
argument, which can be word or long word. By default, the size is byte long. In
this subroutine, the size is recognized first, then it reads user’s input and
changes the memory content according to the user input.
HXDEC_EXE Convert the given HEX number to DEC number. The algorithm used in this
conversion is shown as the pseudo code:
WHILE ( number !=0)
Temp = number % 10
number = number / 10
*BUFFER = number + 30
BUFFER + BUFFER +!
END WHILE
DECHX_EXE Convert the given DEC number to HEX number. The algorithm used is based on
the following equation:
eg. 1234 = 41 + 310 + 2100 + 1
QUIT_EXE Terminate the monitor program, restore all the register to their original state.
AS2HX Convert the ASCII encoded HEX to HEX number. It is similar to the TRAP
conversion routine.
HX2DEC_EXE Convert the HEX number to ASCII encoded HEX. The number of digits to be
converted in specified in D7.
READARGS Convert the two arguments in a string to HEX numbers and store them to
registers A1 and A2. It uses the AS2HX subroutine as base function for
conversion. It also detects any error might have in the arguments,
Program Testing
Since the Bottom-Up programming approach is using to implement this monitor program, every
single subroutines is tested before the whole program is integrated together. Using this approach,
the testing of the program and changing of the code become easier to perform.
Problems Encountered In The Process of Implementation
The only problem encounter during the implementation of the monitor program is that the
unexpected error encountered in running the real program in SANPER unit. Although the program
has been simulated in the M68000 simulator, some of the functions of the monitor program are
not working correctly. Since it takes quite a long time to transfer program to SANPER unit (about
5 to 10 minutes to transfer a 2KB program or 6KB file), the debugging process becomes
extremely difficult and time consuming.