El Croquis 196 Karamuk Kuo 2009 2018 196th Edition Fernando Márquez Cecilia Download
El Croquis 196 Karamuk Kuo 2009 2018 196th Edition Fernando Márquez Cecilia Download
https://ebookfinal.com/download/el-croquis-196-karamuk-
kuo-2009-2018-196th-edition-fernando-marquez-cecilia/
https://ebookfinal.com/download/pierre-loti-2018-critical-lives-
richard-m-berrong/
https://ebookfinal.com/download/real-time-digital-signal-processing-
implementation-and-application-2nd-edition-sen-m-kuo/
https://ebookfinal.com/download/macmillan-destination-c1-c2-grammar-
vocabulary-malcolm-mann/
https://ebookfinal.com/download/real-time-digital-signal-processing-
fundamentals-implementations-and-applications-3rd-edition-sen-m-kuo/
AutoCAD 2009 Essentials 1st Edition Munir M. Hamad
https://ebookfinal.com/download/autocad-2009-essentials-1st-edition-
munir-m-hamad/
https://ebookfinal.com/download/biotechnology-annual-review-10-1st-
edition-m-raafat-el-gewely/
https://ebookfinal.com/download/wireless-sensor-networks-from-theory-
to-applications-1st-edition-ibrahiem-m-m-el-emary-editor/
https://ebookfinal.com/download/annual-reports-on-nmr-spectroscopy-
volume-83-1st-edition-webb/
https://ebookfinal.com/download/where-there-is-no-dentist-15th-
updated-printing-2018-sept-1-2018-edition-murray-dickson/
El Croquis 196 Karamuk Kuo 2009 2018 196th Edition
Fernando Márquez Cecilia Digital Instant Download
Author(s): Fernando Márquez Cecilia, Paloma Poveda
ISBN(s): 9788494775468, 8494775464
Edition: 196
File Details: PDF, 58.59 MB
Year: 2018
Language: english
Another Random Scribd Document
with Unrelated Content
Note particularly that saving memory can be critical if it
allows a program to fit into the limited amount of ROM and RAM
available in a simple one-chip or two-chfp microcomputer. The
hardware cost for smalt systems can thus be substantrally reduced,
if their requirements can be limited to the memory size and i/0
limitations of that particular one-chip or two-chip system. 1) Replace
repetitious in-line code with subroutines. Be sura however, that the
CALL and RETURN instructions do not offset most of the gain. Note
that this replacement usually results in slower programs because of
the time spent in transferring control back and forth. 2) Use register
operations when possible. But remember the cost of the extra
initialization. 3} Use the Stack when possible. The Stack Pointer is
automatically updated after each use so that no explicit updating
instructions are necessary. 4) Eliminate Jump instructions. Try to
reorganize the program or use indirect jumps UP (HU or JP (IX or
lY)), RST, or RETURN instructions. 5) Take advantage of addresses
that you can manipulate as 8-bit quantities. These include page zero
and addresses that are multiples of 100 hexadecimal. For example,
you might try to place all ROM tables in one lOO^g-byte section of
memory, and at! RAM vanables into another lOOig-byte section. 6)
Organize data and tables so that you can address them without
worrying about address calculation carries or without any actual
indexing. This will again allow you to manipulate 16-bit addresses as
8-bit quantities. See pages 5-1 to 5-6 of Z80 Programming for Logic
Design for an example. 7) Use the 16-bit instructions to replace two
separate 8-bit operations. This may be particularly useful in
initialization or storing results. 8) Use leftover results from previous
sections of the program. 9) Take advantage of such instructions as
INC (HL), DCR {HLl, LD {HLl, RL {HU, and RR (HLi, which operate
directly on memory locations without using registers. 10) Use INC or
DEC to set or reset flag bits. 11) Use relative jumps rather than
Jumps with direct addressing. 1 2) Take advantage of the Block
Move, Block Search, and Block I/O instructions whenever you are
handling blocks of data. 13) Watch for special short forms of
instructions such as the Accumulator shifts (RLCA, RLA, RRCA. and
RRA) and DJNZ. 14) Use algorithms rather than tables to calculate
arithmetic or logical expressions and to perform code conversions.
Note that this replacement may result in slower 1 5) Reduce the size
of mathematical tables by interpolating between entries. Here again,
we are saving memory at the cost of execution time. 16) Take
advantage of the alternate register set to cut down on the use of
storage. This can save time as well. REORGANIZING TO USE LESS
MEMORY The following procedures will reduce memory usage for
Z80 assembly language programs: SAVING MEMORY programs.
Although some of the methods that reduce memory usage also save
time, you can generally save an appreciable amount of time only by
concentrating on frequently executed loops. Even SAVING
EXECUTION TIME 16-15
completely eliminating an instruction that is executed only
once can save at most a few microseconds. But a savings in a loop
that is executed frequently will be multiplied many times over. So, if
you must reduce execution time, proceed as follows: 1) Determine
how frequently each program loop is executed. You can do this by
hand or by using the software simulator or another testing method.
2) Examine the loops in the order determined by their frequency of
execution, starting with the most frequent Continue through the list
until you achieve the required reduction. 3) First, see if there are any
operations that can be moved outside the loop, i.e.. repetitive
calculations, data that can be placed into a register or the Stack,
addresses that can be placed into register pairs or index registers,
special cases or errors that can be handled elsewhere, eta Note that
this will require extra initialization and memory but will save time. 4)
Try to eliminate Jump statements. These are very time-consuming.
Or, use jumps with direct addressing that require more memory but
less time than jumps with relative addressing, 5) Replace
subroutines with in-line code. This will save at least a CALL and a
RETURN instruction. 6) Use the Stack for temporary data storage. 7)
Use any of the hints mentioned in saving memory that also decrease
execution time. These include the use of block handling instructions,
8-b(t addresses, 16-bit instructions, RST. special short forms of
instructions, eta 8) Do not oven look at Instructions that are
executed only once. Any changes that you make in such instructions
only invite errors for no appreciable gain. 9) Avoid indexed and
relative addressing whenever possible because they take extra time.
10) Use tables rather than algorithms; make the tables handle as
much of the tasks as possible even if many entries must be
repeated. MAJOR REORGANIZATIONS If you need more than a 25%
increase in speed or decrease in memory usage, do not try
reorganizing the code. Your chances of getting that much of an
improvement are small unless you call in an outside expert. You are
generally better off making a major change. ______ The most
obvious change is a better algorithm. Particularly if BETTiB you are
doing sorts, searches, or mathematical calculations, you
ALGORITHMS may be able to find a faster or shorter method in the
literature. Libraries of algorithms are available in some journals and
from professional groups. See, for example. References 1 through 10
at the end of this chapter. More hardware can replace some of the
software. Counters, shift registers, arithmetic units, hardware
multipliers, and other fast add-ons can save both time and memory.
Calculators, UARTs, keyboards, encoders, and other slower add-ons
may save memory even though they operate slowly. Compatible
parallel and serial interfaces, and other devices specially designed
for use with the Z80 may save time by taking some of the burden off
the CPU. 15-16
Other changes may help as well: 1) A CPU with a longer
word will be faster if the data is long enough. Such a CPU wilt use
less total memory. 16-bit processors, for example, use memory more
efficiently than 8-bit processors, since more of their instructions are
one word long. 2) Versions of the CPU may exist that operate at
higher clock rates. But remember that you will need faster memory
and I/O ports, and you will have to adjust any delay loops. 3) Two
CPUs may be able to do the Job In parallel or separately if you can
divide the job and solve the communications problem. 4) A specially
microprogrammed processor may be able to execute the same
program much faster. The cost however, will be much higher even if
you use an offthe-shelf emulation. 51 You can make tradeoffs
between time and memory. Lookup tables and function ROMs will be
faster than algorithms, but will occupy more memory. This kind of
problem, in which a large improvement is neces- DECIDING sary,
usually results from lack of adequate planning in the ON A MAJOR
definition and design stages. In the problem definition stage
CHANGE you should determine which processor and methods will be
adequate to handle the problem. If you misjudge, the cost later will
be high. A cheap solution may result in an unwarranted expenditure
of expensive development time. Do not try to Just get by; the best
solution is usually to do the proper design and chalk a failure up to
experience. If you have followed such methods as flowcharting,
modular programming, structured programming, top-down design,
and proper documentation, you will be able to salvage a lot of your
effort even if you have to make a major change. OTHER MAJOR
CHANGES 15-17
REFERENCES 1. Coltected Algorithms from ACM, ACM. Inc.,
P 0. Box 12105. Church Street Station. New York 10249. 2. Chen. T.
C. "Automatic Computation of Exponentials. Logarithms. Ratios, and
Square Roots," IBM Journal of Research and Development. Volume
18, pp. 380-388. July, 1972. 3. H. Schmid, Decimal Computation.
Wiley-lntersctence. New York, 1974. 4. Knuth. D, E., The Art of
Computer Proqrammmg, Volume 1: Fundamental Aloorithms,
Addison-Wesley, Reading. Mass.. 1967. 5. Knuth. D. E.. The Art of
Computer Programming, Volume 2: Semmumerical Algorithms.
Addison-Wesley. Reading, Mass., 1969. 6. Knuth, D. E., The Art of
Computer Programming. Volume 3: Sorting and Searchmg, Addison-
Wesley, Reading. Mass.. 1973. 1. Carnahan. B. et al.. Applied
Numerical Methods. Wiiey, New York. 1969. 8. Despam. A. M.
"Fourier Transform Computers Using CORDIC Iterations," IEEE
Transactions on Computers. October 1974. pp. 993-1001, 9. Luke, Y
L., Algorithms for the Computation of Mathematical Functions,
Academic Press, New York. 1977 10. Hwang, K., Computer
Anthmetic. Wiley, New York. 1978. 11. Dollhoff. T,. "Microprocessor
Software: How to Optimize Timing and Memory Usage. Part Four:
Techniques for the Zilog Z80." Digital Design. February 1977, pp. 44-
51. 15-18
Chapter 16 SAMPLE PROJECTS PROJECT #1 : A Digital
Stopwatch Purpose: This project is a digital stopwatch. The operator
enters STOPWATCH two digits (minutes and tenths of minutes) from
a INPUT catculator-iike keyboard and then presses the GO key,
PROCEDURE The system counts down the remaining time on two
seven-segment LED displays (see Chapter 11 for a description of
unencoded keyboards and LED displays). Hardware: The project
uses one input port and one output port (one Z80 Parallel
Input/Output Device or PIO), two seven-segment displays, a 12-key
keyboard, a 7404 inverter, and either a 7400 NAND gate or a 7408
AND gate, depending on the polarity of the seven-segment displays.
The displays may require drivers, inverters, and resistors, depending
on their polarity and configuration. The hardware is organized as
shown in Figure 16-1. Output lines 0, 1, and 2 are used to scan the
keyboard. Input lines 0. 1,2, and 3 are used to determine whether
any keys have been pressed. Output lines 0, 1,2. and 3 are used to
send BCD digits to the sevensegment decoder/drivers. Output line 4
ts used to activate the LED displays (if line 4 is 'V, the displays are
lit). Output line 5 is used to select the left or right display; output
line 5 is '1' if the left display is being used, '0' if the right display is
being used. Thus, the common line on the left display should be
active if line 4 is '1' and line 5 is 'V, while the common line on the
right display should be active if line 4 is '1' and line 5 is '0' Output
line 6 controls the right-hand decimal point on the left display. It
may be dnven with an inverter or simply left on. Keyboard
Connections: The keyboard is a simple calculator keyboard available
for 50(tfrom a local source. It consists of 12 unencoded key-switches
arranged in four rows of three columns each. Since the wiring of the
keyboard does not coincide with the observed rows and columns,
the program uses a table to identify the keys. Tables 16-1 and 1 6-2
contain the input and output connections for the keyboard. The
decimal point key is present for operator convenience and for future
expansion; the current program does not actually use the key. In an
actual application, the keyboard would require pullup resistors to
ensure that the inputs would actually be read as logic '1's when the
keys were not being pressed. It would also require current-limiting
resistors or diodes on the output port to avoid damaging the drivers
in the case where two outputs were driving against each other. This
could occur if two keys in the same row were pressed at the same
time, thus connecting two different column outputs. 16-1
The text on this page is estimated to be only 26.71%
accurate
16-3
Display Connections: The displays are seven-segment
displays with their own integral decoders. A typical example would
be the Texas Instruments TIL309 device, which has an internal TTL
MSI chip with latch, decoder, and driver. Clearly, standard seven-
segment displays would be cheaper but would require some
additional software (the seven-segment conversion routine shown In
Chapter 7). Data is entered into the display as a smgle binary coded
decimal digit; the digits are represented as shown in Figure 11-15.
The decimal point is a smgle LED that is turned on when the decimal
point input is a logic '1' You can find more information about displays
in References 10 and 1 1 at the end of this chapter. Program
Description: The program is modular and has several subroutines.
The emphasis is on clarity and generality rather than efficiency;
obviously, the program does not utilize the full capabilities of the Z80
processor. Each section of the listing will now be described in detail.
1) Introductory Comments The introductory comments fully describe
the program; these comments are a reference so that other users
can easily apply, extend, and understand the program. Standard
formats, indentations, and spacings increase the readability of the
program. 2) Variable Definitions All variable definitions are placed at
the start of the program so that they can easily be checked and
changed. Each variable is placed in a list alphabetically with other
variables of the same type; comments describe the meaning of each
variable. The categories are: a} Memory system constants that may
vary from system to system depending on the memory space
allocated to different programs or types of memories b) Temporary
storage (RAM) used for variables c) 1/0 (PIO) port addresses d)
Definitions The memory system constants are placed in the
definitions so that the user may relocate the program, temporary
storage, and memory stack without making any other changes. The
memory constants can be changed to accommodate other programs
or to coincide with a particular system's allocation of ROM and RAM
addresses. Temporary storage is allocated by means of DEFS (Define
Storage) pseudo-operations. An ORG (origin) pseudo-operation
places the temporary storage locations in a particular part of
memory. No values are placed in these locations so that the program
could eventually be placed in ROM or PROM and the system could be
operated from power-on reset without reloading. Each port address
occupied by a PIO is named so that the addresses can easily be
changed to handle varied configurations. The naming also serves to
clearly distinguish control registers from data registers. The
definitions clarify the meaning of certain constants and allow
parameters to be changed easily. Each definition is given in the form
(binan/. hex, octal. ASCII, or decimal) m which its meaning is the
clearest Parameters (such as debounce time) are placed here so that
they can be varied with system needs. 16-4
3) Initialization Memory location 0 (the reset location on the
Z80 microprocessor) contains a |ump to the starting address of the
main program. The main program can thus be placed anywhere in
memory and reached via a "RESET" signal. The initialization consists
of four steps: a) Place a starting value in the Stack Pointer. The
Stack is used on!y to store subroutine return addresses. b) Configure
the PIO control registers. c) Start the number of digit keys pressed
at zero. d) Initialize the location where the next digit key pressed will
be saved to the start of the digit key array. An indirect procedure is
used, in which KEYAD contains the address in which the next digit
will be placed. Each time a digit key is recognized, the contents of
KEYAD are incremented so that the next digit key will be placed into
the next memory location. 4) Look for Key Closure Flowchart: Key
closures are identified by grounding alt the keyboard columns and
then checking for grounded rows {i.e.. column-to-row switch
closures). Note that the program does not assume that the unused
input bits are all high; instead, the bits attached to the keyboard are
isolated with a logical AND instruction. 5) Debounce Key The
program debounces the key closure in software by waiting for two
milliseconds. This is usually long enough for a clean contact to be
made. Subroutine DELAY simply counts with Register C for 1
millisecond. The number of milliseconds is m the Accumulator.
DELAY would have to be adjusted if a slower clock or slower
memories were being used. You could make the change simply by
redefining the constant MSCNT. Ground all keyboard cofumns 16-5
identify Key Closure Flowchart: Start ^ J S8t kev table
pointer to KTAB - 1 Set pattern pointer to PATT Ground a keyboard
column by output of {pattern pointer) C Increment Itey table pointer
by the number of keys in a column (KCOL) Increment Increment key
tabi? pointer by t Shift keyboard input right 1 bit Key ID = {key table
pointer) Use key table pointer to get key !D The particular key
closed is identified by grounding single columns and observing
whether a closure is found. Once a closure is found (so the key
column is known), the key row can be determined by shifting the
input The patterns required to ground single keyboard columns are
in a table PATT in memory. The final pattern m the table is a marker
(ECODE) which indicates that ail the columns have been grounded
without a closure being found. This pattern also indicates to the
main program that the closure could not be identified (e.g., the key
closure ended or a hardware error occurred before we could find the
closure). 16-6
The key identifications are in table KTAB in memory. The
KEY keys in the first column (attached to the least significant out-
TABLE put bit) are followed by those in the second column, etc.
Within a column, the key in the row attached to the feast significant
mput bit is first etc. Thus, each time a column is scanned without
finding a closure, the number of keys in a column (NROWS) must be
added to the key table pointer in order to move to the next column.
The key table pointer is also incremented by one before each bit In
the row inputs is examined; this process stops when a zero input is
found. Note that the key table pointer is started one location before
the table, since it is always incremented once in the search for the
proper row. If we cannot identify the key closure, we simply ignore it
and look for another closure. 7) Act on Key Identification If the
program has enough digits {two m this simple case), it looks only for
the GO key and ignores all other keys. If it finds a digit key, it saves
the value In the key array, increments the number of digit keys
pressed, and increments the key array pointer. If the entry is not
complete, the program must wait for the key closure to end so that
the system will not read the same closure again. The user must watt
between key closures (i.e.. release one key before pressing another
one). Note that the program will identify double key closures as one
key or the other, depending on which closure the identification
routine finds first. An improved version of this program would display
digits as they were entered and would allow the user to omit a
leading or trailing zero, (i.e., key in "7".. "GO" to get a count of
seventenths of a minute). 8) Set Up Display Output The digits are
placed in registers or memory locations with bit 4 set so that the
output is sent to the displays. Bits 5 and 6 are set for the most
significant digit to direct the output to the left display and to turn on
the decimal point 9) Pulse the LED Displays Each display is turned on
for two milliseconds. This process is repeated 1500 times in order to
get a total delay of 0.1 minutes, or 6 seconds. The pulses are
frequent enough so that the LED displays appear to be lit
continuously. 16-7
10) Decrement Display Count Flowchart: Loft Display - 1
«9ht Display = 9 End of timer program C 1 The value of the less
significant digit is reduced by one. If this affects bit 4 {LEDON —
used to turn the displays on}, the digit has become negative. A
borrow must then be obtained from the more significant digit. If the
borrow fronn the more significant digit affects bit 4, the count has
gone past zero and the countdown is finished. Otherwise, the
program sets the value of the less significant digit to 9 and
continues. Note that comments describe both sections of the
program and individual statements. The comments explain what the
program is doing, not what specific instruction codes do. Spacing
and Indentation have been used to improve readability. 16-8
PROGRAM NAME: TIMER :DATE OF PROGRAM: 10/24/78
PROGRAMMER; LANCE A. LEVENTHAL PROGRAM REGUiREMENTS;
D1 {209) BYTES RAM REOUIREMENTS: 5 BYTES 1/0
REQUIREMENTS; 1 INPUT PORT, 1 OUTPUT PORT (1 Z80 PIO) ,TH!S
PROGRAM IS A SOFTWARE TIMER WHICH ACCEPTS INPUTS FROM
A ; CALCULATOR-UKE KEYBOARD AND THEN PROVIDES A
STOPWATCH . COUNTDOWN ON TWO 7-SEGMENT LED DISPLAYS
IN MINUTES AND TENTHS . OF MINUTES :KEYBOARD :A 12-KEY
KEYBOARD IS ASSUMED JHREE COLUMN CONNECTIONS ARE
OUTPUTS FROM THE PROCESSOR , SO THAT A COLUMN OF KEYS
CAN BE GROUNDED POUR ROW CONNECTIONS ARE INPUTS TO
THE PROCESSOR SO THAT . COMPLETED CIRCUITS CAN BE
IDENTIFIED ;THE KEYBOARD IS DEBOUNCED BY WAITING FOR
TWO MILLISECONDS ; AFTER A KEY CLOSURE IS RECOGNIZED :A
NEW KEY CLOSURE IS IDENTIFIED BY WAITING FOR THE OLD ONE
: TO END SINCE NO STROBE IS USED ,THE KEYBOARD COLUMNS
ARE CONNECTED TO BITS 0 , TO 2 OF THE PIO B PORT THE
KEYBOARD ROWS ARE CONNECTED TO BITS 0 . TO 3 OF THE PIO A
PORT ;DiSPLAYS ;TWO 7-SEGMENT LED DISPLAYS ARE USED WITH
SEPARATE DECODERS ; (7447 OR 7448 DEPENDING ON THE TYPE
OF DISPLAY) ,THE DECODER DATA INPUTS ARE CONNECTED TO
BITS 0 TO 3 : OF THE PIO B PORT :8iT 4 OF THE PIO B PORT IS
USED TO ACTIVATE THE LED : DISPLAYS (BIT 4 IS 1 TO SEND DATA
TO LEDS) :BIT 5 OF THE PIO B PORT IS USED TO SELECT WHICH i
LED IS BEING USED (BIT 5 IS 1 IF THE LEADING DISPLAY . IS
BEING USED. 0 IF THE TRAILING DISPLAY IS BEING USED) ;BIT 6
OF THE PIO B PORT iS USED TO LIGHT THE DECIMAL . POINT LED
ON THE LEADING DISPLAY (BIT 6 IS 1 IF , THE DISPLAY IS TO BE
LIT) ; METHOD ;STEP 1 - INITIALIZATION ; THE MEMORY STACK
POINTER {USED FOR SUBROUTINE RETURN , ADDRESSES) IS
INITIALIZED. THE NUMBER OF DIGIT KEYS PRESSED IS SET . TO
ZERO, AND THE ADDRESS INTO WHICH THE NEXT DIGIT KEY ,
IDENTIFICATION WILL BE PLACED IS INITIALIZED TO THE FIRST
ADDRESS . IN THE DIGIT KEY ARRAY STEP 2 - LOOK FOR KEY
CLOSURE ALL KEYBOARD COLUMNS ARE GROUNDED AND THE
KEYBOARD ROWS ARE EXAMINED UNTIL A CLOSED CIRCUIT IS
FOUND 16-9
:STEP 3 - DEBOUNCE KEY CLOSURE . A WAIT OF 2 MS IS
INTRODUCED TO ELIMINATE KEY BOUNCE ;STEP 4 - IDENTIFY KEY
CLOSURE , THE KEY CLOSURE IS IDENTIFIED BY GROUNDING
SINGLE KEYBOARD COLUMNS AND DETERMINING THE ROW AND
COLUMN OF THE KEY ; CLOSURE. A TABLE IS USED TO ENCODE
THE KEYS ACCORDING TO THEIR ; ROW AND COLUMN NUMBER ;
IN THE KEY TABLE, THE DIGITS ARE IDENTIFIED BY THEIR
VALUES. , THE DECIMAL POINT KEY IS NO. 10. AND THE "GO" KEY
IS NO. 1 1 ;STEP 5 - SAVE KEY CLOSURE ; DIGIT KEY CLOSURES
ARE SAVED IN THE DIGIT KEY ARRAY UNTIL TWO DIGITS HAVE
BEEN IDENTIFIED. DECIMAL POINTS. FURTHER DIGITS. ; AND
CLOSURES OF THE "GO" KEY BEFORE TWO DIGITS HAVE BEEN ;
IDENTIFIED ARE IGNORED : AFTER TWO DIGITS HAVE BEEN
FOUND. THE "GO" KEY IS USED TO . START THE COUNTDOWN
PROCESS ;STEP 6 - COUNT DOWN TIMER INTERVAL ON LEDS ; A
COUNTDOWN IS PERFORMED ON THE LEDS WITH THE LEADING
DIGIT . REPRESENTING THE REMAINING NUMBER OF MINUTES
AND THE TRAILING ; DIGIT REPRESENTING THE REMAINING
NUMBER OF TENTHS OF MINUTES :TIMER VARIABLE DEFINITIONS
iMEMORY SYSTEM CONSTANTS BEGIN EQU 50H LASTM EQU 1000H
TEMP EQU 800H :RAM TEMPORARY STORAGE ORG TEMP KEYAD:
DEFS 2 KEYNO: DEFS NKEYS: DEFS :l/0 UNITS AND PIO
ADDRESSES PIODRA EQU PIOCRA EQU PIODRB EQU PIOCRB EQU
;DEFiNmONS DECPT EQU OEOH 0E2H DE1H 0E3H ;BEGIN IS
STARTING MEMORY LOCATION . FOR PROG ;LASTM IS STARTING
STACK ADDRESS ;TEMP IS START OF RAM STORAGE KEYAD HOLDS
THE ADDRESS IN THE DIGIT KEY ARRAY IN WHICH THE
IDENTIFICATION OF THE NEXT DIGIT KEY WILL BE PLACED KEYNO
IS THE DIGIT KEY ARRAY - IT HOLDS THE IDENTIFICATIONS OF
THE DIGIT KEYS THAT HAVE BEEN PRESSED NKEYS HOLDS
NUMBER OF DIGIT KEYS PRESSED ■.INPUT PIO FOR KEYBOARD
:OUTPUT PIO FOR KEYBOARD AND ; DISPLAY ;BIT POSITION TO
TURN ON DECIMAL ; POINT LED 16-10
ECODE ECU OFFH KEY GOKEY EQU 11 :IDENTIFICAT!ON
NUMRFR FOR "an" k'FV LEDON EQU 4 RIT Pn^lTIOM TO ciPKin ni
itpi \t xn i cnc LEDSL EQU 5 BIT POSITION TO '^Fl FCT 1 FADIKin
DISPi AY t Lj* f vJi t_rA i MSCNT EQU 0F9H COUNT NFFDFn TO niVF
1 npi av tik/ip MXKEY EQU 2 MAXIM! IM Ml iMRFR HP nmiT k'cv
CLOSURFS [J^FD NROWS EQU 4 ;NUMBER OF ROWS IN KEYBOARD
OR KEYS ; IN COLUMN OPEN EQU 00001 111B ;INPUT FROM
KEYBOARD IF NO KEY . CLOSED TPULS EQU 2 iNUMBER OF MS
BETWEEN DIGIT DISPLAYS TWAIT EQU 2 :NUMBER OF MS TO
DEBOUNCE KEYS ORG 0 ; RESET ROUTINE TO REACH TIMER
PROGRAM JP BEGIN ;FIND TIMER PROGRAM :INIT!ALIZATION OF
TIMER PROGRAM ORG BEGIN LD A.01001111B ;MAKE PIO PORT A
INPUT OUT (PIOCRA),A LD A,00001111B ;MAKE PIO PORT B
OUTPUT OUT {PIOCRB),A LD SP.LASTM :PUT STACK AT END OF
MEMORY SUB A LD (NKEYS).A ;NUMBER OF DIGIT KEYS PRESSED =
ZERO LD HLKEYNO iSTARTING LOCATION FOR DIGIT KEYS LD
{KEYADl.HL ;SCAN KEYBOARD LOOKING FOR KEY CLOSURE START:
CALL SCANC ;WAIT FOR KEY CLOSURE ;WAIT FOR KEY TO BE
DEBOUNCED LD A.TWAIT ;GET DEBOUNCE TIME IN MS CALL DELAY
:WAIT FOR KEY TO STOP BOUNCING IDENTIFY WHICH KEY WAS
PRESSED CALL IDKEY ;IDENTIFY KEY CLOSURE CP ECODE ;WAS
KEY CLOSURE IDENTIFIED? JR Z.START :N0. WAIT FOR ANOTHER
CLOSURE ;ACT ON KEY IDENTIFICATION 16-11
LD B,A SAVE KEY NUMBER LD HLNKEYS CHECK FOR
MAXIMUM NUMBER OF DIGIT KEYS LD A,(HL) CP MXKEY HAS
MAXIMUM BEEN REACHED^ JR Z,KEYF YES, LOOK FOR GO KEY LD
A.B NO, LOOK FOR DIGIT KEYS ONLY CP 10 IS THIS KEY A DIGIT?
JR NC.WAITK NO, IGNORE IT iNC (HU YES, INCREMENT DIGIT KEY
COUNTER LD HL(KEYAD) SAVE KEY NUMBER IN ARRAY LD (HU,A
INC HL LQ {KEYAD),HL ■WAIT FOR CURRENT KEY CLOSURE TO
END WAITK; CALL SCANO ;WA!T FOR KEY TO BE RELEASED JR
START ;G0 LOOK FOR NEXT KEY :LOOK FOR GO KEY IF ENOUGH
DIGITS FOUND KEYF; LD A.B GET NUMBER OF KEY PRESSED CP
GOKEY IS IT "GO" KEY? JR NZ.WAITK NO. IGNORE IT •PUT DIGITS
INTO REGISTERS FOR DISPLAY LD HLKEYNO LD D.iHL) GET
LEADING DIGIT SET DECPT.D TURN ON DECIMAL POINT SET
LEDON.D SET OUTPUT TO LEDS SET LEDSL.D SELECT LEADING
DISPLAY INC HL LD E.(HL) GET TRAILING DIGIT SET LEDON,E SET
OUTPUT TO LEDS ;PULSE THE LED DISPLAYS LD C.PIODRB .GET
OUTPUT PORT ADDRESS LEDLP: LD H.6 SET COUNTERS FOR 6
SECONDS TLOOP: LD B,250 LDPUL: OUT {C).D ;OUTPUT LEADING
DIGIT TO LED 1 LD A.TPULS ;DELAY BETWEEN DIGITS CALL DELAY
OUT (C).E iOUTPUT TRAILING DIGIT TO LED 2 LD A.TPULS :DELAY
BETWEEN DIGITS CALL DELAY DJNZ LDPUL DEC H JR NZ.TLOOP
;DECREMENT COUNT ON LED DISPLAYS 16-12
DEC E :COUNT DOWN TRAILING DIGIT BIT LEDON.E ;iS
TRAILING DIGIT PAST ZERO? JR NZ.LEDLP ;N0, CONTINUE DEC D
-.COUNT DOWN LEADING DIGIT BIT LEDON.D :IS LEADING DIGIT
PAST ZERO? JP Z,BEGIN ;YES, WAIT FOR NEXT TIMING TASK LD
E,9 ;N0, SET TRAILING DIGIT TO 9 SET LEDON.E ;SET OUTPUT TO
LEDS JR LEDLP ;RETURN TO DISPLAY SECTION :SUBROUTiNE
SCANC SCANS THE KEYBOARD WAITING FOR A KEY CLOSURE ;ALL
KEYBOARD INPUTS ARE GROUNDED SCANC; SUB A ;GROUND ALL
KEYBOARD COLUMNS OUT (PIODRBKA IN A.iPIODRA) AND OPEN
;IGNORE UNUSED INPUTS CP OPEN :ARE ANY KEYS CLOSED? JR
Z.SCANC :N0. CONTINUE SCANNING RET ;SUBROUTINE DELAY
WAITS FOR THE NUMBER OF MILLISECONDS SPECIFIED ; IN
REGISTER A DELAY^ EXX ;SAVE USER REGISTERS DLYl ; LD
C.MSCNT :LOAD REGISTER C FOR 1 MS WTLP: DEC C :WAIT 1 MS
JR NZ.WTLP DEC A ;COUNT DOWN NUMBER OF MS JR NZ.DLY1 EXX
;RESTORE USER REGISTERS RET iSUBROUTINE IDKEY
DETERMINES THE ROW AND COLUMN NUMBER OF THE , KEY
CLOSURE AND IDENTIFIES THE KEY BY USING A TABLE IDKEY: LD
BCPATT ;POINT TO SCAN PATTERNS LD HL,KTAB-1 ;START KEY
TABLE POINTER LD DE.NROWS ;GET NUMBER OF KEYS IN A
COLUMN ;SCAN KEYBOARD COLUMNS SUCCESSIVELY LOOKING
FOR CLOSURE FCOL; LD A. {BO :GET PATTERN TO GROUND
COLUMN CP ECODE ;ALL COLUMNS SCANNED? RET Z :YES,
RETURN WITH ERROR CODE OUT (PIODRB).A :SCAN COLUMN IN
A.iPIODRA) AND OPEN JGNORE UNUSED INPUTS CP OPEN ;ANY
KEYS IN THIS COLUMN CLOSED? JR NZ.FROW :YES, GO
DETERMINE CLOSURE ROW ADD HUDE ;N0, MOVE KEY TABLE
POINTER TO ; NEXT COLUMN INC BC :POtNT TO NEXT SCAN
PATTERN JR FCOL 16-13
;DETERMtNE ROW NUMBER OF CLOSURE FROW: INC
RRCA JR HL CFROW MOVE KEY TABLE POINTER TO NEXT ROW
NEXT ROW GROUNDED? NO, KEEP LOOKING ;IDENTIFY KEY FROM
TABLE LD RET A.iHL) ;GET KEY NUMBER ;SCAN PATTERNS USED TO
GROUND ONE COLUMN AT A TIME • ERROR PATTERN USED TO
INDICATE THAT ALL COLUMNS HAVE BEEN SCANNED ;THE COLUMN
ATTACHED TO OUTPUT BIT 0 IS SCANNED FIRST, THEN . THE ONE
ATTACHED TO OUTPUT BIT 1, ETC. PATT: DEFB DEFB DEFB DEFB
0000011 OB 00000101 B 00000011 B ECODE KEYBOARD TABLE
COLUMNS ARE PRIMARY INDEX, ROWS SECONDARY INDEX THE
KEYS IN THE COLUMN ATTACHED TO OUTPUT BIT 0 ARE
FOLLOWED BY THOSE IN THE COLUMN ATTACHED TO OUTPUT BIT
1. ETC. WITHIN A COLUMN, THE KEY ATTACHED TO INPUT BIT 0 IS
FIRST FOLLOWED BY THE ONE ATTACHED TO INPUT BIT 1. ETC.
THE DIGIT KEYS ARE 0 TO 9. DECIMAL POINT tS 10. GO IS 1 1
DEFB 3 CO.RO DEFB 2 C0,R1 DEFB 0 C0,R2 DEFB 4 caR3 DEFB 8
C1,R0 DEFB 9 CI.RI DEFB 1 C1.R2 DEFB 11 C1.R3 DEFB 5 C2.R0
DEFB 6 C2,R1 DEFB 7 C2,R2 DEFB 10 C2,R3 :SUBROUTINE SCANO
SCANS THE KEYBOARD WAITING FOR KEY CLOSURE TC , END SO
NEXT CLOSURE CAN BE FOUND SUB A ;GROUND ALL KEYBOARD
COLUMNS OUT (P!ODRB),A IN A,(P!ODRA) AND OPEN ;IGNORE
UNUSED INPUTS CP OPEN ;ARE ANY KEYS STILL CLOSED? JR
NZ.SCANO ;YES, CONTINUE SCANNING RET END 16-14
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com