Dokumen - Tips 8085 Microprocessor Training Kit Users Manual Wwwkswichitcommtk 85usermanual3pdfpdf
Dokumen - Tips 8085 Microprocessor Training Kit Users Manual Wwwkswichitcommtk 85usermanual3pdfpdf
User's Manual
Getting Started…..………………………………………………………………4
Connecting Terminal..……………………………………….…………………16
Hardware……………………………………………………………………….23
2
Overview
The MTK-85 is a low-cost single board computer designed for self-learning the
popular 8085 Microprocessor. The kit enables studying from low level
programming with direct machine code entering to high level programming with
PC tools easily. A nice feature, single-step running, helps students learn the
operation of microprocessor instructions quickly and clearly. The user registers
provide simple means to verify the code execution. Using a PC as the terminal, the
MTK-85 can receive the Intel hex file and disassemble the machine code into 8085
instructions.
Hardware Features:
3
• Simple I/O Port: 8-bit GPIO built with 74LS175 D-type F-F and 74LS126
Tri-state buffer
• Programmable Ports: two 8255 chips, system and user ports
• Programmable Counter: 8254
• UART: 16C550 compatible UART chip
Software Features:
4
Getting Started
AC Adapter
The MTK-85 board requires DC power input to operate. The input voltage accepts
from +6V to +12V. You may find any AC-to-DC adapter having DC jack with
polarity as shown in Figure 2. The board has protection diode to prevent wrong
polarity. If your adapter’s jack has different polarity, when plug it to the board, no
power will be supplied.
- +
Figure 2: Polarity of DC jack.
The common AC adapters mostly provide +12VDC output. You can use it also.
However dissipation at the LM2940 will be higher. For example, the developed
potential will be 12V-5V=7V. So heat dissipation will be 350mA x 7V=2.5W!
When power up the board, the 8085 begins read the instruction from the memory
at location 0000H. The location from 0000H to 7FFFH or 32kB is ROM space. It
contains the monitor program. The monitor program enables us to enter 8085
instruction using HEX digit into the RAM. We can let the 8085 RUN our program
easily using monitor key GO.
When the board was powered up, the cold message running text 8085 will show
on 7-segment LED and the onboard dot LED will turn on and the buzzer will
sound beep. The HOME location is pointed to RAM at address 8100H. The data
LED will display the content at 8100H.
The MTK-85 has 6 digits 7-segment LED and 28 tact switches keypad.
5
Four digits labeled with text “ADDRESS” is used for displaying the memory
address and user registers contents. Two digits labeled with text “DATA” is for
displaying the 8-bit data byte at address shown in the left-hand. The dot indicator
indicates the current mode of HEX digit entering. Figure 3 shows the memory
location 8100 has an 8-bit data, 1E. The dot indicates the current mode is data
entry. Typing Hex key will insert hex digit into data memory.
Keypad has two groups: the left-hand is 16-hex key 0-F and the right-hand is 10-
function key. The hex key also has alternate functions when used with ALT key.
6
Let’s see the functions key as follows.
RESETis hardware reset. Press reset will force the CPU begins execution the
ROM monitor at address 0000H. (The reset out signal
which is active high also feed to reset pins of the
UART and two 8255 PPI).
ADDR changes current mode to ADDRESS entry mode. The dot indicator will
move to ADDRESS filed.
DATA changes current mode to DATA entry mode. The dot indicator will move
to DATA filed.
Key + increments current address by one. The content of new address will show in
data field LED.
Key - decrements current address by one. The content of new address will show in
data field LED.
HOME brings home address back to current display. The home address is 8100H.
ALT enables alternate functions that used with HEX key. We can press ALT
followed with HEX key. The Alternate functions are
described below.
ALT 0 displays user register AF. The Accumulator and Flag registers. Contents of
accumulator is high byte and Flag is low byte.
7
ALT 9 displays HALF CARRY flag.
ALT D deletes one of the current location and shifts the next byte UP.
ALT E inserts one byte and shifts the next byte DOWN.
GO forces CPU to jump from monitor program to user program at current address.
MOD modifies the user registers. It was used together with ALT 0-5.
User registers are the memory space in RAM prepared for saving and loading to the CPU
registers when the CPU jump from monitor program to user program and back to the
monitor program. It is useful for program debugging. We will learn how to use them easily
in the program testing section.
Test Program 1
Let’s learn how to use hex keypad to help enter the computer code to memory and
test run it. Suppose we want to write the program that displays the contents of the
accumulator using onboard 4-bit dot LED. Since the MTK-85 has 4-bit dot LED
tied to the 4-bit output port. Logic ‘1’ presents at a given bit will make the LED
ON. Logic ‘0’ makes the LED OFF. We will write the small program that shows
the low nibble of the accumulator contents.
8
Figure 4: Sending the Accumulator content to the PORT.
We see that the program has only three instructions, i.e., inr a, out 0 and jmp main.
The program was written using 8085 instructions. To test our program, we must
translate above program into the machine code. This can be done easily with hand-
code assembly. See Appendix E for machine code of the instructions.
Since we will write the machine code to the memory for testing, so the space must
be RAM. We must know the memory allocation. Figure 5 shows the memory
space allocation. We see that the board provides begin address for user program at
8100H. Some of the locations from 8000H to 803CH are reserved for interrupts
vectors. The RAM locations from F000H to FFFFH are used by monitor program.
9
Figure 5: Memory space allocation.
Thus we can place our machine code started at location 8100. After translation we
get the code for each instruction easily.
The 1st instruction, inr a, increments the accumulator by one. It has one byte
machine code 3C. This byte will be placed at location 8100.
The 2nd instruction, out 0, write accumulator contents to the port at location 00 has
two bytes machine code, D300. D3 is the instruction OUT and 00 is port location.
10
Figure 6: I/O space allocation.
The 3rd instruction, jmp main, jump back to location 8100 has three bytes machine
code, C3,00,81. C3 is the JMP, and 8100 is location to be jump (Intel places low
byte to low address and high byte to high address).
Above program has only 6 bytes. We can enter such code into RAM easily using
HEX key. Here is the byte sequence from address 8100 to 8105.
ADDRESS DATA
8100 3C
8101 D3
8102 00
8103 C3
8104 00
8105 81
Step 1 Press RESET, the address display will show 8100 and the data LED will
show its contents.
11
The current mode will be data entry. We can swap entry mode for hex key
between address and data by pressing key ADDR or DATA. The DOT indicator
will swap between ADDR mode and DATA mode.
The address display will show 8101. Then repeat step1 until 81 byte was entered
to address 8105.
You can use key + or key - to check the hex code, you can modify it easily in
DATA entry mode.
We will begin set the value to user Accumulator beforehand. It will clear the user
register A to zero.
Press key ALT, 0/AF, display will show the content of user Accumulator and Flag
register.
Press key STEP, the display will show next instruction to be executed at address
8101. We can examine the content of AF by key ALT, 0/AF. We see that now
Accumulator is 01.
Press key STEP again, the 01 will send to LED onboard GPIO. This is the content
of the accumulator after increment instruction.
We can keep press key STEP, we will see everytime the instruction out 0 was
executed, the value of accumulator will write to the GPIO LED.
It works! This demonstration how STEP key helps running the program single
instruction.
Instead of execution one instruction using single step, we can run the program
without stopping for each instruction. We will try with key GO.
12
Now press HOME to bring current location to 8100, press RUN.
There are two methods of program running. First is to use single stepping. This
kind executes only one instruction at a time when we press STEP key. We can
learn the operation easily with user registers. The monitor program loads the
contents of user registers to the CPU registers beforehand, after the instruction has
been executed, the contents of CPU registers will then be saved back to the user
registers. Thus we can examine the result after the instruction has been executed
easily.
But above program, when we try with key GO, the CPU will jump from monitor
program to user program and never get back to monitor program. Since the
instruction JMP 8100 will jump back to 8100 forever. We see that the number
incrementing in the accumulator will be very fast.
How can we make the speed of counting slower? We can just simply add the job
that uses CPU time. Now let’s see below program.
I suppose now you can translate the instruction into the machine code. The first
mnemonic, ORG is not 8085 instruction. It is the assembler directive that tells the
13
assembler program to place the hex code begins at location 8100. We will learn
using assembler when using PC tools on later.
The portion of inserted code is bolded letters. We see that the method of time
delay is just to let the CPU counts the value in register D and register E. Counting
is done by instruction DCR E, decrement register by one for register E and D. The
JNZ, jump to specified location when ZERO flag is not set. That means if the
content of register E or D is not ZERO, it will jump back to decrement again. Until
they are ZERO, the CPU will continue execute the next instruction.
This program has 17 bytes code. We can enter the code into RAM from 8100 to
8110 easily.
ADDRESS DATA
8100 3C
8101 D3
8102 00
8103 11
8104 50
8105 10
8106 1D
8107 C2
8108 06
14
8109 81
810A 15
810B C2
810C 06
810D 81
810E C3
810F 00
8110 81
After finished entering the code, press HOME to bring current RAM location to
8100. Then press key GO.
To stop running, press RESET key. You can modify the initial value of register
DE, 1050 to whatever you want to speed up or slow down.
Test Program #2
This program shows how to use key GO to force CPU jump from monitor program
to user program.
This program has only 6 bytes i.e., 1E, 02, CF, C3, 00, 81. Enter the code, and
press key HOME, GO.
We will see the cold message repeat running on the display. RST 1 having
machine code CF is the method that used to call built-in monitor functions.
Register E is monitor call number.
Test Program #3
We can test the program with software breakpoint. The instruction RTS 7 having
machine code FF returns control back to monitor program and saves the contents
of CPU registers to user registers. We can check the result in user registers easily.
15
Here is the program that adds two BCD numbers 19H and 02H. The result will be
21H.
After enter the code, you can run it with key GO. Check the result in Accumulator
with ALT 0.
For small program, we can place the RST 7 to the end of the program.
However for long program, sometime we may need to check at a given location,
the board also provides tool that helps inserting the RST 7 instruction to the
specified location. This tool is called set break point. Suppose we want to verify
the result after add b instruction. We can set break point at location 8105 by
setting the address to 8105 with key ADDR 8,1,0,5. Then press ALT B, the
display will show this address was set breakpoint.
Press HOME and GO, check user AF with ALT 0, we see that after addition, the
result in Accumulator is 1B. To clear this break address, press ALT C. The display
will show current address 8105. The code 27 will be restored back to address
8105. We can continue execution, press RUN, and check result in AF again, we
will get 21. This the correct BCD number from the addition of 19+02=21.
16
Connecting Terminal
The kit provides RS232 port for connecting the terminal. The ROM monitor
contains ASCII commands when using UART to connect a terminal. The UART
drivers and serial commands are automatically configured when UART chip was
inserted. Communication format is 9600 bit/sec, 8 data bit, no parity and one stop
bit. We can use PC running VT100 terminal emulation. The CD has teraterm
software for emulating VT100 terminal.
RS232C cable
There is no need to switch between standalone mode and terminal mode. Both
commands using keypad or terminal commands are working concurrently.
8100>
17
MTK-85 8085 MICROPROCESSOR TRAINING KIT (? HELP)
A - ASCII code
C - clear watch variables
D - disassemble
E - edit memory
F - fill constant
H - hex dump
I - i/o address map
J - jump to user program
K - display user STACK
L - load Intel hex file
M - monitor call number
N - new location pointer
Q - quick home location
R - user register display
S - set value to user register
W - watch variables
SPACE BAR - single step
? - help menu
8100>
Command ‘A’ prints the hexadecimal code for printable ASCII characters.
The monitor provides quick access to a16-byte RAM for program testing. The
watch variables use RAM space from F000-F00F. Command 'W' prints such
memory on screen.
8100>
F000 AD FD FC 15 8E 9C DB 4D 4F 19 5F FD EB 3E 8A F5
8100>
8100>disassemble...
18
8105 27 DAA
8106 FF RST 7
8107 C20681 JNZ 8106
810A 15 DCR D
810B C20681 JNZ 8106
810E C30081 JMP 8100
8111 62 MOV H,D
8112 CDF862 CALL 62F8
8115 80 ADD B
8116 DC1642 CC 4216
8119 A5 ANA L
811A D3C1 OUT C1
811C 68 MOV L,B
811D>
Command ‘E’ examines and modify the data in memory. We can use this
command to enter machine code. To view the content, uses Space key and to enter
byte, press two digits. To quit just press ENTER.
ADDR DATA
8100 [3E]
8101 [19] 01
8102 [06]
8103 [02]
8104 [80] d3
8105 [27] 00
8106 [FF]
8107 [C2]
8108 [06]
8108>
Command ‘F’ fills 8-bit constant to memory. The example shows filling byte 00
to address 9010-9020.
19
Command ‘H’ dumps memory. The content of memory from current pointer 9010
to 908F will display in hexadecimal. The ASCII code for each byte will be
displayed also. The dot will be displayed for nonprintable ASCII code.
9010>
9010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
9020 4D C2 97 CB DA DF A0 BE 9E 73 1A 34 E3 A6 83 4E M........s.4...N
9030 97 47 81 CE C1 99 98 CB 14 ED 45 DE 35 6A 7C F1 .G........E.5j|.
9040 F0 36 B2 69 CF 1D 90 90 70 F1 73 D8 C1 4F DF 56 .6.i....p.s..O.V
9050 A8 E2 30 84 76 AA C5 18 A7 84 C5 32 81 BF B9 03 ..0.v......2....
9060 8A 13 8C FD 4A 82 B9 99 4E 24 33 9E EB 16 A8 0D ....J...N$3.....
9070 A9 31 CD B7 BB 4E 8D BE FF 5B 3C 8D EA 5E 4F 7F .1...N...[<..^O
9080 41 00 89 F3 54 BF EC BF E0 9F 72 CB 7D E8 34 7A A...T.....r.}.4z
9090>
9090>
00H-0FH onboard 4-bit GPIO, D0-D3=output port
D4-D7=input port
Command ‘J’ jumps from monitor program to user program. The example shows
jump to address 9000. The user register displays results after running the code.
The RST 7 returns control back to monitor program.
AF=5800 BC=19F4 DE=C256 HL=9504 SP=F098 PC=9007 S=0 Z=0 AC=0 P=0 CY=0
9090>
Command ‘K’ displays user STACK memory. The example below shows
running instruction PUSH H.
20
We first check the user register with command ‘r’. We see that TOP of STACK is
F098. After pressing SPACE BAR for single step, the SP is now F096. We can see
the contents of STACK memory with command k. The contents of HL was saved
in STACK.
AF=5800 BC=19F4 DE=C256 HL=9504 SP=F098 PC=9000 S=0 Z=0 AC=0 P=0 CY=0
9000>press SPACE bar for single step
9000 E5 PUSH H
AF=5800 BC=19F4 DE=C256 HL=9504 SP=F096 PC=9001 S=0 Z=0 AC=0 P=0 CY=0
9000>press k for STACK display
ADDR DATA
F096 [04]
F097 [95]
F098 [C0]
9000>
Command ‘L’ loads Intel Hex file to memory. The Assembler and C compiler for
8085 CPU produce standard Intel Hex file. The hex file contains machine code
represented by ASCII letters. The example below uses Teraterm to download the
hex file. The hex file is ASCII text file. So with the teraterm, we can go to Send
File. We can let it show only file with .hex extension by typing *.hex. Then double
clicks at the hex file.
The onboard dot LED will indicate downloading is on going. When completed, the
report will show number of byte received and print checksum error. If no error it
will show 0 errors.
9080>
Command ‘M’ shows monitor call number. Some of common subroutines can be
called through RST 1 with function number preloaded in register E.
9080>
see input parameters in user manual
00 - demo
21
01 - delay
02 - cold_boot
03 - scan
04 - cin
05 - cout
06 - put_str
07 - init_lcd
08 - lcd_ready
09 - clear_lcd
0A - goto_xy
0B - put_str_lcd
0C - put_ch_lcd
0D - demo2
9080>
Command ‘N’ sets new location pointer at prompt. The example sets new pointer
to E000 and press ‘d’ to disassemble.
E018>
Command ‘Q’ sets location pointer at prompt to 9000 and sets user PC to 9000.
9000>
AF=5800 BC=19F4 DE=C256 HL=9504 SP=F096 PC=9000 S=0 Z=0 AC=0 P=0 CY=0
22
9000>
Command ‘R’ displays user registers contents.
9000>
AF=5800 BC=19F4 DE=C256 HL=9504 SP=F098 PC=9000 S=0 Z=0 AC=0 P=0 CY=0
9000>
AF=FF00 BC=19F4 DE=0434 HL=0534 SP=F096 PC=9006 S=0 Z=0 AC=0 P=0 CY=0
9013>
9013>
F000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
org 9000h
xra a
loop: out 0
mov h,a
inr h
push h
pop d
mov a,d
jmp loop
end
Then translate it to machine code file using the Assembler program. Download
hex file.
23
9000>disassemble...
9000 AF XRA A
9001 D300 OUT 00
9003 67 MOV H,A
9004 24 INR H
9005 E5 PUSH H
9006 D1 POP D
9007 7A MOV A,D
9008 C30190 JMP 9001
900B 00 NOP
900C 00 NOP
900D 00 NOP
900E 00 NOP
900F 00 NOP
9010 00 NOP
9011 00 NOP
9012 00 NOP
AF=5800 BC=19F4 DE=C256 HL=1234 SP=F098 PC=9000 S=0 Z=0 AC=0 P=0 CY=0
9013>press SPACE key to execute instruction at 9000, we see A=00
9000 AF XRA A
AF=0044 BC=19F4 DE=C256 HL=1234 SP=F098 PC=9001 S=0 Z=1 AC=0 P=1 CY=0
9013>press SPACE key, the content of A will send to GPIO
AF=0044 BC=19F4 DE=C256 HL=1234 SP=F098 PC=9003 S=0 Z=1 AC=0 P=1 CY=0
9013>press SPACE key, the content of A will copy to H
9003 67 MOV H,A
AF=0044 BC=19F4 DE=C256 HL=0034 SP=F098 PC=9004 S=0 Z=1 AC=0 P=1 CY=0
9013> press SPACE key, the content of H will increment by 1
9004 24 INR H
AF=0000 BC=19F4 DE=C256 HL=0134 SP=F098 PC=9005 S=0 Z=0 AC=0 P=0 CY=0
9013> press SPACE key, the content SP will decrement by 2
9005 E5 PUSH H
AF=0000 BC=19F4 DE=C256 HL=0134 SP=F096 PC=9006 S=0 Z=0 AC=0 P=0 CY=0
9013> press K, to see the content of STACK memory
ADDR DATA
F096 [34]
F097 [01]
F098 [C0]
AF=0000 BC=19F4 DE=0134 HL=0134 SP=F098 PC=9007 S=0 Z=0 AC=0 P=0 CY=0
9013> press SPACE key, the content of D will copy to A
24
9007 7A MOV A,D
AF=0100 BC=19F4 DE=0134 HL=0134 SP=F098 PC=9008 S=0 Z=0 AC=0 P=0 CY=0
9013> press SPACE key, PC will be loaded with 9001
9008 C30190 JMP 9001
AF=0100 BC=19F4 DE=0134 HL=0134 SP=F098 PC=9001 S=0 Z=0 AC=0 P=0 CY=0
9013> press SPACE key, the content of A will send to GPIO, see LED!
9001 D300 OUT 00
AF=0100 BC=19F4 DE=0134 HL=0134 SP=F098 PC=9003 S=0 Z=0 AC=0 P=0 CY=0
25
Hardware
A block diagram of the MTK-85 board is shown below. For complete hardware
schematic, see Appendix D.
CPU
The CPU is a CMOS 80C85. The XTAL frequency is 4MHz. The reset signal is
generated by simple RC circuit. The CPU is protected by brownout circuit.
In case of power supply is dipped caused by AC supply voltage dropped. The
brownout circuit detects VCC, if it is below threshold level, it will reset the
CPU.
The brownout condition can be tested by using a variable power supply. To test it,
adjust the board VIN from 0-12V slowly and see the CPU can start running
properly or not.
Memory
The onboard has 64kB memory. The 32kB ROM monitor 27C256 is placed at
address 0000-7FFFH. And the 32kB SRAM 62256, is placed at address 8000H-
FFFFH.
Some of interrupt vectors are relocated to RAM, so user can write the jump
instruction to the location of such interrupt service routine easily. Here is the
location of interrupts.
26
8010H RST 2
8018H RST 3
8020H RST 4
8028H RST 5
802CH RST 5.5
8030H RST 6
8034H RST 6.5
803CH RST 7.5
Note:
1. RST 7 is used for software breakpoint.
2. RST 1 is used for monitor function call.
3. TRAP is used for hardware single-step.
4. RST 7.5 is tied to OUT0 of 8254 programmable counter.
5. Monitor program uses last page of RAM for data storage, STACK area, and
monitor control functions. The space is from F000H to F098H.
GPIO
GPIO provides 4-bit output port using D type F-F, 74LS175 and 4-bit input port
using tri-state buffer, 74LS126. The address is 00 for both ports. The low-nibble
D0-D3 is output port. The higher-nibble D4-D7 is input port. The signal from both
ports appeared at J1, 16-pin header.
27
System Programmable Port 8255
The board provides a user programmable parallel port, 8255. The 8255’s registers
are mapped to I/O address from 30H to 33H.
30H PORTA
31H PORTB
32H PORTC
33H CONTROL PORT
The programmable counter, 8254 was supplied with clock signal from
CLOCKOUT or 2MHz for counter0 and counter1. The internal registers of 8254
are mapped to I/O space from 20H to 23H.
28
20H COUNTER0
21H COUNTER1
22H COUNTER2
23H CONTROL REGISTER
29
Headers and Connectors
30
Onboard LCD Header JR1
31
Interrupts Test Button
The interrupt test button provides a single positive pulse that tied to CPU hardware
interrupt pins, RST5.5, RST6.5 and INTR. User can select the pulse to be
triggered for each pin by dip switch SW1. The onboard LED, D4 indicates the
pulse is activated when press Test button.
Technical Specifications
01 - delay
Delay subroutine using register pair DE, D is outer loop delay, E is inner loop.
Entry: DE
Exit: none
02 - cold_boot
Display cold-boot message on 7-segment LED.
Entry: none
03 - scan
Scan keyboard and display one cycle.
Entry: HL points the display buffer
Exit: key = scan code –1 no key pressed
32
04 - cin
Get character from console
Entry: none
Exit: A = character received
05 - cout
Send character to console
Entry: A = character to be sent
Exit: none
06 - put_str
Print string to console, string is terminated by 0.
Entry: HL
Exit: none
07 - init_lcd
Initialize LCD module
Entry: none
Exit: none
08 - lcd_ready
Wait until LCD module is ready.
Entry: none
Exit: none
09 - clear_lcd
Clear LCD display
Entry: none
Exit: none
0A - goto_xy
Set cursor position of LCD
Entry: HL, H = x, L = y
Exit: none
0B - put_str_lcd
Print string to LCD, string is terminated by 0
Entry: HL
Exit: none
0C - put_ch_lcd
Print character to LCD at current cursor position
33
Entry: A
Exit: none
0D - demo2
Running GPIO LED
Entry: none
Exit: none
NVRAM Bootable
User can replace U3, SRAM with a Nonvolatile RAM for program storage, when
the board is power off. A JMP instruction placed at 8000H will enable NVRAM
bootable. The monitor program checks the location 8000H. If it has C3 (opcode of
JMP instruction), it will jump to address 8000H. The feature allows application
code to run easily. The monitor subroutines are still available for the application
program.
To get back to monitor mode, user can press USER key while press RESET. The
byte C3 at location 8000H will change to 00.
34
Appendix A Onboard LCD Driver Routines
lcd_ready1: in command_read
ani busy
jnz lcd_ready1 ; wait until lcd ready
pop psw
ret
ret
put_str_lcd1:
call lcd_ready
35
out data_write
inx h
jp put_str_lcd
goto_xy1: cpi 1
jnz goto_xy2
mov a,h
adi 0c0h
out command_write
ret
goto_xy2: cpi 2
jnz goto_xy3
mov a,h
adi 094h
out command_write
ret
goto_xy3: cpi 3
jnz goto_xy4
mov a,h
adi 0d4h
out command_write
ret
goto_xy4: ret
36
Appendix B Subroutine Scan keyboard and Display
; subroutine scan keyboard and display
; entry: hl pointer to display buffer
; exit: key = scan code
; -1 no key pressed
;
scan: push h
push b
push d
push psw
mov a,d
sta key ; save key position
pop psw
next_key:
inr d ; next key position
37
mvi a,0 ; clear a
out system_port_b ; turn off led
pop d
pop b
pop h
ret
38
Appendix C UART Driver Routines
;---------- 16C550 compatible UART I/O address ------------
; e.g. UM8250B, 16C450, 16C550
init_uart:
mvi a,83h
out uart_lcr ; set DLAB bit to access divider
mvi a,13
out uart_divisor_lsb
mvi a,0
out uart_divisor_msb ; 2MHz/13 = 153846 Hz
; 153846Hz/16 = 9615Hz
mvi a,7
out uart_fifo ; init fifo and clear all buffers
mvi a,03h
out uart_lcr ; clar DLAB
39
cout: mov b,a ; save a
cout1: in uart_line_status
ani 20h ; transmitter ready?
jz cout1
cin: in uart_line_status
ani 1 ; data available?
jz cin
in uart_buffer
ret
40
41
Appendix D Using NVRAM Bootable
; MTK-85 8085 Microprocessor Training Kit
; exp1.asm
;
; Using 8254 to produce 30.52Hz interrupt signal at RST7.5
;
; The 8254 counter0 was loaded with 0000 by system monitor.
; The input clock to the 8254 is 2MHz, the OUT0 then
produces
; 2MHz/65536 = 30.52Hz interrupt at RST7.5!
;
CPU "8085.TBL" ;CPU TABLE
HOF "INT8" ;HEX FORMAT
gpio equ 0
org 8000h
jmp start ; put instruction JMP to boot from
RAM
org 8100h
service_rst7.5:
org 0e000h
42
count dfs 1 ; use RAM one byte for count
variable
end
43
Appendix E Machine code and 8085 Instructions
44
!""#$%&'()(*+,-&$#(./%#(+$%(*$#0/$&,(/1(2324(5$6789,7&/$6
45
5 4 3 2 1
D[0..7] J1 +5V
A[0..7] D[0..7]
A[0..7]
U1
0x0000-0x7FFF 0x8000-0xFFFF 32kB D0 4 2 1 2
D1 Q1 GPIO_LED1 3 + +
JP1 3 4
Monitor Program SRAM, NVRAM D0 A0 D1 5
Q1
7 5
+ +
6
D1 1 2 A1 D2 Q2 GPIO_LED2 7 + +
U2 U3 6 8
U4 A0 D0 A0 D0 D2 3 4 A2 D2 Q2 + +
10 A0 O0 11 10 A0 D0 11 5 6 12 D3 Q3 10 9 + + 10
A1 9 12 D1 A1 9 12 D1 D3 A3 11 GPIO_LED3 11 12
D0 A0 A2 A1 O1 D2 A2 A1 D1 D2 D4 7 8 A4 D3 Q3 + +
2 1D 1Q 19 8 A2 O2 13 8 A2 D2 13 9 10 13 D4 Q4 15 13 + + 14
D D1 A1 A3 D3 A3 D3 D5 A5 GPIO_LED4 15 D
3 2D 2Q 18 7 A3 O3 15 7 A3 D3 15 11 12 Q4 14 + + 16
D2 4 17 A2 A4 6 16 D4 A4 6 16 D4 D6 A6
D3 3D 3Q A3 A5 A4 O4 D5 A5 A4 D4 D5 D7 13 14 A7
5 4D 4Q 16 5 A5 O5 17 5 A5 D5 17 15 16 9 CLK
D4 6 15 A4 A6 4 18 D6 A6 4 18 D6 /RD RESET_IN 1
D5 5D 5Q A5 A7 A6 O6 D7 A7 A6 D6 D7 /WR 17 18 CLR
7 6D 6Q 14 3 A7 O7 19 3 A7 D7 19 19 20
D6 8 13 A6 A8 25 A8 25 IO/M *RST5.5 74LS175
D7 7D 7Q A7 A9 A8 A9 A8 SID 21 22 *RST6.5
9 8D 8Q 12 24 A9 24 A9 23 24
A10 21 A10 21 ALE *RST7.5
ALE A11 A10 A11 A10 SOD 25 26 *INTR U5
11 LE 23 A11 23 A11 27 28
1 A12 2 A12 2 S0 INTA
OE A13 A12 A13 A12 S1 29 30 D4
26 A13 26 A13 31 32 3 1Y 1A 2
20 A14 27 A14 1 CLKOUT D5 6 5
VCC A14 A14 READY 33 34 HOLD D6 2Y 2A
35 36 8 3Y 3A 9
ROM_CE 20 RAM_CE 20 RESET_OUT HLDA +5V D7 11 12
74HC573 /RD CE /RD CE 37 38 4Y 4A
22 OE 22 OE 39 40
+5V 1 /WR 27 1
+5V VPP WE 1OE
HEADER 20X2 4
2OE
27C256 HM62256B U6A 10
A[8..14] GPIO 3OE
1 4OE 13
3
/WR 2
74LS126
4001 U6B
C memory & i/o decoder 5 C
4
U8 /RD 6
U7
RESET_IN 36 12 D0 S0 2 12 RAM_CE 4001
+5V 47pF C1 RST-IN AD0 D1 S1 I I/O/Q ROM_CE
AD1 13 3 I I/O/Q 13
1 14 D2 A4 4 14
X1 AD2 D3 I I/O/Q SYSTEM_PPI
15 A5 5 15
AD3 D4 I I/O/Q GPIO +5V
4MHz 16 A6 6 16
C2 AD4 D5 I I/O/Q CTC
D1 Q1 2 17 A7 7 17
X2 AD5 D6 IO/M I I/O/Q USER_PPI VCC
1N4148 R1 18 8 18
SID AD6 D7 A15 I I/O/Q UART
100k 47pF 5 19 9 19
TRAP SID AD7 A8 I I/O/Q LCD_E
6 TRAP A8 21 VCC
S1 22 A9 /RD 1
RST5.5 A9 A10 /WR I/CLK
9 RST 5.5 A10 23 11 I/OE
RST6.5 8 24 A11 VSS
RST7.5 RST 6.5 A11 A12
KIA7045 7 RST 7.5 A12 25
RESET 26 A13 GAL16V8D
INTR A13 A14
10 INTR A14 27
R2 + C3 3 28 A15
1k 1uF OUT INTA A15
2 GND 11 INTA
1 30 ALE U9A
VCC S0 ALE
29 31 WR SW1
S0 WR *RST5.5 RST5.5
U25 RD 32 RD 1 8 1 2
B S1 33 34 2 7 B
S1 IO/M RESET_OUT
RST-OT 3 reset 3 6
+5V HOLD 39 37 CLKOUT 4 5 74LS04
HOLD CLKO SOD CLKOUT
+5V 4 +5V U9B
READY SOD HLDA
35 38 SW DIP-4/SM
READY HLDA *RST6.5 RST6.5
3 4
R3 MSM80C85A R4
+5V 4.7k 4.7k
R15 74LS04
4.7k +5V U6C U9C
R5 8 +5V
4.7k 10 5 6 RST7.5
R6 330 D2 9
SID GPIO_LED1 R7
U10 SW2 4001 330 74LS04
1 3 LED NO 1 U9D
A QA R8 330
2 4 D3 2
B QB GPIO_LED2 *INTR INTR
QC 5 3 9 8
6 NC D4
QD +5V PS2273
10 LED
ALE QE R9 330 LED
8 11 D5 U6D 74LS04
CLK QF GPIO_LED3 +5V
QG 12 12
TRAP R21 R10
9 CLR QH 13 11
4.7k LED 13
R11 *RST7.5
A 74LS164 330 D6 A
U9E GPIO_LED4 4.7k 4001
10 11 TRACE LED U9F
13 12 Title
74LS04 8085 Microprocesssor Training Kit
74LS04 Size Document Number Rev
B <Doc> 2
Date: Saturday, July 30, 2005 Sheet 1 of 4
5 4 3 2 1
5 4 3 2 1
U11 R12
PB0 2 18 1 16
PB1 1A1 1Y1
4 1A2 1Y2 16 2 15
PB2 6 14 3 14
PB3 1A3 1Y3
8 1A4 1Y4 12 4 13
PB4 11 9 5 12
PB5 2A1 2Y1
13 2A2 2Y2 7 6 11
PB6 15 5 7 10 +5V
PB7 2A3 2Y3
17 2A4 2Y4 3 8 9 VCC
1 R-PACK
D 1G D
19 2G VCC
74LS244
10
10
10
10
10
10
7
6
4
2
1
9
7
6
4
2
1
9
7
6
4
2
1
9
7
6
4
2
1
9
7
6
4
2
1
9
7
6
4
2
1
9
5
U12 U13 U14 U15 U16 U17 VSS
a
b
d
e
g
dp
a
b
d
e
g
dp
a
b
d
e
g
dp
a
b
d
e
g
dp
a
b
d
e
g
dp
a
b
d
e
g
dp
c
c
f
f
A[0..7]
COMMON CATHODE 6-DIGIT
A0 7-SEGMENT LED
A1
A2
A3
A4
com1
com2
com1
com2
com1
com2
com1
com2
com1
com2
com1
com2
A5
A6
A7 TOS-5161AE TOS-5161AE TOS-5161AE TOS-5161AE TOS-5161AE TOS-5161AE
3
8
3
8
3
8
3
8
3
8
3
8
U18
0 1
1
1 2
3 SPEAKER 2 Q2
PC0 2 BC327
15 A 3 4
PC1 14 5
PC2 B 4
3
C 13 C 5 6 C
PC3 12 7
D 6
7 9
10 R13
8 100
9 11
74LS145
SU1
SYSTEM_PPI
SW29
0x10-0x13
8255 SPEAKER SW PUSHBUTTON
25 PB7 SPEAKER
PB7 PB6
PB6 24
23 PB5
PB5 PB4
PB4 22 TRACE
21 PB3 SW3
PB3
PB2 20 PB2
PB1 SW4 SW5 SW6 SW7
PA6 user_key1 +5V
PB1 19
18 PB0
PB0
10 SW8
PC7 PA7
11
B 6 CS
PC6
PC5 12 PC5
PC4 SW9 SW10 SW11 SW12
user_key2 B
reset 35 RESET PC4 13
A1 8 17 PC3
A0 A1 PC3 PC2
9 A0 PC2 16
36 15 PC1
WR WR PC1 PC0
RD 5 RD PC0 14
SW13 SW14 SW15
D7 PA7 SW16 +5V
27 D7 PA7 37
D6 28 38 PA6
D5 D6 PA6 PA5 R14
29 D5 PA5 39
D4 30 40 PA4 PA0 2 1
D3 D4 PA4 PA3 PA1
31 D3 PA3 1 3
D2 32 2 PA2 PA2 4
D1 D2 PA2 PA1 SW17 SW18 SW19 PA3
33 D1 PA1 3 5
D0 PA0 SW20 PA4
34 D0 PA0 4 6
PA5 7
U19 PA6 8
PA7 9
C
4.7k
SW21 SW22 SW23 SW24
A A
D[0..7]
SW25 SW26 SW27 SW28 Title
8085 Microprocessor Training Kit
Size Document Number Rev
B <Doc> 2
Date: Saturday, July 30, 2005 Sheet 2 of 4
5 4 3 2 1
5 4 3 2 1
D[0..7] 0x40-0x47
+5V UART
CLKOUT U20
0x20-0x23
U21 D0 1 10 RxD
D D0 D1 D0 SDI D
8 D0 2 D1
D1 7 D2 3 18
D2 D1 D3 D2 WR1 WR
6 D2 CLK0 9 4 D3 WR2 19
D3 5 11 D4 5 21
D4 D3 G0 D5 D4 RD1 RD
4 D4 OUT0 10 *RST7.5 6 D5 RD2 22
D5 3 D6 7 25
D6 D5 D7 D6 ADS
2 D6 CLK1 15 8 D7 MR 35 reset
D7 1 14 36
D7 G1 TxD CTS
OUT1 13 11 SDO DSR 37
22 38 DCD
RD RD DCD
WR 23 WR CLK2 18 34 OUT1 RI 39
A0 19 16 31
A1 A0 G2 OUT2 2MHz
A[0..7] 20 A1 OUT2 17 XIN 16
23 DDIS XOUT 17
21 +5V 24
CTC CS TXRDY A0
29 RXRDY A0 28
A0 8254 30 27 A1
A1 R17 R18 RTS INTRPT A1 A2
counter/timer 32 RTS A2 26
A2 4.7k 4.7k 33 +5V
A3 DTR
CS0 12
A4 9 13
A5 RCLK CS1
15 BAUDOUT CS2 14
A6
A7 User PPI
C C
TL16C550A +5V
0x30-0x33 VCC
U22
D0 34 4 USER_PA0
D1 D0 PA0 USER_PA1
33 D1 PA1 3 UART VCC
D2 32 2 USER_PA2
D3 D2 PA2 USER_PA3
31 D3 PA3 1
D4 30 40 USER_PA4 VSS
D5 D4 PA4 USER_PA5
29 D5 PA5 39
D6 28 38 USER_PA6 +5V
D7 D6 PA6 USER_PA7 JP2
27 D7 PA7 37
5 18 JR1 SW30
RD RD PB0 1 2
WR 36 WR PB1 19 3 4 1
A0 9 20 16 2
A1 A0 PB2 5 6 16
8 A1 PB3 21 7 8 15 15 3
35 22 14 D7 0x50-0x53
reset RESET PB4 9 10 14 D6
6 23 13 backlight
USER_PPI CS PB5 11 12 13 D5
PB6 24 13 14 12 12
25 text LCD 11 D4
PB7 15 16 11 D3
17 18 10 10
14 9 D2
PC0 19 20 9 D1
PC1 15 21 22 8 8
B 16 7 D0 B
PC2 23 24 USER_PA0 7 LCD_E
PC3 17 25 26 6 6 LCD_E
13 USER_PA1 5 R/W A1
PC4 27 28 USER_PA2 5 RS A0
PC5 12 29 30 4 4
11 USER_PA3 3
PC6 31 32 USER_PA4 3
PC7 10 33 34 2 2
USER_PA5 1
35 36 USER_PA6 1
8255
37 38 USER_PA7
39 40 CONN RECT 16 +5V
2
+5V HEADER 20X2
1 3
10uF 10V 10uF C7
R19
+
C6
+
10K
U23
VB1 2 1
V+ C+ 10uF
5 C1- 3
9 6 V- C2+ 4
4 C8 5
C2-
+
+
8 C9
3 10uF
7 14 11 TxD
A T1OUT T1IN RTS A
2 7 T2OUT T2IN 10
6 13 12 RxD
R1IN R1OUT DCD
1 8 R2IN R2OUT 9
SUB-D 9, (male) use straight cable
MAX232A Title
RS232 level converter 8085 Microprocessor Training Kit
Size Document Number Rev
B <Doc> 2
Date: Saturday, July 30, 2005 Sheet 3 of 4
5 4 3 2 1
5 4 3 2 1
J5
1
2
3
CON3
D7 R20 2k
D D
POWER LED (red)
+5V
TP1 U24 J6
LM2490-5.0 D8
+5V 3 1 2 1 1
1 VOUT VIN
2
C13 10uF 16V
GND
+ + 1N4007 DC Input
C12 C14 C15 C16 C17
C10 C18 C19 C11
0.1uF 0.1uF 0.1uF 0.1uF 0.1uF
TP2 0.1uF 0.1uF 1000uF25V
2
GND 1
0.1uF
+5V
C C
+5V
VCC
C20 C21 C22 C23
0.1uF 0.1uF 0.1uF 0.1uF
VCC
VSS
B B
+5V
+ C24 + C25 + C26 + C27
10uF 10uF 10uF 10uF
A A
Title
8085 Microprocessor Training Kit
Size Document Number Rev
B <Doc>
Date: Saturday, July 30, 2005 Sheet 4 of 4
5 4 3 2 1
Appendix G Monitor source code listing
46
A8085.LST 29/3/2558 15:27
1 ;-----------------------------------------------------------------
2 ; A8085.ASM
3 ; monitor program for MTK-85 8085 MICROPROCESSOT TRAINING KIT
4 ; COPYRIGHT (C) 2007-2015 BY WICHIT SIRICHOTE, [email protected]
5 ;
6 ; source file was assembled with C32 Cross Assembler V3.0
7 ;
8 ; 18 May 2007 add insert byte, ALT E
9 ; delete byte, ALT D
10 ; click sound when key pressed
11 ;
12 ; 8 March 2015 remove repeat key
13 ; modified address and data entry mode
14 ;
15 ;-----------------------------------------------------------------
16
17 0000 CPU "8085.TBL" ;CPU TABLE
18 0000 HOF "INT8" ;HEX FORMAT
19
20
21 ; ---------- onboard GPIO --------------------------------------
22
23 0000 = gpio equ 0 ; D0-D3 is 4-bit output port, D4-D7 is 4-bit input port
24
25
26 ;---------- 8255 PPI system port I/O address ----------------------
27
28 0010 = system_port_a: equ 10h
29 0011 = system_port_b: equ 11h
30 0012 = system_port_c: equ 12h
31 0013 = system_port_control: equ 13h
32
33 ;-------------------- 8254 counter/timer --------------------------
34
35 0020 = counter0_8254 equ 20h
36 0021 = counter1_8254 equ 21h
37 0022 = counter2_8254 equ 22h
38 0023 = control_8254 equ 23h
39
40 0034 = control_word_8254 equ 00110100B ; mode 0, counter0
41
42 ;---------- 8255 PPI user port I/O address ------------------------
43
44 0030 = user_port_a: equ 30h
45 0031 = user_port_b: equ 31h
46 0032 = user_port_c: equ 32h
47 0033 = user_port_control: equ 33h
48
49
50 ;---------- 16C550 compatible UART I/O address --------------------
51 ; e.g., UM8250B, 16C450, 16C550
52
53 0040 = uart_buffer: equ 40h
54 0045 = uart_line_status: equ 45h
55 0042 = uart_fifo: equ 42h
56 0043 = uart_lcr: equ 43h
57 0040 = uart_divisor_lsb: equ 40h
58 0041 = uart_divisor_msb: equ 41h
59 0047 = uart_scr: equ 47h
60
61
62 ;------------------- onboard LCD registers ------------------------
63
64 0050 = command_write equ 50h
65 0052 = command_read equ 52h
66 0051 = data_write equ 51h
67 0053 = data_read equ 53h
68 0080 = busy equ 80h
69
70 0009 = TAB EQU 9 ; ASCII TAB
71 0000 = RS EQU 0 ; terminator
72
73 000D = cr: equ 0dh
74 000A = lf: equ 0ah
75 0020 = sp: equ 20h
76
Page 1 of 63
A8085.LST 29/3/2558 15:27
77
78 F000 = system_ram equ 0f000h
79
80 ;system_stack equ 0ffffh
81
82 8100 = home_address equ 8100h
83
84 0000 = rom equ 0000h ; change to 8000 for testing under RAM
85 ; chnage to 0000 for rom programming
86
87 8000 = my_rom equ 8000h
88
89 0000 ORG rom
90 0000 C30001 JMP START ; reset vector
91
92 0008 ORG rom+8 ; RST 1 opcode is CF
93 0008 C35C02 jmp monitor_call
94
95 0010 ORG rom+10h ; RST 2 used for testing RST 7
96 ; jmp service_rst2
97
98 0010 C31080 jmp my_rom+10h
99
100 0018 ORG rom+18h ; DF RST 3 for testing monitor call function in RAM
101 0018 C31880 jmp my_rom+18h
102
103 ; jmp monitor_call
104
105 0020 ORG rom+20h ; RST 4
106 0020 C32080 jmp my_rom+20h
107
108 0024 ORG rom+24h
109 ; jmp my_rom+24h
110 0024 C3D802 jmp service_trap ; sing step running service routine
111
112 0028 ORG rom+28h ; RST 5
113 0028 C32880 jmp my_rom+28h
114
115 002C ORG rom+2ch ; relocate RST5.5 to external ram
116 002C C32C80 jmp my_rom+2ch
117
118 0030 ORG rom+30h ; relocate RST 6
119 0030 C33080 jmp my_rom+30h
120
121 0034 ORG rom+34h ; relocate RST6.5 to external ram
122 0034 C33480 jmp my_rom+34h
123
124 0038 ORG ROM+38H
125 0038 C38E02 jmp service_rst7 ; RST 7 service jump back to monitor
126
127 003C ORG rom+3ch ; relocate RST7.5 to external ram
128 003C C33C80 jmp my_rom+3ch
129
130
131 0100 ORG rom+100h
132
133
134 0100 F3 START di
135 0101 3178F0 lxi sp,system_stack+32 ; point to top of system stack
136 0104 2198F0 lxi h,user_stack+32 ; point to top of user stack
137 0107 2233F0 shld user_SP
138
139
140 010A 3E90 MVI A,90H
141 010C D313 OUT system_port_control
142
143 010E 3EF0 mvi a,0f0h ; disable trap
144 0110 D312 out system_port_c
145
146 0112 CDED11 call init_uart
147
148 0115 CD0302 call init_lcd
149 0118 218B1D lxi h,prompt2
150 011B CD1502 call put_str_lcd
151 011E 210100 lxi h,01
152 0121 CD2502 call goto_xy
Page 2 of 63
A8085.LST 29/3/2558 15:27
Page 3 of 63
A8085.LST 29/3/2558 15:27
Page 4 of 63
A8085.LST 29/3/2558 15:27
Page 5 of 63
A8085.LST 29/3/2558 15:27
381
382 0256 CDF101 put_ch_lcd: call lcd_ready
383 0259 D351 out data_write
384 025B C9 ret
385
386 ;--------------------------------------------------------------------
387
388 ; monitor call entry
389 ; entry: E = monitor call number 0-255
390 ; calling monitor function is made with RST 1 command after loading the
391 ; regsiter E with call number
392 ; destroy: BC user must save it in stack memory
393
394 025C E5 monitor_call: push h
395 025D F5 push psw
396 025E D5 push d
397
398 025F 7B mov a,e ; get call number
399 0260 07 rlc ; x2
400 0261 5F mov e,a ; put it back
401
402 0262 217002 lxi h,vector_table
403 0265 1600 mvi d,0
404 0267 19 dad d ; get location in jump table
405 0268 4E mov c,m
406 0269 23 inx h
407 026A 46 mov b,m
408
409 026B D1 pop d
410 026C F1 pop psw
411 026D E1 pop h
412
413 026E C5 push b ; push address into top of stack
414
415 026F C9 ret ; jump to monitor call function
416
417 0270 vector_table:
418 0270 860B dwl demo ; #0 running LED with HL pointer
419 0272 FB05 dwl delay ; #1 simple delay routine
420 0274 5C0B dwl cold_boot ; #2 show 8085 running
421 0276 940C dwl scan ; #3 scan display one cycle
422 0278 2212 dwl cin ; #4 get byte from console
423 027A 1612 dwl cout ; #5 print byte to console
424 027C 3F12 dwl put_str ; #6 print string with 0 terminator to console
425 027E 0302 dwl init_lcd ; #7 initialize lcd
426 0280 F101 dwl lcd_ready ; #8 wait until lcd is ready
427 0282 FB01 dwl clear_lcd ; #9 clear lcd display
428 0284 2502 dwl goto_xy ; #10 set lcd cursor position
429 0286 1502 dwl put_str_lcd ; #11 print ASCII string on lcd
430 0288 5602 dwl put_ch_lcd ; #12 print ASCII letter on lcd
431 028A ED05 dwl test_led ; #13 run LED onboard
432 028C C401 dwl pint8u ; #14 print 8-bit unsigned to terminal
433
434
435
436 ; save CPU registers to stack and write them to user registers
437 ;
438
439 028E service_rst7:
440 028E F5 push psw
441 028F C5 push b
442 0290 D5 push d
443
444 0291 E1 pop h
445 0292 222FF0 shld user_DE
446 0295 E1 pop h
447 0296 222DF0 shld user_BC
448 0299 E1 pop h
449 029A 222BF0 shld user_AF
450 029D E1 pop h
451
452 029E 2229F0 shld user_PC ; store next PC
453
454 02A1 210000 lxi h,0000h
455 02A4 39 dad sp ; get SP
456 02A5 2233F0 shld user_SP ; save user SP
Page 6 of 63
A8085.LST 29/3/2558 15:27
457
458 02A8 CDA40A call read_memory
459 02AB CD3B0F call register_display1
460
461 02AE 2A56F0 lhld save_stack
462
463 02B1 F9 sphl ; restore system stack
464
465
466 02B2 C9 ret
467
468
469 ; test diplay register after break
470 ; RST 2 opcode is D7
471 ; later will be changed to RST 7
472
473 02B3 service_rst2:
474 02B3 F5 push psw
475 02B4 C5 push b
476 02B5 D5 push d
477
478 02B6 E1 pop h
479 02B7 222FF0 shld user_DE
480 02BA E1 pop h
481 02BB 222DF0 shld user_BC
482 02BE E1 pop h
483 02BF 222BF0 shld user_AF
484 02C2 E1 pop h
485
486 02C3 2229F0 shld user_PC ; store next PC
487
488 02C6 210000 lxi h,0000h
489 02C9 39 dad sp ; get content of SP
490
491 02CA 2233F0 shld user_SP ; save user SP
492
493 02CD CDA40A call read_memory
494 02D0 CD3B0F call register_display1
495
496 02D3 2A56F0 lhld save_stack
497
498 02D6 F9 sphl ; restore system stack
499
500
501 02D7 C9 ret
502
503
504 ; service trap for single step running
505 ; disable trap input by setting system port c.6
506 ; save CPU registers to user registers
507
508 02D8 service_trap:
509 02D8 F5 push psw ; save A and Flag
510
511 02D9 3EFF mvi a,0ffh
512 02DB D312 out system_port_c ; turn trap off by clearing shift register
513
514 02DD C5 push b
515 02DE D5 push d
516 02DF E5 push h
517
518 02E0 E1 pop h
519 02E1 2231F0 shld user_HL ; save HL
520 02E4 E1 pop h
521 02E5 222FF0 shld user_DE
522 02E8 E1 pop h
523 02E9 222DF0 shld user_BC
524 02EC E1 pop h
525 02ED 222BF0 shld user_AF
526
527 02F0 E1 pop h ; store next PC
528 02F1 2229F0 shld user_PC
529
530 02F4 210000 lxi h,0
531 02F7 39 dad sp
532 02F8 2233F0 shld user_SP ; save user SP
Page 7 of 63
A8085.LST 29/3/2558 15:27
533
534 02FB CDA40A call read_memory
535
536 02FE 3A24F0 lda uart_found
537 0301 FE00 cpi 0
538 0303 CA0903 jz skip1
539 0306 CD3B0F call register_display1
540
541 0309 skip1:
542 0309 2A56F0 lhld save_stack
543
544 030C F9 sphl ; restore system stack
545
546 030D C9 ret ; jump back to main body
547
548
549 ; disassemble machine code into mnemonic
550
551 030E disassemble1:
552 030E 3A22F0 lda command
553 0311 FE64 cpi "d"
554 0313 C23403 jnz exit_disassemble
555
556 0316 21881E lxi h,disassemble_text
557 0319 CD3F12 call put_str
558
559 031C CDC112 call new_line
560 031F 0E10 mvi c,16 ; 16 lines
561
562
563 0321 C5 dis2: push b
564
565 0322 CDC112 call new_line
566
567 0325 CDAB03 call d_disassemble
568
569 0328 C1 pop b
570 0329 0D dcr c
571 032A C22103 jnz dis2
572
573 032D CDC112 call new_Line
574 0330 CD210D call send_prompt
575 0333 C9 ret
576
577
578 0334 C9 exit_disassemble: ret
579
580
581 ; disassemble opcode to mnemonic
582 ; entry: user_PC
583 ; exit: user_PC = next address
584
585 0335 2A29F0 disassemble: lhld user_PC
586
587 0338 E5 push h
588
589 0339 7C mov a,h
590 033A CDB212 call out2x
591 033D 7D mov a,l
592 033E CDB212 call out2x
593 0341 CDCC12 call space
594
595 0344 7E mov a,m ; get opcode
596 0345 CD2104 call get_number_of_byte
597 0348 4F mov c,a
598
599 0349 7E disassem3: mov a,m
600 034A CDB212 call out2x
601 034D 23 inx h
602 034E 0D dcr c
603 034F C24903 jnz disassem3
604
605 0352 E1 pop h
606
607 0353 7E mov a,m
608 0354 CD2104 call get_number_of_byte
Page 8 of 63
A8085.LST 29/3/2558 15:27
Page 9 of 63
A8085.LST 29/3/2558 15:27
Page 10 of 63
A8085.LST 29/3/2558 15:27
Page 11 of 63
A8085.LST 29/3/2558 15:27
Page 12 of 63
A8085.LST 29/3/2558 15:27
Page 13 of 63
A8085.LST 29/3/2558 15:27
989
990 0579 3E01 number43: mvi a,1
991 057B C9 ret
992
993
994
995
996
997
998
999
1000 ; execute key 0-F or 10H-19H
1001
1002 057C FE10 key_execute: cpi 10h
1003 057E D28805 jnc function_key ; 0-9 jump to data key
1004 0581 57 mov d,a
1005 0582 CD3706 call buzzer
1006 0585 F20406 jp data_key
1007
1008 0588 FE12 function_key: cpi 12h
1009 058A C29305 jnz function1
1010 058D CD3706 call buzzer
1011 0590 F24B0A jp increment
1012
1013 0593 FE15 function1: cpi 15h
1014 0595 C29E05 jnz function2
1015 0598 CD3706 call buzzer
1016 059B F25E0A jp decrement
1017
1018 059E FE10 function2: cpi 10h
1019 05A0 C2A905 jnz function3
1020 05A3 CD3706 call buzzer
1021 05A6 F2E709 jp address_mode
1022
1023 05A9 FE11 function3: cpi 11h
1024 05AB C2B405 jnz function4
1025 05AE CD3706 call buzzer
1026 05B1 F2F409 jp data_mode
1027
1028 05B4 FE13 function4: cpi 13h
1029 05B6 C2C005 jnz function5
1030 05B9 CD3706 call buzzer
1031 05BC F28109 jp go
1032 05BF C9 ret
1033
1034 05C0 FE14 function5: cpi 14h
1035 05C2 C2CB05 jnz function6
1036 05C5 CD3706 call buzzer
1037 05C8 F2FF09 jp function_2nd
1038
1039
1040 05CB FE16 function6: cpi 16h
1041 05CD C2D605 jnz function7
1042 05D0 CD3706 call buzzer
1043 05D3 F2A509 jp single_step
1044
1045 05D6 FE17 function7: cpi 17h
1046 05D8 C2E105 jnz function8
1047 05DB CD3706 call buzzer
1048 05DE F26709 jp home
1049
1050 05E1 FE18 function8: cpi 18h
1051 05E3 C2EC05 jnz function9
1052 05E6 CD3706 call buzzer
1053 05E9 F2230A jp modify_register
1054
1055 05EC C9 function9: ret
1056
1057 ; test running onboard led
1058
1059 05ED 3E01 test_led: mvi a,1
1060
1061 05EF D300 test_led1: out gpio
1062 05F1 115010 lxi d,1050h
1063 05F4 CDFB05 call delay
1064 05F7 07 rlc
Page 14 of 63
A8085.LST 29/3/2558 15:27
Page 15 of 63
A8085.LST 29/3/2558 15:27
Page 16 of 63
A8085.LST 29/3/2558 15:27
Page 17 of 63
A8085.LST 29/3/2558 15:27
Page 18 of 63
A8085.LST 29/3/2558 15:27
Page 19 of 63
A8085.LST 29/3/2558 15:27
Page 20 of 63
A8085.LST 29/3/2558 15:27
Page 21 of 63
A8085.LST 29/3/2558 15:27
Page 22 of 63
A8085.LST 29/3/2558 15:27
1673
1674 093D C9 ret
1675
1676
1677 ;--------------- ALT D delete byte ---------------------------------
1678 ; delete byte within 512 bytes
1679
1680 093E FE0D delete_byte: cpi 13
1681 0940 C26309 jnz option1
1682
1683 0943 2A29F0 lhld user_PC
1684 0946 E5 push h
1685 0947 E5 push h
1686 0948 C1 pop b
1687
1688 0949 03 inx b
1689 094A 110002 lxi d,512
1690
1691 094D delete_byte1:
1692 094D 0A ldax b
1693 094E 77 mov m,a
1694 094F 23 inx h
1695 0950 03 inx b
1696 0951 1B dcx d
1697 0952 7B mov a,e
1698 0953 B2 ora d ; check if DE ==0
1699 0954 C24D09 jnz delete_byte1
1700
1701 0957 E1 pop h
1702 0958 CDA40A call read_memory
1703 095B AF xra a
1704 095C 3225F0 sta entry_mode
1705 095F CDE80A call mode_indicator
1706
1707 0962 C9 ret
1708
1709
1710
1711
1712
1713
1714 0963 option1:
1715 0963 CD5406 call display_off ; no service key
1716 0966 C9 ret
1717
1718
1719
1720 0967 210081 home: lxi h,home_address
1721 096A 2229F0 shld user_PC
1722 096D 2110F0 lxi h,buffer
1723 0970 CDA40A call read_memory
1724 0973 AF xra a
1725 0974 3225F0 sta entry_mode
1726 0977 CDE80A call mode_indicator
1727 097A C9 ret
1728
1729
1730 097B 3E2A debug: mvi a,"*"
1731 097D CD1612 call cout
1732 0980 C9 ret
1733
1734 ; go function, jump from monitor program to user program
1735 ; save system stack and load user stack
1736 ; load CPU registers with user registers before jump
1737
1738 0981 go:
1739 0981 210000 lxi h,0
1740
1741 0984 39 dad sp ; save system stack
1742 0985 2256F0 shld save_stack
1743
1744 0988 2A33F0 lhld user_SP ; get user stack
1745 098B F9 sphl ; load user stack
1746
1747 098C 2A29F0 lhld user_PC
1748 098F E5 push h
Page 23 of 63
A8085.LST 29/3/2558 15:27
Page 24 of 63
A8085.LST 29/3/2558 15:27
1825
1826 09E7 3E01 address_mode: mvi a,1
1827 09E9 3225F0 sta entry_mode
1828 09EC CDA40A call read_memory
1829 09EF AF xra a
1830 09F0 3227F0 sta counter2
1831 09F3 C9 ret
1832
1833 09F4 AF data_mode: xra a
1834 09F5 3225F0 sta entry_mode
1835 09F8 3226F0 sta counter1
1836 09FB CDA40A call read_memory
1837 09FE C9 ret
1838
1839 09FF 3E02 function_2nd: mvi a,2
1840 0A01 3225F0 sta entry_mode
1841 0A04 3E77 mvi a,77h
1842 0A06 3210F0 sta buffer
1843 0A09 3E38 mvi a,38h
1844 0A0B 3211F0 sta buffer+1
1845 0A0E 3E78 mvi a,78h
1846 0A10 3212F0 sta buffer+2
1847 0A13 3E00 mvi a,0
1848 0A15 3213F0 sta buffer+3
1849 0A18 3E00 mvi a,0
1850 0A1A 3214F0 sta buffer+4
1851 0A1D 3E00 mvi a,0
1852 0A1F 3215F0 sta buffer+5
1853 0A22 C9 ret
1854
1855
1856 ; set entry mode to 3
1857 ; hex data will be used for register modifying
1858
1859 0A23 modify_register:
1860
1861 0A23 F5 push psw
1862
1863 0A24 3E03 mvi a,3
1864 0A26 3225F0 sta entry_mode
1865
1866 0A29 3A13F0 lda buffer+3
1867 0A2C F680 ori 80h
1868 0A2E 3213F0 sta buffer+3
1869
1870 0A31 3A12F0 lda buffer+2
1871 0A34 F680 ori 80h
1872 0A36 3212F0 sta buffer+2
1873
1874 0A39 3A11F0 lda buffer+1
1875 0A3C F680 ori 80h
1876 0A3E 3211F0 sta buffer+1
1877
1878 0A41 3A10F0 lda buffer
1879 0A44 F680 ori 80h
1880 0A46 3210F0 sta buffer
1881
1882 0A49 F1 pop psw
1883
1884 0A4A C9 ret
1885
1886
1887
1888
1889
1890
1891
1892
1893 ; increment key works with mode0 or mode1 display
1894
1895 0A4B 3E00 increment: mvi a,0
1896 0A4D 3225F0 sta entry_mode ; switch to data mode
1897 0A50 3226F0 sta counter1 ; clear event counter1
1898
1899 0A53 2A29F0 lhld user_PC
1900 0A56 23 inx h
Page 25 of 63
A8085.LST 29/3/2558 15:27
Page 26 of 63
A8085.LST 29/3/2558 15:27
Page 27 of 63
A8085.LST 29/3/2558 15:27
Page 28 of 63
A8085.LST 29/3/2558 15:27
Page 29 of 63
A8085.LST 29/3/2558 15:27
Page 30 of 63
A8085.LST 29/3/2558 15:27
2281
2282 0C64 2110F0 lxi h,buffer
2283 0C67 CD940C call scan
2284 0C6A 3A21F0 lda key
2285 0C6D FEFF cpi 0ffh
2286 0C6F C2640C jnz scan_key4 ; loop if key still pressed
2287 ;pop d
2288 0C72 F2750C jp scan_key3
2289
2290 0C75 scan_key2: ;pop d
2291
2292 ;dcr d
2293
2294 ;jp scan_key4 ; no repeat function
2295
2296 ; repeat if still pressed when timeout
2297
2298
2299 0C75 CD8D0C scan_key3: call debounce ; debounce after released
2300
2301 0C78 2110F0 lxi h,buffer
2302 0C7B CD940C scan_key1: call scan
2303 0C7E 3A21F0 lda key
2304 0C81 FEFF cpi 0ffh
2305 0C83 CA7B0C jz scan_key1 ; loop until key will be pressed
2306
2307 0C86 CD8D0C call debounce
2308
2309
2310 0C89 CD910B call get_key_code
2311
2312 ; call out2x
2313 0C8C C9 ret
2314
2315
2316 0C8D 060A debounce: mvi b,10
2317 0C8F 05 debounce1: dcr b
2318 0C90 C28F0C jnz debounce1
2319 0C93 C9 ret
2320
2321
2322 ; subroutine scan keyboard and display
2323 ; input: hl pointer to buffer
2324 ; exit: key = scan code
2325 ; -1 no key pressed
2326 ;
2327
2328 0C94 E5 scan: push h
2329 0C95 C5 push b
2330 0C96 D5 push d
2331
2332 0C97 0E06 mvi c,6 ; for 6-digit LED
2333 0C99 1E00 mvi e,0 ; digit scan code appears at 4-to-10 decoder
2334 0C9B 1600 mvi d,0 ; key position
2335 0C9D 3EFF mvi a,0ffh ; put -1 to key
2336 0C9F 3221F0 sta key ; key = -1
2337
2338
2339 0CA2 7B scan1: mov a,e
2340 0CA3 F6F0 ori 0f0h ; high nibble must be 1111
2341 0CA5 D312 out system_port_c ; active digit first
2342 0CA7 7E mov a,m ; load a with [hl]
2343 0CA8 D311 out system_port_b ; then turn segment on
2344
2345 0CAA 0600 mvi b,0 ; delay for transition process
2346 0CAC 05 wait1: dcr b
2347 0CAD C2AC0C jnz wait1
2348
2349 0CB0 DB10 in system_port_a ; read input port
2350
2351 0CB2 0608 mvi b,8 ; check all 8-row
2352 0CB4 1F shift_key: rar ; rotate right through carry
2353 0CB5 DABE0C jc next_key ; if carry = 1 then no key pressed
2354
2355 0CB8 F5 push psw
2356 0CB9 7A mov a,d
Page 31 of 63
A8085.LST 29/3/2558 15:27
Page 32 of 63
A8085.LST 29/3/2558 15:27
Page 33 of 63
A8085.LST 29/3/2558 15:27
Page 34 of 63
A8085.LST 29/3/2558 15:27
Page 35 of 63
A8085.LST 29/3/2558 15:27
Page 36 of 63
A8085.LST 29/3/2558 15:27
Page 37 of 63
A8085.LST 29/3/2558 15:27
Page 38 of 63
A8085.LST 29/3/2558 15:27
Page 39 of 63
A8085.LST 29/3/2558 15:27
2965
2966 1067 3A22F0 lda command
2967 106A FE66 cpi "f"
2968 106C C2AA10 jnz exit_fill
2969 106F 21561E lxi h,fill_text1
2970 1072 CD3F12 call put_str
2971
2972 1075 CD6C13 call get_hex1
2973 1078 67 mov h,a
2974 1079 CD6C13 call get_hex1
2975 107C 6F mov l,a
2976 107D E5 push h ; save begin address to stack
2977
2978 107E 21671E lxi h,fill_text2
2979 1081 CD3F12 call put_str
2980
2981 1084 CD6C13 call get_hex1
2982 1087 67 mov h,a
2983 1088 CD6C13 call get_hex1
2984 108B 6F mov l,a
2985 108C E5 push h ; save end address to stack
2986
2987 108D 21771E lxi h,fill_text3
2988 1090 CD3F12 call put_str
2989 1093 CD6C13 call get_hex1
2990
2991 1096 47 mov b,a ; byte save to B
2992
2993 1097 D1 pop d ; end address in DE
2994
2995 1098 E1 pop h ; begin address in HL
2996
2997 1099 fill_memory1:
2998
2999 1099 78 mov a,b
3000 109A 77 mov m,a
3001 109B 23 inx h
3002
3003 109C 7D mov a,l
3004 109D BB cmp e
3005 109E C29910 jnz fill_memory1
3006
3007 10A1 7C mov a,h
3008 10A2 BA cmp d
3009 10A3 C29910 jnz fill_memory1
3010
3011
3012 10A6 CD210D call send_prompt
3013 10A9 C9 ret
3014
3015 10AA exit_fill:
3016
3017 10AA C9 ret
3018
3019
3020
3021
3022 ;---------------- monitor function list -------------------------------
3023
3024 10AB monitor_function:
3025
3026 10AB 3A22F0 lda command
3027 10AE FE6D cpi "m"
3028 10B0 C2C310 jnz exit_monitor
3029
3030 10B3 CDC112 call new_line
3031 10B6 215322 lxi h,monitor_text
3032 10B9 CD3F12 call put_str
3033 10BC CDC112 call new_line
3034 10BF CD210D call send_prompt
3035 10C2 C9 ret
3036
3037 10C3 exit_monitor:
3038 10C3 C9 ret
3039
3040 ;----------------------- jump to user program --------------------
Page 40 of 63
A8085.LST 29/3/2558 15:27
3041
3042 10C4 3A22F0 jump_to_user_pgm: lda command
3043 10C7 FE6A cpi "j"
3044 10C9 C20D11 jnz exit_jump
3045
3046 10CC 212E1E lxi h, jump_text1
3047 10CF CD3F12 call put_str
3048
3049 10D2 2A29F0 lhld user_PC
3050 10D5 7C mov a,h
3051 10D6 CDB212 call out2x
3052 10D9 7D mov a,l
3053 10DA CDB212 call out2x
3054
3055 10DD 21401E lxi h,jump_text2
3056 10E0 CD3F12 call put_str
3057
3058 10E3 CD8513 call get_hex2
3059
3060 10E6 F5 push psw
3061
3062 10E7 3A23F0 lda flag1
3063 10EA E601 ani 1
3064 10EC C2FE10 jnz skip_load_PC
3065
3066 10EF F1 pop psw
3067
3068 10F0 67 mov h,a
3069 10F1 CD8513 call get_hex2
3070 10F4 6F mov l,a
3071 10F5 2229F0 shld user_PC
3072 10F8 CDC112 call new_line
3073 10FB C38109 jmp go
3074
3075 10FE skip_load_PC:
3076 10FE F1 pop psw
3077 10FF 3A23F0 lda flag1
3078 1102 E6FE ani 0feh
3079 1104 3223F0 sta flag1
3080 1107 CDC112 call new_line
3081 110A C38109 jmp go
3082
3083 110D C9 exit_jump: ret
3084
3085 ;------------ edit memory -----------------------------------------
3086
3087
3088 110E 3A22F0 edit_location: lda command
3089 1111 FE65 cpi "e"
3090 1113 C29011 jnz exit_edit
3091
3092 1116 21DD1D lxi h, edit_text
3093 1119 CD3F12 call put_str
3094 111C CD6C13 call get_hex1
3095 111F 67 mov h,a
3096 1120 CD6C13 call get_hex1
3097 1123 6F mov l,a
3098 1124 223BF0 shld pointer ;user_PC
3099
3100 1127 21F51D lxi h, edit_text1
3101 112A CD3F12 call put_str
3102
3103 112D 21201E lxi h, edit_text2
3104 1130 CD3F12 call put_str
3105
3106 1133 CDC112 edit1: call new_line
3107
3108 1136 2A3BF0 lhld pointer ;user_PC
3109 1139 7C mov a,h
3110 113A CDB212 call out2x
3111 113D 7D mov a,l
3112 113E CDB212 call out2x
3113 1141 CDCC12 call space
3114 1144 CDCC12 call space
3115 1147 3E5B mvi a,"["
3116 1149 CD1612 call cout
Page 41 of 63
A8085.LST 29/3/2558 15:27
Page 42 of 63
A8085.LST 29/3/2558 15:27
Page 43 of 63
A8085.LST 29/3/2558 15:27
Page 44 of 63
A8085.LST 29/3/2558 15:27
Page 45 of 63
A8085.LST 29/3/2558 15:27
Page 46 of 63
A8085.LST 29/3/2558 15:27
3497
3498 138D CD2212 call cin
3499 1390 FE0D cpi cr
3500 1392 CAD813 jz exit_get_hex2
3501
3502 1395 FE20 cpi " "
3503 1397 CAE113 jz exit_get_hex3
3504
3505 139A FE30 cpi 30h ; hex must be 0-9 and A-F
3506 139C DA8513 jc get_hex2
3507
3508 139F FE40 cpi 40h
3509 13A1 DAAE13 jc ascii_0_9
3510
3511 13A4 FE61 cpi 97 ; < 97?
3512 13A6 DA8513 jc get_hex2
3513
3514 13A9 FE67 cpi 103 ; >= 103?
3515 13AB D28513 jnc get_hex2
3516
3517 13AE ascii_0_9:
3518
3519 13AE CD1612 call cout
3520 13B1 CD4D13 call to_hex
3521 13B4 0F rrc
3522 13B5 0F rrc
3523 13B6 0F rrc
3524 13B7 0F rrc
3525 13B8 5F mov e,a
3526
3527 13B9 get_2nd_hex:
3528
3529 13B9 CD2212 call cin
3530
3531 13BC FE30 cpi 30h ; hex must be 0-9 and A-F
3532 13BE DAB913 jc get_2nd_hex
3533
3534 13C1 FE40 cpi 40h
3535 13C3 DAD013 jc ok_0_9
3536
3537 13C6 FE61 cpi 97 ; < 97?
3538 13C8 DAB913 jc get_2nd_hex
3539
3540 13CB FE67 cpi 103 ; >= 103?
3541 13CD D2B913 jnc get_2nd_hex
3542
3543 13D0 ok_0_9:
3544 13D0 CD1612 call cout
3545 13D3 CD4D13 call to_hex
3546 13D6 83 add e
3547 13D7 C9 ret
3548
3549 13D8 exit_get_hex2:
3550
3551 13D8 3A23F0 lda flag1
3552 13DB F601 ori 1
3553 13DD 3223F0 sta flag1 ; Q key has been pressed
3554 13E0 C9 ret
3555
3556 13E1 exit_get_hex3:
3557
3558 13E1 3A23F0 lda flag1
3559 13E4 F602 ori 2
3560 13E6 3223F0 sta flag1 ; SPACE key has been pressed
3561 13E9 C9 ret
3562
3563
3564 ; add check sum
3565
3566
3567 ; get record, write to SRAM and jump to 8000h
3568 ; entry: A= byte received, B= byte check sum
3569
3570 add_bcs: macro ; add accumulator with byte check sum stored in B
3571 push psw
3572 add b
Page 47 of 63
A8085.LST 29/3/2558 15:27
Page 48 of 63
A8085.LST 29/3/2558 15:27
3649
3650 1442 CD5913 data_record: call get_hex ; get data byte
3651 1445 77 mov m,a ; save to SRAM at [HL]
3652
3653 1446 add_bcs
3654 1446 F5 push psw
3655 1447 80 add b
3656 1448 47 mov b,a
3657 1449 F1 pop psw
3658 144A endm
3659
3660 144A CD7014 call inc_bcd1
3661
3662 ; ori 7fh
3663 ; out system_port_c ; make buzzer sound
3664
3665
3666 144D 23 inx h ; next location
3667
3668 144E 0D dcr c
3669 144F C24214 jnz data_record ; until c = 0
3670
3671 1452 78 mov a,b
3672 1453 2F cma
3673 1454 47 mov b,a
3674 1455 04 inr b ; compute two's complement
3675
3676 1456 CD5913 call get_hex ; get check sum
3677
3678 1459 B8 cmp b
3679 145A CA6414 jz skip_error
3680
3681 145D 3A20F0 lda bcs
3682 1460 3C inr a
3683 1461 3220F0 sta bcs
3684
3685 1464 skip_error:
3686 1464 3A39F0 lda temp ; then shift into temp8
3687 1467 07 rlc
3688 1468 3239F0 sta temp
3689 146B D300 out 0 ; send to GPIO
3690
3691 146D C3EA13 jmp get_record ; back to next record
3692
3693
3694 ;---------------- increment BCD counter1 -------------------------
3695
3696 1470 E5 inc_bcd1: push h
3697
3698 1471 2140F0 lxi h,bcd_counter1
3699 1474 AF xra a
3700
3701 1475 7E mov a,m
3702 1476 C601 adi 1
3703 1478 27 daa
3704 1479 77 mov m,a
3705 147A 23 inx h
3706
3707 147B 7E mov a,m
3708 147C CE00 aci 0
3709 147E 27 daa
3710 147F 77 mov m,a
3711 1480 23 inx h
3712 1481 7E mov a,m
3713 1482 CE00 aci 0
3714 1484 27 daa
3715 1485 77 mov m,a
3716
3717 1486 E1 pop h
3718
3719 1487 C9 ret
3720
3721 1488 E5 inc_bcd2: push h
3722
3723 1489 2143F0 lxi h,bcd_counter2
3724 148C AF xra a
Page 49 of 63
A8085.LST 29/3/2558 15:27
3725
3726 148D 7E mov a,m
3727 148E C601 adi 1
3728 1490 27 daa
3729 1491 77 mov m,a
3730 1492 23 inx h
3731
3732 1493 7E mov a,m
3733 1494 CE00 aci 0
3734 1496 27 daa
3735 1497 77 mov m,a
3736 1498 23 inx h
3737 1499 7E mov a,m
3738 149A CE00 aci 0
3739 149C 27 daa
3740 149D 77 mov m,a
3741
3742 149E E1 pop h
3743
3744 149F C9 ret
3745
3746
3747 14A0 print_bcd1:
3748 14A0 2142F0 lxi h,bcd_counter1+2
3749 14A3 7E mov a,m
3750 14A4 CDB212 call out2x
3751 14A7 2141F0 lxi h,bcd_counter1+1
3752 14AA 7E mov a,m
3753 14AB CDB212 call out2x
3754 14AE 2140F0 lxi h,bcd_counter1
3755 14B1 7E mov a,m
3756 14B2 CDB212 call out2x
3757 14B5 21CD1E lxi h,byte_text
3758 14B8 CD3F12 call put_str
3759 14BB C9 ret
3760
3761 14BC 210000 clear_bcd1: lxi h,0
3762 14BF 2240F0 shld bcd_counter1
3763 14C2 2241F0 shld bcd_counter1+1
3764 14C5 2242F0 shld bcd_counter1+2
3765 14C8 C9 ret
3766
3767 14C9 print_bcd2:
3768 14C9 2145F0 lxi h,bcd_counter2+2
3769 14CC 7E mov a,m
3770 14CD CDB212 call out2x
3771 14D0 2144F0 lxi h,bcd_counter2+1
3772 14D3 7E mov a,m
3773 14D4 CDB212 call out2x
3774 14D7 2143F0 lxi h,bcd_counter2
3775 14DA 7E mov a,m
3776 14DB CDB212 call out2x
3777 14DE 21CD1E lxi h,byte_text
3778 14E1 CD3F12 call put_str
3779 14E4 C9 ret
3780
3781 14E5 210000 clear_bcd2: lxi h,0
3782 14E8 2243F0 shld bcd_counter2
3783 14EB 2244F0 shld bcd_counter2+1
3784 14EE 2245F0 shld bcd_counter2+2
3785 14F1 C9 ret
3786
3787 ; constants
3788
3789 14F2 INS_TABLE:
3790
3791 14F2 F216 DWL C0 ; "NOP",TAB,RS ; 00
3792 14F4 F716 DWL C1 ; "LXI",TAB,"B,",RS ; 01
3793 14F6 FE16 DWL C2 ; "STAX",TAB,"B",RS ; 02
3794 14F8 0517 DWL C3 ; "INX",TAB,"B",RS ; 03
3795 14FA 0B17 DWL C4 ; "INR",TAB,"B",RS ; 04
3796 14FC 1117 DWL C5 ; "DCR",TAB,"B",RS ; 05
3797 14FE 1717 DWL C6 ; "MVI",TAB,"B,",RS ; 06
3798 1500 1E17 DWL C7 ; "RLC",TAB,RS ; 07
3799 1502 2317 DWL C8 ; "DFB",TAB,RS ; 08
3800 1504 2817 DWL C9 ; "DAD",TAB,"B",RS ; 09
Page 50 of 63
A8085.LST 29/3/2558 15:27
Page 51 of 63
A8085.LST 29/3/2558 15:27
Page 52 of 63
A8085.LST 29/3/2558 15:27
Page 53 of 63
A8085.LST 29/3/2558 15:27
Page 54 of 63
A8085.LST 29/3/2558 15:27
Page 55 of 63
A8085.LST 29/3/2558 15:27
Page 56 of 63
A8085.LST 29/3/2558 15:27
Page 57 of 63
A8085.LST 29/3/2558 15:27
Page 58 of 63
A8085.LST 29/3/2558 15:27
Page 59 of 63
A8085.LST 29/3/2558 15:27
Page 60 of 63
A8085.LST 29/3/2558 15:27
Page 61 of 63
A8085.LST 29/3/2558 15:27
Page 62 of 63
A8085.LST 29/3/2558 15:27
Page 63 of 63