User Manual 4.2
User Manual 4.2
User Manual 4.2
User's Manual
Getting Started…..………………………………………………………………5
Connecting Terminal..……………………………………….…………………18
Hardware……………………………………………………………………….27
2
Overview
The 8085 Microprocessor kit 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
kit can receive the Intel hex file and disassemble the machine code into 8085
instructions.
3
Hardware Features:
Software Features:
4
Getting Started
AC Adapter
The kit requires DC power input to operate. The input voltage accepts from +7.5V
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. The center pin is positive.
- +
Figure 2: Polarity of DC jack.
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 speaker will
sound beep. The HOME location is pointed to RAM at address 8100H. The data
LED will display the content at 8100H.
5
LED Display and Keypad
The kit has 6 digits 7-segment LED and 28 tact switches keypad.
Four digits is used for displaying the memory address and user registers contents.
Two digits “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.
8100 1E.
Figure 3: ADDRESS and DATA fields.
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
The functions key are:
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 the 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 memory spaces 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 us 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 content of
the accumulator using onboard gpio LED. The kit has 8-bit dot LED tied to the 8-
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 accumulator
content.
8
1010 1010 Accumulator
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 8085 hex 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 as shown below.
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 content to the gpio port at location 00
has two bytes machine code, D3, 00. D3 is the instruction OUT and 00 is port
location.
10
Figure 6: I/O space allocation, User PPI is not available for this version.
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.
8100 3C.
Step 2 Press key + to increment address.
The address display will show 8101. Then repeat step1 until 81 byte was entered
to address 8105.
8100 d3.
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.
12
We can keep press key STEP, we will see every time 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.
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.
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.
13
How can we make the speed of counting slower? We can just simply add the job
that uses CPU time. 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
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
both are ZERO, the CPU will continue execute the next instruction.
14
Here is the translation from instructions to machine code.
This program has 17 bytes . 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
8109 81
810A 15
810B C2
810C 06
810D 81
810E C3
810F 00
8110 81
15
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.
Here is the program that adds two BCD numbers 19H and 02H. The result will be
21H.
16
8106 FF rst 7 ; jump back to monitor
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 GO, and check result in AF again, we will
get 21. This the correct BCD number from the addition of 19+02=21.
17
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. You may download free
terminal program, teraterm from this URL,
http://ttssh2.sourceforge.jp/index.html.en
RS232C cable
Figure 7: Connecting PC running teraterm and kit with RS232 cross cable.
There is no need to switch between standalone mode and terminal mode. Both
commands using keypad or terminal commands are working concurrently.
8100>
18
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...
19
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.
20
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.
21
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
22
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
23
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.
24
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
25
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
26
Hardware
A block diagram of the 8085 kit is shown below. For complete hardware
schematic, see Appendix D.
CPU
The CPU is the 8-bit Microprocessor, 80C85. The XTAL frequency is 4MHz. The
reset signal is generated by RC circuit. The CPU is reset 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 operating
properly.
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.
27
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 list of
location of interrupts.
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.
GPIO1
GPIO1 provides 8-bit output port. The I/O address is 00. The output drives 8-dot
LED. We can use it for program testing easily.
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.
20H COUNTER0
21H COUNTER1
22H COUNTER2
23H CONTROL REGISTER
28
Headers and Connectors
29
Onboard LCD Header JR1
30
RS232C DB9 male connector VB1
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, D10 indicates the
pulse is activated when press Test button.
Technical Specifications
31
Monitor Call Number
00 - demo
Scan 7-segment display with buffer display pointed by HL
Entry: HL
Exit: none
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
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
32
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
Entry: A
Exit: none
0D - demo2
Running GPIO LED
Entry: none
Exit: none
User can replace U2, SRAM with a Nonvolatile RAM for program storage, when
the board is powered 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 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 be changed to 00, thus get back to normal RESET.
33
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
34
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
35
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
36
mvi a,0 ; clear a
out system_port_b ; turn off led
pop d
pop b
pop h
ret
37
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
38
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
39
40
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
41
count dfs 1 ; use RAM one byte for count
variable
end
42
Appendix E Machine code and 8085 Instructions
43
!""#$%&'()(*+,-&$#(./%#(+$%(*$#0/$&,(/1(2324(5$6789,7&/$6
44
5 4 3 2 1
D[0..7]
A[0..7]
0x0000-0x7FFF 0x8000-0xFFFF
32kB ROM 32kB SRAM U3
U1 U2
U4 A0 10 11 D0 A0 10 11 D0 D0 2 19
A1 A0 O0 D1 A1 A0 D0 D1 D1 1D 1Q
9 12 9 12 3 18
D0 A0 A2 A1 O1 D2 A2 A1 D1 D2 D2 2D 2Q
2 19 8 13 8 13 4 17
D D1 1D 1Q A1 A3 A2 O2 D3 A3 A2 D2 D3 D3 3D 3Q D
3 18 7 15 7 15 5 16
D2 2D 2Q A2 A4 A3 O3 D4 A4 A3 D3 D4 D4 4D 4Q
4 17 6 16 6 16 6 15
D3 3D 3Q A3 A5 A4 O4 D5 A5 A4 D4 D5 D5 5D 5Q
5 16 5 17 5 17 7 14
D4 4D 4Q A4 A6 A5 O5 D6 A6 A5 D5 D6 D6 6D 6Q
6 15 4 18 4 18 8 13
D5 5D 5Q A5 A7 A6 O6 D7 A7 A6 D6 D7 D7 7D 7Q
7 14 3 19 3 19 9 12
D6 6D 6Q A6 A8 A7 O7 A8 A7 D7 8D 8Q
8 13 25 25
D7 7D 7Q A7 A9 A8 A9 A8 GPIO1
9 12 24 24 11
8D 8Q A10 A9 A10 A9 LE
21 21 1
ALE A11 A10 A11 A10 +5V OE D0
11 23 23 D0
LE A12 A11 A12 A11 D1
1 2 2 20 D1
OE A13 A12 A13 A12 VCC D1 D2 D3 D4 D5 D6 D7 D8 D2
26 26 D2
A14 A13 A14 A13 D3
20 27 1 D3
+5V VCC A14 A14 74HC573 D4
ROM_CE RAM_CE D5 D4
20 20 D5
74HC573 /RD CE /RD CE D6
22 22 D6
OE /WR OE D7
1 27 D7
+5V VPP WE D9
27C256 HM62256B LED 3mm
A[8..14] 1N5237A
A0
A0
memory & i/o decoder
A1
C A1 C
U5
A2
S0 RAM_CE A2
U6 2 12
D0 S1 I I/O/Q ROM_CE
36 12 3 13
30pF C1 RST-IN AD0 D1 A4 I I/O/Q
13 4 14 SYSTEM_PPI
AD1 D2 A5 I I/O/Q
1 14 5 15 GPIO1
X1 AD2 D3 A6 I I/O/Q
15 6 16 CTC
4MHz AD3 D4 A7 I I/O/Q
16 7 17 USER_PPI
C2 Q1 AD4 D5 IO/M I I/O/Q
2 17 8 18 UART
X2 AD5 D6 A15 I I/O/Q
18 9 19 LCD_E
+5V SID AD6 D7 I I/O/Q +5V VCC
5 19
30pF TRAP SID AD7 A8 /RD
6 21 1
TRAP A8 A9 /WR I/CLK
22 11
R1 RST5.5 A9 A10 I/OE
9 23 U7A U7B VCC
10k RST6.5 RST 5.5 A10 A11
8 24 1 5
RST7.5 RST 6.5 A11
S1 RESET 7 25 A12 GAL16V8B 3 4 VSS
RST 7.5 A12 A13
26 2 6
INTR A13 A14
10 27
INTR A14 A15
28 4001 4001
R2 INTA A15
11
100 + C3 INTA ALE
30
10uF S0 ALE
29 31 WR U8A
S0 WR +5V
32 RD SW1
+5V S1 RD *RST5.5 RST5.5
B 33 34 1 8 1 2 B
S1 IO/M RESET_OUT *RST6.5
3 reset 2 7
RST-OT CLKOUT R3
39 37 CLKOUT 3 6
R4 10k HOLD CLKO SOD 10k
4 4 5 74LS14
SOD
3
D0 A0
+5V 10k D1 1 2 A1 SW2 4001 74LS14
D2 3 4 A2 2 U8C
D3 5 6 A3 1
SID D4 7 8 A4 RST7.5
3 5 6
D5 9 10 A5
D6 11 12 A6 SW SPDT
+5V D7 13 14 A7
U9 U7D 74LS14
/RD 15 16
1 3 OUT1 12 *RST7.5 U8D
A QA /WR 17 18
2 4 11
B QB
5 IO/M 19 20 *RST5.5 OUT2 13 *INTR 9 8 INTR
QC SID 21 22 *RST6.5
6
QD ALE 23 24 *RST7.5
10 4001
ALE QE SOD 25 26 *INTR R6
8 11 74LS14
CLK QF +5V S0 27 28 INTA 10k 330 +5V
12 U8E
A QG TRAP S1 29 30 +5V D10 R7 A
9 13
CLR QH CLKOUT 31 32
11 10
R8 READY 33 34 HOLD
74HC164
10k RESET_OUT 35 36 HLDA +5V
U8F
37 38 LED
74LS14
39 40 Title
12 13 TRACE
HEADER 20X2 8085 Microprocesor Kit
U10 U11
U12 R9
PB0 2 18 1 16 A 14 A 14
PB1 1A1 1Y1 B A B A
4 16 2 15 16 16
PB2 1A2 1Y2 C B C B
6 14 3 14 13 13
D PB3 1A3 1Y3 D C D C D
8 12 4 13 3 3
PB4 1A4 1Y4 E D E D
11 9 5 12 5 5
PB5 2A1 2Y1 F E F E
13 7 6 11 11 11
PB6 2A2 2Y2 G F G F
15 5 7 10 15 15
PB7 2A3 2Y3 DP G DP G
17 3 8 9 7 7
2A4 2Y4 DP DP
1 R-PACK
DIGIT1
DIGIT2
DIGIT3
DIGIT4
DIGIT1
DIGIT2
DIGIT3
DIGIT4
1G
19 4 4
2G L1L2L3 L1L2L3
74LS244
LTC-4727JR LTC-4727JR
8
U13
1
0
2
1
C 3 C
PC0 2
15 4
PC1 A 3
14 5
PC2 B 4
13 6
PC3 C 5
12 7
D 6
9
7
10
8
11
9
74LS145 SPEAKER
SW3
TRACE
D0 SW4 SW5 SW6 SW7 1 2 USER
D1 D0
D2 D1 8255
D2 1 2 1 2 1 2 1 2 OPTION
1
D3 25 PB7 R10
D4 D3 PB7 PB6 SPEAKER
24 C D E F SW8 2 Q3
D5 D4 PB6 PB5 BC557
D5 23
D6 PB5 PB4 SW9 SW10 SW11 SW12 PA6 4.7k
D6 22 1 2
D7 PB4 PB3
3
D7 21
PB3 PB2 VCC
20 1 2 1 2 1 2 1 2 MODE
PB2 PB1
19
PB1 PB0 R11
B 18 8 9 A B D11 LS1 B
PB0 SW13
10 PC7
PC7 PC6 SW14 SW15 SW16 SW17 PA7 330
11 1 2 TONE
PC6 PC5
SYSTEM_PPI 6 12 SPEAKER
CS PC5 PC4 +5V
A1 reset 35
RESET PC4
13
PC3
1 2 1 2 1 2 1 2 USER1 R12
8 17
A0 A1 PC3 PC2
9
A0 PC2
16
PC1
4 5 6 7
36 15
WR WR PC1 PC0 10
5 14
RD RD PC0
D7 27 37 PA7 SW18 SW19 SW20 SW21
D6 D7 PA7 PA6 10k RESISTOR SIP 9 R13 VCC
28 38
D5 D6 PA6 PA5 PA0
29 39 1 2 1 2 1 2 1 2 2 1
D4 D5 PA5 PA4 PA1
30 40 3
D3 D4 PA4 PA3 PA2
31
D3 PA3
1 0 1 2 3 4
D2 32 2 PA2 PA3 5 +5V VCC
D1 D2 PA2 PA1 PA4
33 3 6
D0 D1 PA1 PA0 PA5
34 4 7
D0 PA0 SW22 SW23 SW24 SW25 PA6 8 VCC
U14 PA7 9
1 2 1 2 1 2 1 2 C
VSS
A
INC DEC STEP HOME A
SW26 SW27 SW28 SW29 A0
A0
1 2 1 2 1 2 1 2 A1
A1
GO ALT ADDR DATA A2 Title
A2
8085 Microprocesssor Kit
D[0..7]
2
D6 7
D7 D6
8 1 3
D7
C 24 C
+5V VCC CSOUT
25 23
ADS DDIS R15
35 29
reset RESET NC 10K
VCC 16
XTAL1/CLK
17
D0 XTAL2
VSS D1 D0
D1 9 15
D2 RCLK BAUDOUT
D3 D2
D3 8250
D4
D5 D4
A0 D6 D5
+5V
A0 D7 D6
A1 D7
A1
10uF 10V 10uF C5
A2
+
C4
+
A2
U17
2 1
+5V +5V VB1 V+ C+ 10uF
3
C1-
5 6 4
C6 V- C2+
9 5
+ C2-
+
4 C7
B 8 10uF B
3 14 11 TXD
C8 C9 + C10 + C11 T1OUT T1IN RTS
7 7 10
100nF 100nF 10uF 10uF T2OUT T2IN
2 13 12 RXD
R1IN R1OUT DCD
6 8 9
R2IN R2OUT
1
D12 R16 2k
POWER
+5V
TP1 U18 J1
VCC LM7805/TO D13 DC input
+5V 3 1 2 1 1
1 VOUT VIN
C14 10uF 16V
GND
+ + 1N4007
2
C15 C16 C17 C18
C12 C19 C20 C13
0.1uF 0.1uF 0.1uF 0.1uF
TP2 0.1uF 0.1uF 1000uF 16V
2
A DC2 A
GND 1
0.1uF
Title
8085 Microprocessor Kit
45
46
Appendix G Monitor source code listing
47
B8085.LST 29/12/2559 12:32
1 ;-----------------------------------------------------------------
2 ; B8085.ASM
3 ; monitor program for MTK-85 8085 MICROPROCESSOT TRAINING KIT
4 ; COPYTIGHT (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 ; 3 April 2016 replace buzzer with small speaker for tone experiment
15 ; add beep/no beep with ALT F press
16 ; 16 April 2016 add delay after no beep
17 ;
18 ;-----------------------------------------------------------------
19
20 0000 CPU "8085.TBL" ;CPU TABLE
21 0000 HOF "INT8" ;HEX FORMAT
22
23
24 ; ---------- onboard GPIO --------------------------------------
25
26 0000 = gpio equ 0 ; D0-D3 is 4-bit output port, D4-D7 is 4-bit input port
27
28
29 ;---------- 8255 PPI system port I/O address ----------------------
30
31 0010 = system_port_a: equ 10h
32 0011 = system_port_b: equ 11h
33 0012 = system_port_c: equ 12h
34 0013 = system_port_control: equ 13h
35
36 ;-------------------- 8254 counter/timer --------------------------
37
38 0020 = counter0_8254 equ 20h
39 0021 = counter1_8254 equ 21h
40 0022 = counter2_8254 equ 22h
41 0023 = control_8254 equ 23h
42
43 0034 = control_word_8254 equ 00110100B ; mode 0, counter0
44
45 ;---------- 8255 PPI user port I/O address ------------------------
46
47 0030 = user_port_a: equ 30h
48 0031 = user_port_b: equ 31h
49 0032 = user_port_c: equ 32h
50 0033 = user_port_control: equ 33h
51
52
53 ;---------- 16C550 compatible UART I/O address --------------------
54 ; e.g., UM8250B, 16C450, 16C550
55
56 0040 = uart_buffer: equ 40h
57 0045 = uart_line_status: equ 45h
58 0042 = uart_fifo: equ 42h
59 0043 = uart_lcr: equ 43h
60 0040 = uart_divisor_lsb: equ 40h
61 0041 = uart_divisor_msb: equ 41h
62 0047 = uart_scr: equ 47h
63
64
65 ;------------------- onboard LCD registers ------------------------
66
67 0050 = command_write equ 50h
68 0052 = command_read equ 52h
69 0051 = data_write equ 51h
70 0053 = data_read equ 53h
71 0080 = busy equ 80h
72
73 0009 = TAB EQU 9 ; ASCII TAB
74 0000 = RS EQU 0 ; terminator
75
76 000D = cr: equ 0dh
Page 1 of 64
B8085.LST 29/12/2559 12:32
Page 2 of 64
B8085.LST 29/12/2559 12:32
Page 3 of 64
B8085.LST 29/12/2559 12:32
Page 4 of 64
B8085.LST 29/12/2559 12:32
305
306
307
308
309 ;--------------------- LCD driver routines --------------------------------
310
311 01F6 F5 lcd_ready: push psw
312
313 01F7 DB52 lcd_ready1: in command_read
314 01F9 E680 ani 80h
315 01FB C2F701 jnz lcd_ready1 ; wait until lcd ready
316 01FE F1 pop psw
317
318 01FF C9 ret
319
320 0200 CDF601 clear_lcd: call lcd_ready
321 0203 3E01 mvi a,1
322 0205 D350 out command_write
323 0207 C9 exit_clear: ret
324
325 0208 CDF601 init_lcd: call lcd_ready
326 020B 3E38 mvi a,38h
327 020D D350 out command_write
328 020F CDF601 call lcd_ready
329 0212 3E0C mvi a, 0ch
330 0214 D350 out command_write
331 0216 CD0002 call clear_lcd
332
333 0219 C9 ret
334
335 ; print ASCII text on LCD
336 ; entry: HL pointer with 0 for end of string
337
338 021A 7E put_str_lcd: mov a,m ; get A from [HL]
339 021B FE00 cpi 0
340 021D C22102 jnz put_str_lcd1
341 0220 C9 ret
342
343 0221 put_str_lcd1:
344
345 0221 CDF601 call lcd_ready
346 0224 D351 out data_write
347 0226 23 inx h
348 0227 F21A02 jp put_str_lcd
349
350 ; goto_xy set cursor location on lcd
351 ; entry: HL: H = x, L = y
352
353 022A CDF601 goto_xy: call lcd_ready
354 022D 7D mov a,l
355 022E FE00 cpi 0
356 0230 C23902 jnz goto_xy1
357 0233 7C mov a,h
358 0234 C680 adi 80h
359 0236 D350 out command_write
360 0238 C9 ret
361
362 0239 FE01 goto_xy1: cpi 1
363 023B C24402 jnz goto_xy2
364 023E 7C mov a,h
365 023F C6C0 adi 0c0h
366 0241 D350 out command_write
367 0243 C9 ret
368
369 0244 FE02 goto_xy2: cpi 2
370 0246 C24F02 jnz goto_xy3
371 0249 7C mov a,h
372 024A C694 adi 094h
373 024C D350 out command_write
374 024E C9 ret
375
376 024F FE03 goto_xy3: cpi 3
377 0251 C25A02 jnz goto_xy4
378 0254 7C mov a,h
379 0255 C6D4 adi 0d4h
380 0257 D350 out command_write
Page 5 of 64
B8085.LST 29/12/2559 12:32
Page 6 of 64
B8085.LST 29/12/2559 12:32
457
458 02A3 222AF0 shld user_PC ; store next PC
459
460 02A6 210000 lxi h,0000h
461 02A9 39 dad sp ; get SP
462 02AA 2234F0 shld user_SP ; save user SP
463
464 02AD CDBE0A call read_memory
465 02B0 CD540F call register_display1
466
467 02B3 2A57F0 lhld save_stack
468
469 02B6 F9 sphl ; restore system stack
470
471
472 02B7 C9 ret
473
474
475 ; test diplay register after break
476 ; RST 2 opcode is D7
477 ; later will be changed to RST 7
478
479 02B8 service_rst2:
480 02B8 F5 push psw
481 02B9 C5 push b
482 02BA D5 push d
483
484 02BB E1 pop h
485 02BC 2230F0 shld user_DE
486 02BF E1 pop h
487 02C0 222EF0 shld user_BC
488 02C3 E1 pop h
489 02C4 222CF0 shld user_AF
490 02C7 E1 pop h
491
492 02C8 222AF0 shld user_PC ; store next PC
493
494 02CB 210000 lxi h,0000h
495 02CE 39 dad sp ; get content of SP
496
497 02CF 2234F0 shld user_SP ; save user SP
498
499 02D2 CDBE0A call read_memory
500 02D5 CD540F call register_display1
501
502 02D8 2A57F0 lhld save_stack
503
504 02DB F9 sphl ; restore system stack
505
506
507 02DC C9 ret
508
509
510 ; service trap for single step running
511 ; disable trap input by setting system port c.6
512 ; save CPU registers to user registers
513
514 02DD service_trap:
515 02DD F5 push psw ; save A and Flag
516
517 02DE 3EFF mvi a,0ffh
518 02E0 D312 out system_port_c ; turn trap off by clearing shift register
519
520 02E2 C5 push b
521 02E3 D5 push d
522 02E4 E5 push h
523
524 02E5 E1 pop h
525 02E6 2232F0 shld user_HL ; save HL
526 02E9 E1 pop h
527 02EA 2230F0 shld user_DE
528 02ED E1 pop h
529 02EE 222EF0 shld user_BC
530 02F1 E1 pop h
531 02F2 222CF0 shld user_AF
532
Page 7 of 64
B8085.LST 29/12/2559 12:32
Page 8 of 64
B8085.LST 29/12/2559 12:32
Page 9 of 64
B8085.LST 29/12/2559 12:32
685
686 03B3 E5 push h
687
688 03B4 7C mov a,h
689 03B5 CDCB12 call out2x
690 03B8 7D mov a,l
691 03B9 CDCB12 call out2x
692 03BC CDE512 call space
693
694 03BF 7E mov a,m ; get opcode
695 03C0 CD2604 call get_number_of_byte
696 03C3 4F mov c,a
697
698 03C4 7E d_disassem3: mov a,m
699 03C5 CDCB12 call out2x
700 03C8 23 inx h
701 03C9 0D dcr c
702 03CA C2C403 jnz d_disassem3
703
704 03CD E1 pop h
705
706 03CE 7E mov a,m
707 03CF CD2604 call get_number_of_byte
708 03D2 FE01 cpi 1
709 03D4 C2DC03 jnz d_one_tab
710
711 03D7 3E09 mvi a,tab ; print two tabs for one byte opcode
712 03D9 CD2F12 call cout
713
714 03DC 3E09 d_one_tab: mvi a,tab ; else only one tab
715 03DE CD2F12 call cout
716
717 03E1 E5 push h
718
719 03E2 7E mov a,m ; get opcode
720
721 03E3 F5 push psw
722
723 03E4 210000 lxi h,0000h ; clear HL
724 03E7 6F mov l,a
725
726 03E8 29 dad h ; HL = HLx2
727
728 03E9 5D mov e,l
729 03EA 54 mov d,h
730
731 03EB 210B15 lxi h,ins_table
732 03EE 19 dad d ; ADD HL,DE
733 03EF 5E mov e,m
734 03F0 23 inx h
735 03F1 56 mov d,m
736
737 03F2 6B mov l,e
738 03F3 62 mov h,d
739
740 03F4 CD5812 call put_str
741
742 03F7 F1 pop psw
743 03F8 E1 pop h
744
745 03F9 CD2604 call get_number_of_byte
746 03FC FE01 cpi 1
747 03FE C20604 jnz d_disassem1
748 0401 23 inx h
749 0402 223CF0 shld pointer
750 0405 C9 ret
751
752 0406 FE02 d_disassem1: cpi 2
753 0408 C21504 jnz d_disassem2
754 040B 23 inx h
755 040C 7E mov a,m
756 040D CDCB12 call out2x
757 0410 23 inx h
758 0411 223CF0 shld pointer
759 0414 C9 ret
760
Page 10 of 64
B8085.LST 29/12/2559 12:32
Page 11 of 64
B8085.LST 29/12/2559 12:32
Page 12 of 64
B8085.LST 29/12/2559 12:32
Page 13 of 64
B8085.LST 29/12/2559 12:32
Page 14 of 64
B8085.LST 29/12/2559 12:32
Page 15 of 64
B8085.LST 29/12/2559 12:32
Page 16 of 64
B8085.LST 29/12/2559 12:32
Page 17 of 64
B8085.LST 29/12/2559 12:32
Page 18 of 64
B8085.LST 29/12/2559 12:32
Page 19 of 64
B8085.LST 29/12/2559 12:32
Page 20 of 64
B8085.LST 29/12/2559 12:32
Page 21 of 64
B8085.LST 29/12/2559 12:32
Page 22 of 64
B8085.LST 29/12/2559 12:32
1673 092F 110002 lxi d,512 ; load counter with 512 bytes
1674
1675 0932 insert_byte1:
1676 0932 0A ldax b
1677 0933 77 mov m,a
1678 0934 2B dcx h
1679 0935 0B dcx b
1680 0936 1B dcx d
1681 0937 7B mov a,e
1682 0938 B2 ora d ; check DE ==0
1683 0939 C23209 jnz insert_byte1
1684
1685 093C E1 pop h ; restore user PC
1686 093D AF xra a
1687 093E 77 mov m,a ; store 00 at insert byte
1688 093F CDBE0A call read_memory
1689 0942 AF xra a
1690 0943 3226F0 sta entry_mode
1691 0946 CD020B call mode_indicator
1692
1693 0949 C9 ret
1694
1695
1696 ;--------------- ALT D delete byte ---------------------------------
1697 ; delete byte within 512 bytes
1698
1699 094A FE0D delete_byte: cpi 13
1700 094C C26F09 jnz beep_chk
1701
1702 094F 2A2AF0 lhld user_PC
1703 0952 E5 push h
1704 0953 E5 push h
1705 0954 C1 pop b
1706
1707 0955 03 inx b
1708 0956 110002 lxi d,512
1709
1710 0959 delete_byte1:
1711 0959 0A ldax b
1712 095A 77 mov m,a
1713 095B 23 inx h
1714 095C 03 inx b
1715 095D 1B dcx d
1716 095E 7B mov a,e
1717 095F B2 ora d ; check if DE ==0
1718 0960 C25909 jnz delete_byte1
1719
1720 0963 E1 pop h
1721 0964 CDBE0A call read_memory
1722 0967 AF xra a
1723 0968 3226F0 sta entry_mode
1724 096B CD020B call mode_indicator
1725
1726 096E C9 ret
1727
1728 ;--------------- ALT F BEEP/NO BEEP ---------------------------------
1729 096F FE0F beep_chk: cpi 15
1730 0971 C27D09 jnz option1
1731
1732 0974 3A24F0 lda beep_flag
1733 0977 EE01 xri 1
1734 0979 3224F0 sta beep_flag
1735 097C C9 ret
1736
1737
1738 097D option1:
1739 097D CD6006 call display_off ; no service key
1740 0980 C9 ret
1741
1742
1743
1744 0981 210081 home: lxi h,home_address
1745 0984 222AF0 shld user_PC
1746 0987 2110F0 lxi h,buffer
1747 098A CDBE0A call read_memory
1748 098D AF xra a
Page 23 of 64
B8085.LST 29/12/2559 12:32
Page 24 of 64
B8085.LST 29/12/2559 12:32
Page 25 of 64
B8085.LST 29/12/2559 12:32
1901
1902 0A5B 3A10F0 lda buffer
1903 0A5E F680 ori 80h
1904 0A60 3210F0 sta buffer
1905
1906 0A63 F1 pop psw
1907
1908 0A64 C9 ret
1909
1910
1911
1912
1913
1914
1915
1916
1917 ; increment key works with mode0 or mode1 display
1918
1919 0A65 3E00 increment: mvi a,0
1920 0A67 3226F0 sta entry_mode ; switch to data mode
1921 0A6A 3227F0 sta counter1 ; clear event counter1
1922
1923 0A6D 2A2AF0 lhld user_PC
1924 0A70 23 inx h
1925 0A71 222AF0 shld user_PC
1926 0A74 CDBE0A call read_memory
1927 0A77 C9 ret
1928
1929 ; decrement key works with mode0 or mode1 display
1930
1931 0A78 3E00 decrement: mvi a,0
1932 0A7A 3226F0 sta entry_mode ; switch to data mode
1933 0A7D 2A2AF0 lhld user_PC
1934 0A80 2B dcx h
1935 0A81 222AF0 shld user_PC
1936 0A84 CDBE0A call read_memory
1937 0A87 C9 ret
1938
1939
1940 ; convert nibble 0-F to 8-bit seven segment code
1941 ; entry: A
1942 ; exit: A
1943
1944 0A88 to_seven_segment:
1945
1946 0A88 E60F ani 0fh ; get only low nibble as the index
1947 0A8A 218E1D lxi h,convert
1948 0A8D 5F mov e,a
1949 0A8E 1600 mvi d,0
1950 0A90 19 dad d
1951 0A91 7E mov a,m ; get code
1952 0A92 C9 ret
1953
1954 ; convert [HL] to display buffer 0-3
1955 ; for register display
1956 ; entry: HL
1957
1958 0A93 read_register:
1959 0A93 E5 push h
1960 0A94 7C mov a,h
1961 0A95 F5 push psw
1962 0A96 0F rrc
1963 0A97 0F rrc
1964 0A98 0F rrc
1965 0A99 0F rrc
1966 0A9A CD880A call to_seven_segment
1967 0A9D 3210F0 sta buffer
1968
1969 0AA0 F1 pop psw
1970 0AA1 CD880A call to_seven_segment
1971 0AA4 3211F0 sta buffer+1
1972
1973 0AA7 E1 pop h
1974
1975 0AA8 E5 push h
1976
Page 26 of 64
B8085.LST 29/12/2559 12:32
Page 27 of 64
B8085.LST 29/12/2559 12:32
Page 28 of 64
B8085.LST 29/12/2559 12:32
2129
2130 0B7D CDAE0C cold1: call scan
2131 0B80 15 dcr d
2132 0B81 C27D0B jnz cold1
2133
2134 0B84 23 inx h
2135 0B85 0D dcr c
2136 0B86 C27B0B jnz cold2
2137
2138 0B89 2B dcx h
2139
2140 0B8A 0E00 mvi c,0
2141 0B8C CDAE0C cold3: call scan
2142 0B8F 0D dcr c
2143 0B90 C28C0B jnz cold3
2144
2145 0B93 C9 ret
2146
2147 0B94 0000000000title: dfb 0,0,0,0,0,0,7fh,3fh,7fh,6dh,0,0
2148
2149
2150 ; display data read from memory pointed to by HL on LED
2151 ; entry: HL
2152 ;
2153
2154 0BA0 1605 demo: mvi d,5
2155
2156 0BA2 CDAE0C demo1_2: call scan
2157 0BA5 15 dcr d
2158 0BA6 C2A20B jnz demo1_2
2159 0BA9 23 inx h
2160 0BAA C9 ret
2161
2162
2163 ; convert position key to internal key code 0-F for data entry and 10-19H
2164 ; function keys
2165 ; entry: A = scan code
2166 ; exit: A = internal code
2167
2168 0BAB FE02 get_key_code: cpi 2
2169 0BAD C2B30B jnz code1
2170 0BB0 3E00 mvi a,0
2171 0BB2 C9 ret
2172
2173 0BB3 FE0A code1: cpi 0ah
2174 0BB5 C2BB0B jnz code2
2175 0BB8 3E01 mvi a,1
2176 0BBA C9 ret
2177
2178 0BBB FE12 code2: cpi 12h
2179 0BBD C2C30B jnz code3
2180 0BC0 3E02 mvi a,2
2181 0BC2 C9 ret
2182
2183 0BC3 FE1A code3: cpi 1ah
2184 0BC5 C2CB0B jnz code4
2185 0BC8 3E03 mvi a,3
2186 0BCA C9 ret
2187
2188 0BCB FE03 code4: cpi 3
2189 0BCD C2D30B jnz code5
2190 0BD0 3E04 mvi a,4
2191 0BD2 C9 ret
2192
2193 0BD3 FE0B code5: cpi 0bh
2194 0BD5 C2DB0B jnz code6
2195 0BD8 3E05 mvi a,5
2196 0BDA C9 ret
2197
2198 0BDB FE13 code6: cpi 13h
2199 0BDD C2E30B jnz code7
2200 0BE0 3E06 mvi a,6
2201 0BE2 C9 ret
2202
2203 0BE3 FE1B code7: cpi 1bh
2204 0BE5 C2EB0B jnz code8
Page 29 of 64
B8085.LST 29/12/2559 12:32
Page 30 of 64
B8085.LST 29/12/2559 12:32
Page 31 of 64
B8085.LST 29/12/2559 12:32
2357
2358 0CB1 0E06 mvi c,6 ; for 6-digit LED
2359 0CB3 1E00 mvi e,0 ; digit scan code appears at 4-to-10 decoder
2360 0CB5 1600 mvi d,0 ; key position
2361 0CB7 3EFF mvi a,0ffh ; put -1 to key
2362 0CB9 3221F0 sta key ; key = -1
2363
2364
2365 0CBC 7B scan1: mov a,e
2366 0CBD F6F0 ori 0f0h ; high nibble must be 1111
2367 0CBF D312 out system_port_c ; active digit first
2368 0CC1 7E mov a,m ; load a with [hl]
2369 0CC2 D311 out system_port_b ; then turn segment on
2370
2371 0CC4 060A mvi b,10 ; delay for transition process
2372 0CC6 05 wait1: dcr b
2373 0CC7 C2C60C jnz wait1
2374
2375 0CCA AF xra a
2376 0CCB D311 out system_port_b ; turn off segment
2377
2378
2379 0CCD DB10 in system_port_a ; read input port
2380
2381 0CCF 0608 mvi b,8 ; check all 8-row
2382 0CD1 1F shift_key: rar ; rotate right through carry
2383 0CD2 DADB0C jc next_key ; if carry = 1 then no key pressed
2384
2385 0CD5 F5 push psw
2386 0CD6 7A mov a,d
2387 0CD7 3221F0 sta key ; save key position
2388 0CDA F1 pop psw
2389
2390 0CDB next_key:
2391 0CDB 14 inr d ; next key position
2392
2393 0CDC 05 dcr b ; until 8-bit was shifted
2394 0CDD C2D10C jnz shift_key
2395
2396 ; mvi a,0 ; clear a
2397 ; out system_port_b ; turn off led
2398
2399 0CE0 1C inr e ; next digit scan code
2400 0CE1 23 inx h ; next location
2401
2402 0CE2 0D dcr c ; next column
2403 0CE3 C2BC0C jnz scan1
2404
2405 0CE6 CDED0C call serial_command
2406
2407 0CE9 D1 pop d
2408 0CEA C1 pop b
2409 0CEB E1 pop h
2410 0CEC C9 ret
2411
2412
2413
2414 ;----------- serial commands with 9600 8n1 terminal --------------------
2415 ; check if serial buffer has command
2416 ;
2417
2418 0CED serial_command:
2419 0CED 3A25F0 lda uart_found
2420 0CF0 FE00 cpi 0
2421 0CF2 CA310D jz skip_serial
2422
2423 0CF5 CD4512 call get_command
2424 0CF8 CD500D call download
2425 0CFB CD320D call prompting
2426 0CFE CDF112 call hex_dump
2427 0D01 CDEE11 call help
2428 0D04 CDC711 call quick_home
2429 0D07 CDDC11 call io_address
2430 0D0A CDAA11 call new_location
2431 0D0D CD2711 call edit_location
2432 0D10 CDDD10 call jump_to_user_pgm
Page 32 of 64
B8085.LST 29/12/2559 12:32
Page 33 of 64
B8085.LST 29/12/2559 12:32
2509
2510 0D8A 7D mov a,l
2511 0D8B CD2F12 call cout
2512
2513 0D8E 3E3D mvi a,"="
2514 0D90 CD2F12 call cout
2515 0D93 7D mov a,l
2516 0D94 CDCB12 call out2x
2517 0D97 CDE512 call space
2518 0D9A 2C inr l
2519 0D9B 0D dcr c
2520 0D9C C28A0D jnz ascii_print1
2521
2522 0D9F CD3A0D call send_prompt
2523 0DA2 C9 ret
2524
2525 0DA3 exit_ascii_print:
2526
2527 0DA3 C9 ret
2528
2529 ;------------------- set value to user registers ---------------------
2530 ; set value to user register AF, BC, DE, HL, SP, PC
2531
2532 0DA4 set_user_register:
2533
2534 0DA4 3A22F0 lda command
2535 0DA7 FE73 cpi "s"
2536 0DA9 C2B80E jnz exit_set_user
2537
2538 0DAC 210C1F lxi h, set_register_text
2539 0DAF CD5812 call put_str
2540
2541 0DB2 CD3B12 call cin
2542 0DB5 FE61 cpi "a"
2543 0DB7 C2E00D jnz set_user1
2544
2545 0DBA CDDA12 call new_line
2546 0DBD 21B01E lxi h,af_text
2547 0DC0 CD5812 call put_str
2548 0DC3 2A2CF0 lhld user_AF
2549 0DC6 7C mov a,h
2550 0DC7 CDCB12 call out2x
2551 0DCA 7D mov a,l
2552 0DCB CDCB12 call out2x
2553 0DCE CDEB12 call send_tab
2554 0DD1 CD9E13 call get_hex2
2555 0DD4 67 mov h,a
2556 0DD5 CD9E13 call get_hex2
2557 0DD8 6F mov l,a
2558 0DD9 222CF0 shld user_AF
2559
2560 0DDC CD3A0D call send_prompt
2561 0DDF C9 ret
2562
2563 0DE0 set_user1:
2564 0DE0 FE62 cpi "b"
2565 0DE2 C20B0E jnz set_user2
2566
2567 0DE5 CDDA12 call new_line
2568 0DE8 21B41E lxi h,bc_text
2569 0DEB CD5812 call put_str
2570 0DEE 2A2EF0 lhld user_BC
2571 0DF1 7C mov a,h
2572 0DF2 CDCB12 call out2x
2573 0DF5 7D mov a,l
2574 0DF6 CDCB12 call out2x
2575 0DF9 CDEB12 call send_tab
2576 0DFC CD9E13 call get_hex2
2577 0DFF 67 mov h,a
2578 0E00 CD9E13 call get_hex2
2579 0E03 6F mov l,a
2580 0E04 222EF0 shld user_BC
2581
2582 0E07 CD3A0D call send_prompt
2583 0E0A C9 ret
2584
Page 34 of 64
B8085.LST 29/12/2559 12:32
Page 35 of 64
B8085.LST 29/12/2559 12:32
Page 36 of 64
B8085.LST 29/12/2559 12:32
Page 37 of 64
B8085.LST 29/12/2559 12:32
Page 38 of 64
B8085.LST 29/12/2559 12:32
Page 39 of 64
B8085.LST 29/12/2559 12:32
Page 40 of 64
B8085.LST 29/12/2559 12:32
3041
3042 10BF CD3A0D call send_prompt
3043 10C2 C9 ret
3044
3045 10C3 exit_fill:
3046
3047 10C3 C9 ret
3048
3049
3050
3051
3052 ;---------------- monitor function list -------------------------------
3053
3054 10C4 monitor_function:
3055
3056 10C4 3A22F0 lda command
3057 10C7 FE6D cpi "m"
3058 10C9 C2DC10 jnz exit_monitor
3059
3060 10CC CDDA12 call new_line
3061 10CF 216C22 lxi h,monitor_text
3062 10D2 CD5812 call put_str
3063 10D5 CDDA12 call new_line
3064 10D8 CD3A0D call send_prompt
3065 10DB C9 ret
3066
3067 10DC exit_monitor:
3068 10DC C9 ret
3069
3070 ;----------------------- jump to user program --------------------
3071
3072 10DD 3A22F0 jump_to_user_pgm: lda command
3073 10E0 FE6A cpi "j"
3074 10E2 C22611 jnz exit_jump
3075
3076 10E5 21471E lxi h, jump_text1
3077 10E8 CD5812 call put_str
3078
3079 10EB 2A2AF0 lhld user_PC
3080 10EE 7C mov a,h
3081 10EF CDCB12 call out2x
3082 10F2 7D mov a,l
3083 10F3 CDCB12 call out2x
3084
3085 10F6 21591E lxi h,jump_text2
3086 10F9 CD5812 call put_str
3087
3088 10FC CD9E13 call get_hex2
3089
3090 10FF F5 push psw
3091
3092 1100 3A23F0 lda flag1
3093 1103 E601 ani 1
3094 1105 C21711 jnz skip_load_PC
3095
3096 1108 F1 pop psw
3097
3098 1109 67 mov h,a
3099 110A CD9E13 call get_hex2
3100 110D 6F mov l,a
3101 110E 222AF0 shld user_PC
3102 1111 CDDA12 call new_line
3103 1114 C39B09 jmp go
3104
3105 1117 skip_load_PC:
3106 1117 F1 pop psw
3107 1118 3A23F0 lda flag1
3108 111B E6FE ani 0feh
3109 111D 3223F0 sta flag1
3110 1120 CDDA12 call new_line
3111 1123 C39B09 jmp go
3112
3113 1126 C9 exit_jump: ret
3114
3115 ;------------ edit memory -----------------------------------------
3116
Page 41 of 64
B8085.LST 29/12/2559 12:32
3117
3118 1127 3A22F0 edit_location: lda command
3119 112A FE65 cpi "e"
3120 112C C2A911 jnz exit_edit
3121
3122 112F 21F61D lxi h, edit_text
3123 1132 CD5812 call put_str
3124 1135 CD8513 call get_hex1
3125 1138 67 mov h,a
3126 1139 CD8513 call get_hex1
3127 113C 6F mov l,a
3128 113D 223CF0 shld pointer ;user_PC
3129
3130 1140 210E1E lxi h, edit_text1
3131 1143 CD5812 call put_str
3132
3133 1146 21391E lxi h, edit_text2
3134 1149 CD5812 call put_str
3135
3136 114C CDDA12 edit1: call new_line
3137
3138 114F 2A3CF0 lhld pointer ;user_PC
3139 1152 7C mov a,h
3140 1153 CDCB12 call out2x
3141 1156 7D mov a,l
3142 1157 CDCB12 call out2x
3143 115A CDE512 call space
3144 115D CDE512 call space
3145 1160 3E5B mvi a,"["
3146 1162 CD2F12 call cout
3147 1165 7E mov a,m
3148 1166 CDCB12 call out2x
3149 1169 3E5D mvi a,"]"
3150 116B CD2F12 call cout
3151
3152 116E CDE512 call space
3153
3154 1171 CD9E13 call get_hex2
3155
3156 1174 F5 push psw
3157
3158 1175 3A23F0 lda flag1
3159 1178 E601 ani 1
3160 117A C29A11 jnz exit_edit1 ; Enter key?
3161
3162 117D 3A23F0 lda flag1
3163 1180 E602 ani 2
3164 1182 C28A11 jnz skip_edit1 ; SPACE key?
3165
3166 1185 F1 pop psw
3167
3168 1186 77 mov m,a
3169 1187 C39311 jmp skip_edit2
3170
3171 118A F1 skip_edit1: pop psw
3172
3173 118B 3A23F0 lda flag1
3174 118E E6FD ani 0fdh
3175 1190 3223F0 sta flag1
3176
3177 1193 skip_edit2:
3178 1193 23 inx h
3179 1194 223CF0 shld pointer ;user_PC
3180 1197 C34C11 jmp edit1
3181
3182 119A F1 exit_edit1: pop psw
3183
3184 119B 3A23F0 lda flag1
3185 119E E6FE ani 0feh
3186 11A0 3223F0 sta flag1
3187
3188 11A3 CDDA12 call new_line
3189 11A6 CD3A0D call send_prompt
3190
3191 11A9 C9 exit_edit: ret
3192
Page 42 of 64
B8085.LST 29/12/2559 12:32
3193
3194 11AA 3A22F0 new_location: lda command
3195 11AD FE6E cpi "n"
3196 11AF C2C611 jnz exit_new_location
3197 11B2 21E61D lxi h,new_text
3198 11B5 CD5812 call put_str
3199 11B8 CD8513 call get_hex1
3200 11BB 67 mov h,a
3201 11BC CD8513 call get_hex1
3202 11BF 6F mov l,a
3203 11C0 223CF0 shld pointer ; user_PC
3204 11C3 CD3A0D call send_prompt
3205
3206 11C6 exit_new_location:
3207
3208 11C6 C9 ret
3209
3210
3211
3212
3213 11C7 quick_home:
3214 11C7 3A22F0 lda command
3215 11CA FE71 cpi "q"
3216 11CC C2DB11 jnz exit_quick_home
3217
3218 11CF 210081 lxi h,home_address
3219 11D2 222AF0 shld user_PC
3220 11D5 223CF0 shld pointer
3221 11D8 CD3A0D call send_prompt
3222
3223 11DB exit_quick_home:
3224 11DB C9 ret
3225
3226 ; i/o address map
3227
3228 11DC 3A22F0 io_address: lda command
3229 11DF FE69 cpi "i"
3230 11E1 C2ED11 jnz exit_io
3231
3232 11E4 210321 lxi h,io_text
3233 11E7 CD5812 call put_str
3234 11EA CD3A0D call send_prompt
3235
3236 11ED C9 exit_io: ret
3237
3238
3239 ; help listing
3240
3241 11EE 3A22F0 help: lda command
3242 11F1 FE3F cpi "?"
3243 11F3 C20512 jnz exit_help
3244
3245 11F6 216F12 lxi h,prompt3
3246 11F9 CD6612 call alt_put_str
3247 11FC 216E1F lxi h,help_text1
3248 11FF CD5812 call put_str
3249 1202 CD3A0D call send_prompt
3250
3251 1205 C9 exit_help: ret
3252
3253
3254 ; initialize 16C550 uart to 9600 8n1 with 2MHz clock
3255 ; 2MHz/13 = 153846Hz
3256
3257 1206 init_uart:
3258
3259 1206 3E83 mvi a,83h
3260 1208 D343 out uart_lcr ; set DLAB bit to access divider
3261
3262 120A 3E0D mvi a,13
3263 120C D340 out uart_divisor_lsb
3264 120E 3E00 mvi a,0
3265 1210 D341 out uart_divisor_msb ; 2MHz/13 = 153846 Hz
3266 ; 153846Hz/16 = 9615Hz
3267 1212 3E07 mvi a,7
3268 1214 D342 out uart_fifo ; init fifo and clear all buffers
Page 43 of 64
B8085.LST 29/12/2559 12:32
Page 44 of 64
B8085.LST 29/12/2559 12:32
3345
3346 12AC 21581D send_prompt1: lxi h,prompt1
3347 12AF CD5812 call put_str
3348 12B2 C9 ret
3349
3350 12B3 216F12 send_prompt3: lxi h,prompt3
3351 12B6 CD6612 call alt_put_str
3352 12B9 C9 ret
3353
3354
3355
3356 12BA F5 out1x: push psw
3357 12BB E60F ani 0fh
3358 12BD C630 adi "0"
3359 12BF FE3A cpi 3Ah
3360 12C1 DAC612 jc out1x1
3361 12C4 C607 adi 7
3362
3363 12C6 CD2F12 out1x1: call cout
3364 12C9 F1 pop psw
3365 12CA C9 ret
3366
3367 12CB out2x:
3368 12CB 0F rrc
3369 12CC 0F rrc
3370 12CD 0F rrc
3371 12CE 0F rrc
3372 12CF CDBA12 call out1x
3373 12D2 07 rlc
3374 12D3 07 rlc
3375 12D4 07 rlc
3376 12D5 07 rlc
3377 12D6 CDBA12 call out1x
3378 12D9 C9 ret
3379
3380 ; new_line
3381
3382 12DA 3E0D new_line: mvi a,cr
3383 12DC CD2F12 call cout
3384 12DF 3E0A mvi a,lf
3385 12E1 CD2F12 call cout
3386 12E4 C9 ret
3387
3388 12E5 3E20 space: mvi a," "
3389 12E7 CD2F12 call cout
3390 12EA C9 ret
3391
3392 12EB 3E09 send_tab: mvi a,9
3393 12ED CD2F12 call cout
3394 12F0 C9 ret
3395
3396
3397
3398 12F1 3A22F0 hex_dump: lda command
3399 12F4 FE68 cpi "h"
3400 12F6 C25013 jnz exit_hex_dump
3401
3402 12F9 CDDA12 call new_line
3403
3404 12FC 0E08 mvi c,8 ; 8 lines
3405
3406 12FE C5 hex_dump2: push b
3407 12FF CDDA12 call new_line
3408 1302 2A3CF0 lhld pointer ;user_PC
3409 1305 7C mov a,h
3410 1306 CDCB12 call out2x
3411 1309 7D mov a,l
3412 130A CDCB12 call out2x
3413 130D CDE512 call space
3414
3415 1310 0E10 mvi c,16
3416
3417 1312 CDE512 hex_dump1: call space
3418 1315 7E mov a,m
3419 1316 CDCB12 call out2x
3420 1319 23 inx h
Page 45 of 64
B8085.LST 29/12/2559 12:32
Page 46 of 64
B8085.LST 29/12/2559 12:32
Page 47 of 64
B8085.LST 29/12/2559 12:32
Page 48 of 64
B8085.LST 29/12/2559 12:32
3649
3650 142D add_bcs
3651 142D F5 push psw
3652 142E 80 add b
3653 142F 47 mov b,a
3654 1430 F1 pop psw
3655 1431 endm
3656
3657 1431 FE01 cpi 1 ; end of record type is 01 ?
3658 1433 C25B14 jnz data_record ; jump if not 01
3659
3660 1436 CD3B12 wait_cr: call cin
3661 1439 FE0D cpi cr
3662 143B C23614 jnz wait_cr ; until end of record sending! with cr detection
3663
3664 143E 3EFF mvi a, 0ffh ; turn speaker off
3665 1440 D312 out system_port_c
3666 1442 AF xra a
3667 1443 D300 out 0 ; turn off GPIO
3668
3669 1445 CDB914 call print_bcd1
3670 1448 CDE512 call space
3671 144B 3A20F0 lda bcs
3672 144E CDC901 call pint8u
3673 1451 21991E lxi h,error_text
3674 1454 CD5812 call put_str
3675 1457 CDDA12 call new_line
3676
3677 145A C9 esc_quit: ret
3678
3679
3680 145B CD7213 data_record: call get_hex ; get data byte
3681 145E 77 mov m,a ; save to SRAM at [HL]
3682
3683 145F add_bcs
3684 145F F5 push psw
3685 1460 80 add b
3686 1461 47 mov b,a
3687 1462 F1 pop psw
3688 1463 endm
3689
3690 1463 CD8914 call inc_bcd1
3691
3692 ; ori 7fh
3693 ; out system_port_c ; make buzzer sound
3694
3695
3696 1466 23 inx h ; next location
3697
3698 1467 0D dcr c
3699 1468 C25B14 jnz data_record ; until c = 0
3700
3701 146B 78 mov a,b
3702 146C 2F cma
3703 146D 47 mov b,a
3704 146E 04 inr b ; compute two's complement
3705
3706 146F CD7213 call get_hex ; get check sum
3707
3708 1472 B8 cmp b
3709 1473 CA7D14 jz skip_error
3710
3711 1476 3A20F0 lda bcs
3712 1479 3C inr a
3713 147A 3220F0 sta bcs
3714
3715 147D skip_error:
3716 147D 3A3AF0 lda temp ; then shift into temp8
3717 1480 07 rlc
3718 1481 323AF0 sta temp
3719 1484 D300 out 0 ; send to GPIO
3720
3721 1486 C30314 jmp get_record ; back to next record
3722
3723
3724 ;---------------- increment BCD counter1 -------------------------
Page 49 of 64
B8085.LST 29/12/2559 12:32
3725
3726 1489 E5 inc_bcd1: push h
3727
3728 148A 2141F0 lxi h,bcd_counter1
3729 148D AF xra a
3730
3731 148E 7E mov a,m
3732 148F C601 adi 1
3733 1491 27 daa
3734 1492 77 mov m,a
3735 1493 23 inx h
3736
3737 1494 7E mov a,m
3738 1495 CE00 aci 0
3739 1497 27 daa
3740 1498 77 mov m,a
3741 1499 23 inx h
3742 149A 7E mov a,m
3743 149B CE00 aci 0
3744 149D 27 daa
3745 149E 77 mov m,a
3746
3747 149F E1 pop h
3748
3749 14A0 C9 ret
3750
3751 14A1 E5 inc_bcd2: push h
3752
3753 14A2 2144F0 lxi h,bcd_counter2
3754 14A5 AF xra a
3755
3756 14A6 7E mov a,m
3757 14A7 C601 adi 1
3758 14A9 27 daa
3759 14AA 77 mov m,a
3760 14AB 23 inx h
3761
3762 14AC 7E mov a,m
3763 14AD CE00 aci 0
3764 14AF 27 daa
3765 14B0 77 mov m,a
3766 14B1 23 inx h
3767 14B2 7E mov a,m
3768 14B3 CE00 aci 0
3769 14B5 27 daa
3770 14B6 77 mov m,a
3771
3772 14B7 E1 pop h
3773
3774 14B8 C9 ret
3775
3776
3777 14B9 print_bcd1:
3778 14B9 2143F0 lxi h,bcd_counter1+2
3779 14BC 7E mov a,m
3780 14BD CDCB12 call out2x
3781 14C0 2142F0 lxi h,bcd_counter1+1
3782 14C3 7E mov a,m
3783 14C4 CDCB12 call out2x
3784 14C7 2141F0 lxi h,bcd_counter1
3785 14CA 7E mov a,m
3786 14CB CDCB12 call out2x
3787 14CE 21E61E lxi h,byte_text
3788 14D1 CD5812 call put_str
3789 14D4 C9 ret
3790
3791 14D5 210000 clear_bcd1: lxi h,0
3792 14D8 2241F0 shld bcd_counter1
3793 14DB 2242F0 shld bcd_counter1+1
3794 14DE 2243F0 shld bcd_counter1+2
3795 14E1 C9 ret
3796
3797 14E2 print_bcd2:
3798 14E2 2146F0 lxi h,bcd_counter2+2
3799 14E5 7E mov a,m
3800 14E6 CDCB12 call out2x
Page 50 of 64
B8085.LST 29/12/2559 12:32
Page 51 of 64
B8085.LST 29/12/2559 12:32
Page 52 of 64
B8085.LST 29/12/2559 12:32
Page 53 of 64
B8085.LST 29/12/2559 12:32
Page 54 of 64
B8085.LST 29/12/2559 12:32
Page 55 of 64
B8085.LST 29/12/2559 12:32
Page 56 of 64
B8085.LST 29/12/2559 12:32
Page 57 of 64
B8085.LST 29/12/2559 12:32
Page 58 of 64
B8085.LST 29/12/2559 12:32
Page 59 of 64
B8085.LST 29/12/2559 12:32
4485
4486
4487 F03E break_address dfs 2 ; break address
4488 F040 break_opcode dfs 1 ; opcode that saved
4489
4490 F041 bcd_counter1 dfs 3 ; 6-digit BCD counter1
4491 F044 bcd_counter2 dfs 3 ; 6-digit BCD counter2
4492
4493 F047 line_buffer dfs 16 ; reserved for terminal printing
4494
4495
4496 F057 save_stack dfs 2 ; for saving system stack
4497 F059 system_stack dfs 32
4498 F079 user_stack dfs 32
4499
4500 0000 END
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
4501
Page 60 of 64
B8085.LST 29/12/2559 12:32
4501
4501 1075 AC_TEXT 0A01 ADDRESS_MODE 1EB0 AF_TEXT
4502 1266 ALT_PUT_STR 13C7 ASCII_0_9 0D72 ASCII_PRINT
4503 0D8A ASCII_PRINT1 1E5E ASCII_TEXT F041 BCD_COUNTER1
4504 F044 BCD_COUNTER2 F020 BCS 1EB4 BC_TEXT
4505 096F BEEP_CHK F024 BEEP_FLAG 0640 BEEP_ON
4506 019B BIN1 01A6 BIN2 0199 BIN2ASCII
4507 01B0 BIN3 01BB BIN4 08CA BREAK
4508 F03E BREAK_ADDRESS F040 BREAK_OPCODE F010 BUFFER
4509 0080 BUSY 0631 BUZZER 0642 BUZZER1
4510 1EE6 BYTE_TEXT 170B C0 1710 C1
4511 176C C10 1771 C11 1778 C12
4512 177F C13 1785 C14 178B C15
4513 1791 C16 1798 C17 179D C18
4514 17A2 C19 17A8 C1A 17AF C1B
4515 17B5 C1C 17BB C1D 17C1 C1E
4516 17C8 C1F 1717 C2 17CD C20
4517 17D2 C21 17D9 C22 17DF C23
4518 17E5 C24 17EB C25 17F1 C26
4519 17F8 C27 17FD C28 1802 C29
4520 1808 C2A 180E C2B 1814 C2C
4521 181A C2D 1820 C2E 1827 C2F
4522 171E C3 182C C30 1831 C31
4523 1839 C32 183E C33 1845 C34
4524 184B C35 1851 C36 1858 C37
4525 185D C38 1862 C39 1869 C3A
4526 186E C3B 1875 C3C 187B C3D
4527 1881 C3E 1888 C3F 1724 C4
4528 188D C40 1895 C41 189D C42
4529 18A5 C43 18AD C44 18B5 C45
4530 18BD C46 18C5 C47 18CD C48
4531 18D5 C49 18DD C4A 18E5 C4B
4532 18ED C4C 18F5 C4D 18FD C4E
4533 1905 C4F 172A C5 190D C50
4534 1915 C51 191D C52 1925 C53
4535 192D C54 1935 C55 193D C56
4536 1945 C57 194D C58 1955 C59
4537 195D C5A 1965 C5B 196D C5C
4538 1975 C5D 197D C5E 1985 C5F
4539 1730 C6 198D C60 1995 C61
4540 199D C62 19A5 C63 19AD C64
4541 19B5 C65 19BD C66 19C5 C67
4542 19CD C68 19D5 C69 19DD C6A
4543 19E5 C6B 19ED C6C 19F5 C6D
4544 19FD C6E 1A05 C6F 1737 C7
4545 1A0D C70 1A15 C71 1A1D C72
4546 1A25 C73 1A2D C74 1A35 C75
4547 1A3D C76 1A42 C77 1A4A C78
4548 1A52 C79 1A5A C7A 1A62 C7B
4549 1A6A C7C 1A72 C7D 1A7A C7E
4550 1A82 C7F 173C C8 1A8A C80
4551 1A90 C81 1A96 C82 1A9C C83
4552 1AA2 C84 1AA8 C85 1AAE C86
4553 1AB4 C87 1ABA C88 1AC0 C89
4554 1AC6 C8A 1ACC C8B 1AD2 C8C
4555 1AD8 C8D 1ADE C8E 1AE4 C8F
4556 1741 C9 1AEA C90 1AF0 C91
4557 1AF6 C92 1AFC C93 1B02 C94
4558 1B08 C95 1B0E C96 1B14 C97
4559 1B1A C98 1B20 C99 1B26 C9A
4560 1B2C C9B 1B32 C9C 1B38 C9D
4561 1B3E C9E 1B44 C9F 1747 CA
4562 1B4A CA0 1B50 CA1 1B56 CA2
4563 1B5C CA3 1B62 CA4 1B68 CA5
4564 1B6E CA6 1B74 CA7 1B7A CA8
4565 1B80 CA9 1B86 CAA 1B8C CAB
4566 1B92 CAC 1B98 CAD 1B9E CAE
4567 1BA4 CAF 174E CB 1BAA CB0
4568 1BB0 CB1 1BB6 CB2 1BBC CB3
4569 1BC2 CB4 1BC8 CB5 1BCE CB6
4570 1BD4 CB7 1BDA CB8 1BE0 CB9
4571 1BE6 CBA 1BEC CBB 1BF2 CBC
4572 1BF8 CBD 1BFE CBE 1C04 CBF
4573 1754 CC 1C0A CC0 1C0F CC1
4574 1C15 CC2 1C1A CC3 1C1F CC4
4575 1C24 CC5 1C2B CC6 1C30 CC7
Page 61 of 64
B8085.LST 29/12/2559 12:32
Page 62 of 64
B8085.LST 29/12/2559 12:32
Page 63 of 64
B8085.LST 29/12/2559 12:32
Page 64 of 64