NEC8201A TechRef
NEC8201A TechRef
First edition
NEC Corporation
Persona] Computer development division
--1 - .
.. ; ;a;. ~ "
IMPORTANT NOTICE
(1) All rights reserved. This manual is protected br
copyright. No part of this manual may be reproduced in
any form whatsoever without the written permission of the
copyright owner.
(2) All efforts have been make to ensure that the contents
of this manual are correct; however, should any errors be
detected, NEC would greatly appreceate being informed.
(3) NEC can assume no responsibility for errors· in this
manual or their consequences. The entire risk as to the
results of and performance of this manual is assumed by
you.
2 -
The numeric notation and rules in illustration
----------------- AXFFFF
I
I
I A
I
----------------- Upper
I
I
: File A
--------------~--
I
I
l File B
Lower
V
-----------------
---------------- AX0000
Fig 0.1 The •File A• is located
upper the •File e·.
c·=· means ·skipped •• )
- 3 -
And the address and the pointers written in the
illustration points· the just above the line.
APOINT ---> AX8000
·,I
================= <Skipped)
- 4 -
Authors:
Chapter 2 -- 4
Mr.Youshiro Hayashi
Software Engineer
Ap~lication Technology Department
Personal Computer Sales Promotion Division
Chapter 1,5 -- 8
Mr.Hiroaki Yokoyama
Software Engineer
Development department
Personal Computer Development Division
Chapter 9 -- 14
Mr.Akio Takagi
Software Engineer
Development Department
Personal Computer Development Division
Chapter 15
Mr.Moriharu Seki
Hardware Engineer
Development Department
Personal Computer Development Division
- 5 -
CHAPTER 1 INTRODUCTION
- 6 -
CHAPTER 6 DIRECTORY STRUCTURE
6.1 DIRECTORY CONFIGURATION PER ENTRY • • • • • • • • 76
- 7 -
8.7.1 MAKHOL • • • • • • • • • • • • • • • • • • • • • 126
8.7.2 LNKFIL • • • • • • • • • • • • • • • • • • • • • 129
8.7.3 MASOEL • • • • • • • • • • • • • • • • • • • • • 132
8.7.4 CHEAO • • • • • • • • • • • • • • • • • • • • • 133
a.a SAMPLE PROGRAM ••••••••••••••••• 134
8.8.1 Make A New 00 File CASCii File) • • • • • • • • 135
8.8.2 Save Data Into 00 File • • • • • • • • • • • • • 139
8.8.3 DELETE SOME DATA FROM 00 FILE • • • • • • • • • 142
8.8.4 DELETE 00 FILE • • • • • • • ~ • • • • • • • • • 144
s.a.s DELETE BA FILE • • • • • • • • • • • • • • • • • 146
8.8.6 MAKE NEW CO FILE • • • • • • • • • • • • • • • • 149
8.8.7 DELETE A CO FILE • • • • • • • • • • • . • • • • • 152
- 8 -
10.1.3 KEYIN ----- Read Keyboard Data • • • • • • • • 187
10.1.4- Keyboard Scanning • • • • • • • • • • • • • • • 188
10.2 SOFT WARE FOR KEYBOARD OPERATION. • • • • • • • • 189
10.2.1 How To Read The Keyboard • • • • • • • • • • • • 189
10.2.1.1 Sample Program Reading Keyboard. • • • • • • • 190
- 9 -
14.1.1 Physical Interface Of PC-8201A • • • • • • • • • 223
14.1.2 I/0 Port For PRINTER Interface • • • • • • • • • 223
14.1.2.1 Port A---- Data Out Put Port For Printer • • • 223
14.1.2.2 Port C ---- BUSY,SLCT Signal Read • • • • • • 224
14.1.2.3 SPCCSystem Control Port> --- STROBE Output
Po~t . • • • • • • • . • • . . . . • . . . . . 224
14.1.3 Basic Theory Of Writing A Data To Centronics •• 225
14.2 SOFTWARE SPECIFICATION • • • • • • • • • • • • • • 226
14.2.1 How To Write A Byte To Th~ Printer • • • • • • • 226
CHAPTER 15 HARDWARE
15.1 SYSTEM SLOT • • • • • • • • • • • • • • • • • • • 229
15.1.1 Assignment Of Signal • • • • • • • • • • • • • • 229
15.1.2 Explanation Of Pin • • • • • • • • • • • • • • • 232
15.1.2.1 Function Of Signal • • • • • • • • • • • • • • 232
15.1.3 DC Characteristics • • • • • • • • • • • • • • • 236
15.1.4 AC Characteristics • • • • • • • • • • • ~ • • • 237
15.2 MEMORY CONTROL CIRCUIT • • • • • • • • • • • • • • 240
15.3 I/0 ADDRESS • • • • • • • • • • • • • • • • • • • 245
15.3.1 Detail Information About I/0 • • • • • • • • • • 247
15.3.1.1 Reserve Area • • • • • ~ • • • • • • • • • • • 247
15.3.1.2 System Control • • • • • • • • • • • • • • • • 247
15.3.1.3 Bank Contro 1 • • • • • • · • • • • • • • • • • • 24.8
15.3.1.4 Bank Status • • • • • • • • • • • • • • • • • 249
15.3.1.5 PIO 81C55 Address • • • • • • • • • • • • • • 250
15.3.1.6 UART Data I /0 Port • • • • • • • • • • • • • • 254
15.3.1.7 UART Control Port • • • • • • • • • • • • • • 254
15.3.1.8 Keyboard Input • • • • • • • • • • • • • • • • 257
15.3.1.9 LCDC Address • • • • • • • .• • • • • • • • • • 257
- 10 -
CHAPTER 1
INTRODUCTION
- 11 -
INTRODUCTION
!
~- - 12 -
CHAPTER 2
MEMORY MAP
2.1 OVERVIEW
The PC-8201A has the following memory capacity. The
value specified with "Max" means the maximum capacity that is
greatly expanded by adding RAM/ROM chips or RAM cartridge.
ROM 32K byte~
C Max 64K bytes)
RAM 16K bytes
( Max 96 K: 32k bytes x 3 bank)
2 banks are equipped on Main
board of PC-8201A and 1 bank
is provided with RAM cartridge.
- 13 -
MEMORY MAP
- 14 -
f
I
MEMORY MAP
RAM I
I
(option):
*1
- 15 -
MEMORY MAP
- 16 -
MEMORY MAP
MSB 7 6 5 4 :· 3 2 1 0
5
.Bit not used
Bit 4 not used
Bit 3 High address
(AX8000 - AXFFFF) selection #2
Bit 2 High address
- 17 -
F'
'
MEMORY MAP
- 18 -
MEMORY MAP
MSB -----------------~-------------------------------
7 6 5 4 3 2 1 0
- 19 -
MEMORY MAP
- 20 -
MEMORY MAP
Interrupt routine
System work area
- 21 -
MEMORY MAP
AXF3s0· -------------~---I
· : User- machine I
- 22 -
MEMORY MAP
: .BA fi 1es
ar-ea : <-CTXTENDJ "XFA88
: Cur-r-ent BA
file l<-CTXTTABJ "XFASO
: .BA fi 1es I
I
ar-ea l<-CBOTTOMJ+1 "XF980+1
I <-CBOTTOMJ "XF980
- 23 -
MEMORY MAP
- 24 -
MEMORY MAP
2.4 SAMPLE
;
,• This sample will only change the bank of
; RAM addressed from AX8000 to AXFFFF.
; · You had better check that the bank which
; you want to switch really exists. And you
,• should save the next bank# at the
,• bookkeeping area, BANK •
,•
,• Entry None
,• Exit None
,• Bank will be changed
,•
; Bank rotation #1 -> #2 -> #3 -> #1 ~> •••
- 25 -
MEMORY MAP
EI : Enable interrupt
JMP SYSTEM : We must update book
•• keeping area •
: Jump AX0000 is the
END •• best way •
- 26 -
CHAPTER 3
HOU TO USE 2ND ROM
- 27 -
,_, ..
- 28 -
/
HOW TO USE 2ND ROM
MSB 7 6 5 4 3 2 1 0
- 29 -
~-
t
HO~ TO USE 2ND ROM
- 30 -
,,-
HOW TO USE 2ND ROM
3.1.3 UART
MSB 7 6 s 4 3 2 1 0
- 31 -
f HOY TO USE 2ND ROM
MSB
-----------------~-----------------------------
7 6 5 4 3 2 1 0
----------------------------------------------
Bit 7 Data #7
Bit 6 Data #6
Bit 5 Data *5
Bit 4 Data #4
Bit 3 Data #3
Bit 2 Data #2
Bit 1 Data *1
Bit 0 Data *0
- 32 -
,,,-
HOW TO USE 2ND ROM
PORT ADDRESS
MSB 7 6 5 4 3 2 1 0
- 33 -
HOW TO USE 2ND ROM
- 34 -
/
HOW TO USE 2ND ROM
When you would like to use 2nd ROM, you must write the
following information into the· 2nd ROM's special reserved
area. The special reserved area is located from AX0000 to
AX0047. These area will be used for 2nd ROM starting jump
instruction and IO code, and the file name of 2nd ROM. This
name is displayed like a one of the RAM files on Menu screen
by 1st ROM, ROM #0. The following figure is the explanation
about 2nd ROM special reserved area.
ADDRESS CODE
AX0000 JMP START ,• 2nd ROM start address
AX0003 • • • •
AX0024 RET ,• Non maskable interrupt
AX002C RET ,•
Barcode reader interrupt
AX0034 RET ,•UART interrupt
AX003C RET ,•Interval timer interrupt
AX003F ,•Reserved for RST interrupt
AX0040 DB 'A'
AX0041 DB '8' ,• IO code for 2nd ROM
AX0042 DB '2NDROM'; File name which displayed in
,• the menu
AX0048 START: ; 2nd ROM code
S P E C I AL R E S A R V E 0 ADORE S S
- 35 -
HOW TO USE 2ND ROM
3.3 THE METHOD TO USE 1ST ROM ENTRY FROM 2ND ROM
The following program is the sample which uses 1st ROM entry
points from 2nd ROM.
- 36 -
HOW TO USE 2ND ROM
3.3.1 Sample
,• TITLE Using 1st ROM entry from 2nd ROM
,•
,•
; This sample will enable to use 1st ROM entry from
; 2nd ROM.
; ·Some routines in 1st ROM might enable interrupts,
; so all interrupt
; hook table should be replaced with RET code.
; And restore them after done the 1st ROM calling •
,•
• Entry CENTRYJ:1st ROM entry address
',• Exit for return condition of 1st ROM
,•
; <<< SYSTEM define label >>>
BNKCRL EQU "X0A1 ; Bank control port
STATUS EQU "X0A0 ; Bank status port
; <<< Main routine>>>
ORG "X8000 ; This routine must be stay
,• "X8000-~XFFFF
ROM1ST: SHLD WORKH ; Save register HL
LXI H,RET2NO ; Return address from 1st ROM
PUSH H ; Push stack top
LHLD ENTRY ; Pick up 1st. ROM entry
; address
PUSH H ; Push stack top
LHLD WORKH ; Restore HL
PUSH PSW ; Save all register
DI ; Disable interrupt
IN STATUS ; Get current bank status
ANI "811111110 ; Switch 1st·ROM data set up
OUT BNKCRL ; Bank select
; Now "X0000-"X7FFF are
; 1s·t ROM
EI ; Enable.interrupt
POP PSW •
RET ;' Jump 1st ROM entry
.' <<<Return from 1st ROM>>>
RET2NO: PUSH PSW . Save a 11 register
IN STATUS '• Get current bank status
ORI "'B00000001 ' Switch 2nd ROM data set up
OUT BNKCRL •Bank select
'•Now "X0000-"X7FFF are
'•2nd ROM
POP PSW ' Pick up a 11 register
- 37 -
HOW TO USE 2NO ROM
RET ,•
; <<< SYSTEM WORK AREA>>>
ENTRY: ow AX0000 I 1st ROM entry address
WORKH: OW AX0000 ; HL register saving area
END
- 38 -
HOW TO USE 2ND ROM
1. INITIALIZE
This sequence sets up CSPJ(Stack Pointer),
power-on trap and other interrupt routines. Then it
copies the book-keeping area and system area. finally
some peripherals will be initialized by this routine.
2. RETURN TO MENU
3. POWER DOWN
- 39 -
t.
' HOW TO USE 2ND ROM
resuming address
starting address of
the ROM switching
routine
Contents of Pointers
<-- CS°TAKSVJ
4. POWER ON
- 40 -
HOW TO USE 2ND ROM
The following figure are the general 2nd ROM routine control
sequence.
: MENU mode
. ROM:
of 1st
:-Return
I
I
I
I
+-Turn off power switch:
...
:-Turn on
power switch
V
P O WE R 0 F F
Fig 3.2
- 41 -
rJ
r HOW TO USE 2ND ROM
1. Interrupt vector
If you do not want to use interrupt, all interrupt
table should be set with only ·RET• code. But I suggest
you that you had better use interval timer interrupt,
because of saving the battery poWer by using auto power
off function. The counter for this auto power off
function is counted by this interval timer interrupt. If
you do not use this function, the battery consumption may
be more larger than now.
2. Bank of RAM
Do not switch the ROM bank when PC, Program
Counter, points a routine in that ROM. You can guess the
reason and it's not so hard to imagine these bank
switching will cause the fatal problem for system. At the
worst case, the all files which you stored will be lost.
And also you should be careful in stack area, too.
- 42 -
HOW TO USE 2ND ROM
If you want to use 1st ROM entry from 2nd ROM, please
take care of the following point. The all routines rewrite
some work area sometimes. So, if you use 1st ROM entry from
2nd ROM witho~t understanding that routine's internal
specification, the system might be crashed. In addition,
interrupts and ·stack area are other important points. Refer
to 2.3 •The method to use 1st ROM Entry from 2nd ROM• and its
sample program.
- 43 -
HOU TO USE 2ND ROM -
3.6 SAMPLE
START:
JMP INIT : 2nd ROM start address
ORG "'X0024 ; Non maskable interrupt
: table
JMP POWER ; Power down trap
ORG ""X002C ; RST S.5
JMP BARCOO ; Barcode reader interrupt
: table
ORG "'X0034 ; RST 6.5
JMP UART ; UART interrupt table
ORG "'X003C ; RST 7.5
JMP TIMER ; Timer interrupt table
ORG "'X0040 ; IO code for 2nd ROM
OB 'AB' ; AB is ID code for 2nd ROM
DB '2NOROM' ; File name which
; displayed in the MENU
; <<< Initialization of 2nd ROM program>>>
!NIT: LHLO SAVSTK ; Set stack pointer
- 44 -
HOW TO USE 2ND ROM
SPHL ,•
CALL SETTRP ; Set hook for resume
; 2nd-ROM's program,
; and other routine into RAM.
CALL HINIT ; Hardware initialization
JMP MAIN ; Goto main routine
,•
; <<< Hardware initialize routine>>>
HINIT: RET ;
•
,•'
; <<< MAIN ROUTINE OF 2ND ROM>>>
,•
,•
MAIN: ; Main routine
; <<< Set up hook>>>
; Set up hook table for 2nd ROM
SETTRP: MVI A,"'800000001 • Select standard RAM
OUT BNKCRL '• Select!
LXI H,DTBL •' Set some codes into RAM
LXI D,PWHOK '•, for power on sequence
MVI B,TBLEND-DTBL •,
CALL COPY ,•
LXI H,TBLHOK ,• Return code table
.LXI D,FREE ,• Free area of RAM portion
LXI B,HOKE-TBLHOK • Set length
CALL COPY ,'•
RET ,•
,• CDEJ <- CHLJ
COPY: MOV A,M • Read CHLJ
STAX 0 •,' Save CDEJ
INX H •
INX D ',• Next address set
OCR B ,• Decrement counter
JNZ COPY ,• Loop until done
RET ,•
•
;' The following code will be copied in RAM
; portion for re-power on sequences
; these part are interrupt hook table •
,•
DTBL EQU $
MVI A,'"'800000001 ; These code will be
; copied into RAM
OUT BNKCRL ; Bank select!
45 -
~
v HOW TO USE 2ND ROM
; -
; The following code will be copied
; in RAM portion for return 1st ROM
,•
TBLHOK EQU $
RETSB: XRA A ; Clear A
OUT BNKCRL ; Select 1st ROM and
; standard RAM
JMP "'X0000 ; Return!
HOKE EQU $
- 46 -
HOW TO USE 2ND ROM
.
POP 0 ,•
POP H ,•
RET ; Resume old program
; <<< POWER DOWN TRAP >>>
POWER: PUSH PSW ,•
IN PWPORT ; Read power down port
ANA A ; Check
JM NTPWFL ; No power down
POP PSW ,•
DI ; Disable interrupt
PUSH H ; Save HL
PUSH 0 ; Save DE
PUSH 8 ; Save BC
PUSH PSW ; Save AF
LXI H,"X0000
DAO SP ; Now I know stack address
SHLO STAKSV ; Save stack
MVI A,0FFH ; Reset interva 1 ·timer
; counter
STA PWRINT ; Set up for next power on
IN STATUS ; Save current RAM bank status
; When power on resume,
remember
; this and select RAM bank.
MOV 8,A ; Save it
MVI A,"800000001 ; Select standard RAM
OUT BNKCRL ; Select!
MOV A,B ; Resave old status
STA BANKI-OTBL ,•
MVI A,"S00000001 ; Select RAM bank 1
OUT SNKCRL •,
MVI A,0 ; Set up to come back
; to 2nd ROM
STA BANK •
LXI H,AUTOIO ',•
SHLD ATIDSV ,•
IN PORTS ,•
ORI "800010000 ,•
OUT PORTS ,•
HLT ; Never 90 on
•,
NTPWFL: POP PSW
RET ,•
--47 -
HOW TO USE 2ND ROM
- 48 -
CHAPTER 4
HOW TO USE 2ND/3RD RAM
- 49 -
HOW TO USE 2ND/3RD RAM
·- STACK POINTER ,too.
In addition you must take care of the
- 50 -
HOW TO USE 2ND/3RD RAM
- 51 ~
HOU TO USE 2ND/3RD RAM
- 52 -
HOW TO USE 2ND/3RD RAM
AX0000 --------
Fig 4.2
(2) Change the Bank.
AXFFFF ---------
Your
I
code I
I
I
I
:<--
I •·
:<--
Fig 4.3
- 53 -
~···
- 54 -
HOW TO USE 2ND/3RD RAM
AX7FFF ----------
2nd
ROM
AX0000 ----------
Fig 4.4
AX0000 ----------
Fig 4.5
(3) S~itch again, and resume the previous processing.
55 -
3RD 'RAN
Bank number
Bank *1 (Standard RAM) :"X00
Bank *2 CRAM #2) :""X08
Bank 13 CRAM #3) :"X0C
- 56 -
HOW TO USE 2ND/3RD RAM
-
SLOW EQU 0 ; Low address (AX0000-AX7FFF)
; <<< Byte access routine>>>
BYTER: DI ; Disable interrupt
IN STATUS ; Read current bank status
PUSH PSW ; Save current bank status
IF SHIGH
ANI AB11110011 ; Clear high address of bank
; switch
ORA C ; Set new data of bank
ELSE
PUSH PSW ; Save curre"t bank
MOV A,C : Pick up new bank data
RAR ,•
RAR Shift 2 bit
MOV C,A Restore bank data
POP PSW Pick up current bank
ANI AB11111100 Clear low address of bank
switch
ORA C Set new data or bank
ENDIF
OUT BNKCRL ; Select new bank!
MOV B,M ; Read data from some bank
POP PSW ; Pick up before bank
OUT BNKCRL ; Select before bank
EI ; Enable interrupt
RET ,•
BYTEW: DI ; Disable interrupt
IN STATUS ; Read current bank status
PUSH PSW ; Save current bank status
IF SHIGH
ANI "'811110011 ; Clear high address·o-f bank
; switch
ORA C ; Set new data of bank
ELSE
PUSH PSW ; Save current bank
MCV A,C ; Pick up new bank data
RAR ,•
RAR ; Shift 2 bit
MOV C,A ; Pick up current bank
ANI "'B11111100 ; Clear low address of bank
; switch
ORA C ; Set new data of bank
ENOIF
OUT BNKCRL ; Bank switch!
- 57 -
HOW TO USE 2ND/3RD ~AM
- 58 -
HOW TO USE :3RD RAM
swit
IRA C ; Set new data of bank
:LSE
'USH PSW ; Save current bank
'OV A,C ; Pick up new bank data
AR •;•
AR Shift 2 bit
,ov C,A ; Restore bank data
'OP PSW ; Pick up current bank
,NI ""B11111100 ; Clear low address of bank
switch
)RA C ; Set new bank ~ata
~NOIF
,op B ; Pick up length
NEXTW:
MOV A,M ; Pick up data
STAX D ; Write data
INX H ,•
INX D ; Next position of data
DCX B ; Decrement counter
JNZ NEXTW ; Loop until done
LOA CURBNK ; Restore previous bank*
OUT BNKCRL ; Select previous bank
RET •
'
: <<< ~stem work area >>>
CURBNK: DB ... X00 ; ~urrent bank data
ENO
- 59 -
CHAPTERS
UNDERSTANDING THE RAM FILE CONCEPT
S.1 ·suMMARY
Usually, the RAM files are controlled by the ROM #0,
settled in ROM socket #0 at the shipment. There are many
rules to·use the RAM file. Unless you replace this ROM #0
with your own ROM, ROM #0 checks the RAM file organization and
pointers in the bookkeeping area sometimes, even if you don't
use BASIC, TEXT or TELCOM. (For instance, at Power on and
·sank• command in menu.) If you ignore the standard rules for
RAM file handling, ROM #0 will flush not only the files which
were made by your own application program ,but also the files
which were made by BASIC and TEXT in ROM #0. In order to save
your files from such kinds of accidents, please read following
chapters about .the RAM file handling and understand the
standard rules in PC-8201A.
The two situations were considered for this section.
Someone wants to handle RAM files with the machine language
subroutine in the BASIC m·ode. In this case, opening the file
will be done by a BASIC command, OPEN. And the file will be
closed and deleted by CLOSE and KILL command in BASIC. So the
machine language subroutine will make up the lacking
facilities in BASIC commands. For instance, Insert a data at
the middle of the opened file. In this case, you had better
care about a few pointers only. You needn't know the
directory structure.
But another person might try to make a his (or her)
original application program without using BASIC. He (or She)
might open a file, save data, append data, insert data, delete
data and erase a file with his ( or her) own application. In
this case, the name of the data file should be registered by
that application program. So that programmer need to.know the
Directory configuration and many parts of the pointers
playing.
~ 60 -
UNDERSTANDING THE RAM FILE CONCEPT
- 61 -
UNDERSTANDING THE RAM FILE CONCEPT
- 62 -
UNDERSTANDING THE RAM FILE CONCEPT
I A
I
Upper
I
'' I
I •
I 00 files I •
Lower
non-registered V
·BASIC program
or
9aved BASIC
program
•A.BA•
....
:Up,:,er
DO file!!
------------ I
I
- 63 -
UNDERSTANDING THE RAM FILE CONCEPT
- 64 -
UNDERSTANDING THE RAM FILE CONCEPT
• 4
- 65 -
r
5.2.2 BA File
The BA file is made in BASIC mode or made by LOAD
function in Menu mode·. There are two types of BA file in
PC-8201A. One-is a ·saved· BASIQ program, and another is
·non-registered· BASIC program. Sometimes the
·non-registered· is called the ·un-saved· BASIC program,
because ·un-saved· will make sense more than ·non-registered·
for a person who knows BASIC very well. The BASIC program
typed just after selecting BASIC mode in menu level, is called
·non-registered· "BASIC file, since the name of the program has
not been registered in the directory area yet. But after
executing ·sAvE· command in BASIC mode, that ·non-registered·
BASIC program becomes a ·saved· BASIC program. (In the point
of view, "SAVE• command in BASIC, the word ·un-saved". and
·saved" are suitable, I think.) The ·sAVE" command in BASIC
·register·s the file name and the starting address in the
directory area. Then the file name can be seen on the display
screen of the MENU or by •Files· command in the BASIC mode.
Meanwhile the ·LoAo• function in MENU can create a
"saved• BA file directly. The "LOAD• function can read a
BASIC program from the cassette, and can ·register" its name
in the directory area. So after "LOAO"ing in Menu, the
program name appears on the Menu screen.
ex. The flow diagram of making BASIC program
1. Select BASIC in menu level
2. Type BASIC program ·
10 PRINT •HELLO•
20 ENO
3. In this point, this BASIC program is called
·non-registered· program.
- 66 -
UNDERSTANDING THE RAM FILE CONCEPT
SAVE .TEST.BA •.
Just after doing SAVE, you can list the program with
LIST command. So you might be confused. But don't worry
about it. The following illustration will help you to
understand not only why LIST command just after SAVE command,
can list the "saved" program, but also why PC-8201A can have
many BASIC programs at a time, I hope.
- 67 -
UNDERSTANDING THE RAM FIL€ CONCEPT
"'XFFFF
-----------------
I
I
l 00 files
----------------- "'XUUUU
I I
I I
: saved BA file :
<- BOTTOM
C"'XF980)
Fig 5.2
2. Select BASIC in MENU and TYPE a BASIC program.
LIST shows you the non-registered BASIC program.
"'XFFFF
-----------------
: 00 files
---------------I AXYYYY
I
non-reg i!,tered:
BASIC program l
----------------- <-- ("XUUUU)
TXTTAB
saved BA
file
-----------------<--BOTTOM
Fig S.3
- 68 -
UNDERSTANDING THE RAM FILE CONCEPT
"'XFFFF
-----------------
00 files
----------------- "'XYYYY
non-registered:
BASIC program:
----------------- "'XUUUU
I I
I I
: Saved BA file:
-----------------<--BOTTOM
Fig 5.4
"'XFFFF
--------- ------
-------
I
I
: DO files
---~-------------
I I
AXYYYY
.1 I
non-registered:
program
----------------- <- TXTTAB
C"XUUUU>
: Saved BA files:
-----------------<--BOTTOM
Fig S.S
69 :-
UNDERSTANDING THE RAM FILE CONCEPT
..
""XFFFF
-----------------
DO files
----------------- ""XYYYY
TEST.BA
----------------- AX8000
_Fig 5.6
- 70 -
UNDERSTANDING THE RAM FILE CONCEPT
6. MENU and s·elect BASIC again or-· execute NEW commandin BASIC.
Now, LIST command lists nothing. Type new BASIC program,
again. LIST lists the pr-ogr-am that you typed just now •
I
• I ... XFFFF
-----------------
: 00 files
----------------- . . xzzzz
non-r-eg i ster-ed: .
pr-ogr-am ar-ea:
----------------- . . xuuuu
I
I
: Saved BA files:
-----------------<--BOTTOM
Fig 5.7
- -----71 -
UNDERSTANDING THE RAM FILE CONCEPT
7. •
LOAD •TEST.BA• in this case, or select •TEST.BA• directly in
MENU. LIST shows you the program, TEST.BA.
"'XFFFF
=================
: 00 files
----------------- "'XZZZZ
non-registered:
program
---------------
I
"'XYYYY
I
: TEST.BA
----------------- <- TXTTAB
C"'XUUUU)
: saved BA files:
-----------------<--BOTTOM
Figs.a
- 72 -
I
UNDERSTANDING THE RAM FILE CONCEPT
- 73 -
UNDERSTANDING THE RAM FILE CONCEPT
S.2.3 CO File
The CO file is made in BASIC with BSAVE command or can
be loaded and saved from the cassette tape in MENU mode. The
CO file is, sometimes, called ·machine language· file. It can
be executed directly like a command in menu level,when
·Execute· address was specified in BSAVE and the start address
is higher than the second parameter in the latest ·cLEAR•
command in BASIC. The default value is AXF380. So no CO file
can be executed directly from the menu level without CLEAR
command. The CO files are located above the DO files.
- 74 ~
UNDERSTANDING THE RAM FILE CONCEPT
.
5.2.4 The Order Of The Files In RAM
The order of these files in PC-8201A is fixed.
----------------- ~XFFFF
=================
CO file9
00 files
------------~----I
I
non-registered:
BASIC program :
: BA file9
----------------<-BOTTOM
Fig 5.9 the order of the files in RAM
- 75 -
.
CHAPTER 6
DIRECTORY STRUCTURE
- 76 -
DIRECTORY STRUCTURE
Dir-Y f 1 ag (1 byte)
Adcfiel d (2 bytes)
Fi 1e (8;bytes)
· Tota 1 11 bytes.
VPf address-field
- 77 -
DIRECTORY STRUCTURE
•• ·-1
78 -
~PTER 7
~GANIZATION
~ FILES
-~
- 79 -
RAM ORGANIZATION
AXFFFF ~---------------
:Bookkeeping I
I
""
I
Area I
----------------
-----------------
:Free area & I
I
MACHIN.CO
,.
I
DIARY.DO
I
I
MEMO.DO :Lower
GRAPH.BA
V
GAME.BA I
I
: <- BOTTOM
Fig 7.1.
- 80 -
RAM ORGANIZATION
• --
----------------- <---
A I
I MACHIN.CO
Moved
Upper
----------------- up
I
I DIARY.DO
-----------------
I
I MEMO.DO
----------------
I
I
<---
I
I GOLF.BA :<-- Added here
---------------- <---·
Lower I
I GRAPH.BA
Not
I
I
V
-----------------
I
I
Changed
I
.I
I
I GAME.BA
----------------- <---
Fig 7.2
- 81 -
RAM ORGANIZATION
,.
----------------- <--
I
I
Upper- l MACHIN.CO I
.'
----------------- Moved
up
: DIARY.DO
,.I
I
I
: MEMO.DO
<--
: ADORES.DO <-- Inserted
here
<---
Lower- GOLF.BA
-------------- Not
V changed
GRAPH.BA
: GAME.BA
-----------------<----
Fig 7.3
-·82 -
RAM ORGANIZATION
-4
----------------- <---
Upper : MACHIN.CO
: DIARY.DO
l MEMO.DO
Not changed
: ADORES.DO
I
I
Lower : GOLF.BA
V
: GRAPH.BA
l GAME.BA
----------------<----
Fig 7.4
- 83 -
RAM ORGANIZATION
ex.
Non-registered program is created just
under the ASCII file.
I A
I
: ASCII1.DO
Upper
I
I
non-registered:
program
----------------- Lower
: BASIC2.BA V
- 84 -
RAM ORGANIZATION
"'XF977 I
I
I I I
I I I
- 85 -
RAM ORGANIZATION
AXFFFF ----------------
'I
: Part III BIOS's data
AXFE40 ----------------
,'
l Part II LCD buffer
AXFBC0 -----------------
I' : BASIC's data
: Part I :. File handling data
Directory
AXF380 -----------------
Fig 7.7 Bookkeeping area
-~-
RAM ORGANIZATION
NOTE: ..
In this section, the articles about the
pointers and flags for BASIC are omitted, because this
document is written for the programmer who wants to
understand the many good features in PC-8201A, in
order to utilize this machine with 2nd ROM or user's
machine language program. Not written for the people
who wants to understand the internal specification of
PC-8201A's BASIC interpreter. So I think this
document is unfriendly for such kind of people.
Please refer to another manuals and textbook if you
need understand the BASIC interpreter.
- 87 -
RAM ORGANIZATION
FAE3 8INTAB 2
.FAES VARTAB 2
FAE7 ARYTAB 2
FAE9 STREND 2
FB63 FILTAB 2
FB67 NULBUF 2
7.2.1.1 FSIDSV
ADDRESS "'XF380
SIZE 2 bytes
Purpose First power on or not
If this FSIDSV is not identical' with FRSTID
("'X8A4D), the initialization routine falls into the
·coLD START• routine. In this case, the all data and
files in PC-8201A are cleared. The ·coLD START•
routine sets FRSTID here after done the
initialization. And no one may not change this ID
value.
7.2.1.2 HIMEM
ADDRESS "'XF384
SIZE 2 Byte
- 88 -
RAM ORGANIZATION
7.2.1.3 TXTTAB
ADDRESS AXF450
SIZE 2 bytes
PURPOSE Pointer to beginning of current
BA file
This pointer is valid in BASIC mode. In
another mode, TEXT or TELCOM mode, this pointer keeps
the latest value used in BASIC. In BASIC mode, the
• address of the first link pointer is stored here. And
this value won't be changed in BASIC mode unless
"LOAD" command is executed to load another BASIC
program, or "NEU" command. Almost internal routine
for BASIC interpreter refers to this pointer to know
the top of the current program. And this pointer 1s
very important when a BA file is deleted, too. You
cannot kill a BA file in BASIC mode when this TXTTAB
points the BA file. Refer to "How to delete a BA
file".
7.2.1.4 STKTOP
ADDRESS AXF459
SIZE 2 bytes
PURPOSE Top location to use for the stack
Initially set up by INIT routine in ROM #0
according to memory size to allow for 256 bytes of
string space. This value will be changed by a CLEAR
command with the first argument. The difference
between MEMSIZ and STKTOP means total string space.
- 89 -
,,-
.
RAM ORGANIZATION
7.2.1.5 OIRTBL
ADDRESS "XF84F
SIZE 33 bytes
PURPOSE directory for program in ROM
The names and pointers for the programs 1n ROM
are stored here. They are BASIC, TEXT and TELCOM. If
you don't want to use these standard programs, you can
use this area for your programs. This area will be
kept until •coLO START• is invoked. Refer to
·oirectory construction.·
7.2.1.6 NULOIR
ADDRESS . "XF870
SIZE 11 bytes
PURPOSE Directory for non-registered program
This area is kept for internal use. The
"non-registered program· that means the BASIC program,
just typed after selecting BASIC, uses this area for
pointing the starting address. There is a detail
explanation about the 'non-registered· program in the
previous section, 'BA file". And also, refer to
"Directory Construction".
- 90 -
RAM ORGANIZATION
7.2.1.7 SCRDIR •
ADDRESS "'XF87B
SIZE 11 bytes
PURPOSE Directory for SCRAP
The TEXT editor can do •sELECT•, •cur·, •copy•
and •pAsr•. This directory is used for this
·temporary file•, SCRAP, in TEXT. This file is
created when some characters are ·sELECT.ed and
•coPY.ed or •cur·. (Refer to PC-8201A user's guide
•sELECT•, •cur•, ·copy• and •PAST •• ) This file is kept
even if you exit from TEXT. And you can use it in
another programs, BASIC, TELCOM and so on. If you CUT
or COPY without SELECT, the starting address points
Control-Z. It means that the SCRAP files is empty.
Refer to •Do file• and •Directory Construction".
7.2.1.8 EDTOIR
ADDRESS "'XF886
S-IZE -11 byte!!
PURPOSE Directory for EDIT in BASIC
The EDIT command in BASIC makes a temporary DO
file. This slot is used for this file. Refer to •no
file· and ·Directory Construction·.
7.2.1.9 USRDIR
ADDRESS "XF891
SIZE 231 bytes
PURPOSE Directory for user's files (21 slots)
This area is used for BA files, DO files and
CO files which user makes. 21 files can be registered
- 91 -
/
RAM ORGANIZATION
•
here at most. The end of directory area is indicated
by ·--xFF·, ·Directory search stopper·. Refer to·
Directory Construction·.
7.2.1.10 BOTTOM
ADDRESS "'XF9B0
SIZE 2 bytes
PURPOSE Bottom address of RAM
The lowest available RAM address is saved
here. You can know how many RAM chips are installed
in this RAM bank easily by checking this pointer.
7.2.1.11 MEMSIZ
ADDRESS "'XFA9A
SIZE 2 bytes
7.2.1.12 FRETOP
ADORESS "'XFABF
SIZE 2 bytes
PURPOSE Top of the string free space
The highest address (closer to ... XFFFF) of the
- 92 -
- I
RAM ORGANIZATION
7.2.1.13 ASCTAB
7.2.1.14 BINTAB
7.2.1.15 VARTAB
- 93 -
RAM QR{;ANIZATION
7.2.1.16 ARYTA8
ADDRESS "XFAE7
SIZE 2 bytee
7.2.1;17 STREND
ADDRESS "XFAE9
SIZE 2 bytee
PURPOSE End of storage in use
This pointer keepe just above the address of
ARRAY .TABLE. The area between this pointer and the
stack pointer can be used as the FREE area.
Note:
When you ~ill use this FREE area, you have to consider
about the stack area. As the stack pointer points the
current bottom of the stack area, you had better about
120 bytes for the feature etack operation.
7.2.1.18 FILTAB
ADDRESS "XFB63
SIZE 2 bytes
PURPOSE Point to address of file data
This points to the starting address of the
- 94 -
/
RAM ORGANIZATION
7.2.1.19 NULBUF
ADDRESS AXFB67
SIZE 2 bytes
PURPOSE Points to address of file #0 buffer
The buffer for file #0 , sometimes called
NULBUF, is allocated just above the file data table,
pointed by FILTAB.
- 95 -
RAM ORGANIZATION
AXFFFF ----------------- I
I
Bookkeeping I
I
: <--- AXF380
----------------- -
User's machine
area
or
Device code
<-- HIMEM
FCB l·
I
C#1 -- #n) I
: <-:-- Address is
stored in FILTAB
Nul buffer
<Fi 1e #0 > I
I
: <-- NULBUF
I
I
: FCB address I
I
: <-- FILTAB
( 2 Bytes)
---------------
Used : <-- MEMSIZ
String area
---~-----------
Free : <-- FRETOP
String area
I
• I
I
I : <-- STKTOP
: Stack area I
I
I
I :<- Stack Pointer
I
I
Free area I
I
: <-- STRENO
I
I
: Array data
: <-- ARYTAB
- 96
/
.I
I
: Simple I
I
l Variables I
I
·,
I l <-- VARTAB.
-----------------
: CO fi 1es I
I
l <-- BINTAB
,-----------------
l DO fi 1es I
I
l <-- ASCTAB
I
I
BA files I
I
.I
l<--
I
TXTTAB
I
'
:<-- BOTTOM
- 97 -
RAM ORGANIZATION
ADDRESS
- 98 -
RAM ORGANIZATION
(1) FL.MOO
Address: FCBOFF+0
Size: 1 byte
- 99 -
RAM ORGANIZATION
(2) FL.FCA
ADDRESS: FCSOFF + 1
SIZE: 1 byte
The· first cluster allocated to file. In RAM file
handling, this parameter has no meaning.
C3) FL.LCA
ADDRESS: FCBOFF + 2
SIZE: 1 byte
The last cluster accessed. For RAM file open, this
and next byte is used for the storage of the Directory
address of·that RAM file.
<4> FL.LSA
ADDRESS FCBOFF + 3
SIZE 1 byte
The last sector accessed. For RAM file open, this and
previous byte is used for the storage of the Directory
address of that RAM file.
CS) FL.OSK
ADDRESS: FCBOFF + 4
SIZE 1 byte
Disk* of the file or Device IO. The table listed
below is the Device IO table in PC-8201A.
Device name IO number
LCD ""XFF
C CRT ""XFE )
CAS ""XFD
COM ""XFC
< WANO ""XFB )
LPT ""XFA
RAM ""XF9
CRT and WANO is option I/0.
C6> FL.SLB
- 100 -
RAM ORGANIZATION
ADDRESS: FCBOFF + 5
SIZE: 1 byte
Size of last buffer read.
-.
(7) FL.BPS
ADDRESS: FCBOFF + 6
SIZE: 1 byte
The position in buffer for both PRINT and INPUT with
the file One of the most important parameter in
FCB. *·
(8) FL.FLG
ADDRESS: FCBOFF + 7
SIZE
This byte and next byte are used for the offset
address of the RAM file which is opened now. For
example, in the •INPUT• mode file, this offset address
is advanced by 256 bytes when the block-read command
reads 256 bytes from the file into the buffer in FCB.
So in reading or writing to the RAM file (00 file),
the starting address and this offset show the next
byte should be read or written.
(9) FL.OPS
ADDRESS: FCBOFF + 8
SIZE: 1 byte
High byte of the offset address for RAM file. Refer
to FL.FLG.
C10>FL.BUF
ADDRESS: FCBOFF + 9
S~ZE: 256 bytes
Buffer for the file.
- 101 -
CHAPTER 8
RAM FILE HANDLING
- 102 -
RAM FILE HANDLING
- 103 -
RAM FILE HANDLING
- 104 -
RAM FILE HANDLING
.
changed when you make a new BASIC file. (BASIC file 1s
created under the lowest DO file. Refer to "Memory Map
about RAM files" ) And when some data are inserted in
"A.DO", a DO file, the starting address of the DO file and
CO file located above "A.DO" should be changed. Refer to
"LNKFIL" in the "Useful Routines For RAM file Handfing in
ROM #0". You can get the know-how to make up- the starting
address in the directory area. ·
- 105 -
RAM FILE HANDLING
- 106 -
F'
l RAM FILE HANDLING
........
and directory flag yet, please read that section and make up
them first.
Usually the new DO file is created just above the
ASCTAB, the lowest address of the-:existed DO files. Refer to
the figure in the ·what is RAM file· to make sure your image.
If you go with the standard rule which Menu, BASIC and others
in ROM #0 is used, you can copy the contents of the ASCTAB-1
as the starting address of the new files. Then the
registration of the new DO file is done completely. The
reason why we have to use ASCTAB-1 instead of ASCTAB is to
maintain the order of the files. The LNKFIL, to make up
starting address in directory area, searches the file name
from top to end and links the starting address of each file.
For LNKFIL searches the directory from younger address to
older address and older file has younger address, the order of
the DO file will be swapped if you use ASCTAB instead of
ASCTAB-1. Refer to •LNKFIL• in •useful Routine for RAM file
handling in ROM #0".
But you have to do two more steps for that new DO
file. One is to insert the end of file flag at the bottom of
that new DO file. Another one is, as you know, to make up the
starting address of other files in the directory area.
There is no DO file whose size is zero, because the
final character of the DO fiie should be AZ (AX1A, 26 in
Decimal). In other words, the AZ indicates the End of File of
the DO file. So the DO file will spend one byte at least. If
you only want to open the new DO file without any data, you
have to insert a AZ at the starting address. If you want to
save some data now, you have to append a AZ at the end of the
data. Never forget to insert a AZ at the end of the file.
Otherwise, next RAM file operation might destroy the all RAM
files.
In order to make a room for the new file, a convenient
routine is in the ROM #0. Its name is MAKHOL, MAKe HOLe.
This routine makes a hole from the specified point and whose
size can be decided by the contents in CBCJ register. Refer
to ·MAKHOL• in ·useful Routine For RAM file handling in ROM
#0·. The concept of the MAKHOL is shown briefly in that
section.
- 107 -
RAM FILE HANDLING
........
of that routine is shown in the ·useful Routine For RAM file
handling in ROM #0·. You can get information to make your own
LNKFIL routine in it, too.
If you succeed to insert 6 AZ and to make up the
etarting address field in the directory, the opening a new 00
file ha~ been done successfully. You can save the data to the
new file with using MAKHOL and LNKFIL. Refer to another
section to know how to Append, Insert, and Delete data. The
sample program in the following section will show you how to
make a new file and save data.
Cf. How to make a new DO file
1. Find a free slot in the user's directory. If you
cannot find a free slot in the directory area, you
have to give up to make a new DO file. Or if you
find the same name in the directory, delete that
file or abandon to continue.
2. Register the file name and directory· flag at the
free slot.
3. Get the ASCTAB-1 and·save it in the address field
of the elot.
4. Try to make a one byte hole at the address where
ASCTAB pointed.
5. If you fail to make a hole, clear the directory
flag which you registered at (2).
6. If you succeed to make a hole, insert a AZ at that
point.
7. Make up the pointers and starting address in the
directory area.
8. Tha~'s all. The new 00 file has been created
without fail.
- 108. -
f RAM FILE HANDLING
- 109 -
RAM FILE HANDLING
- 110 -
RAM FILE HANDLING
Heading of CO file
START ADDRESS 2 bytes
LENGTH 2 bytes
- 111 - -
RAM FILE HANDLING
- 112 -
RAM FILE HANDLING
- 113 -
RAM FILE HANDLING
- 114 -
RAM FILE HANDLING
4. Load it again.
LOAD .TEsr·
5. Try to kill it
KILL •TEST.BA• (Return>
?FC Error
Ok
6. This result show you what I want to say. SASIC's
KILL command checks the current TXTTAB and avoid
to kill himself. Your machine language routine
should do same check before killing a BASIC file.
- 115 -
RAM FILE HANDLING
~ 116 -
:Restore the result of the comparison between the
:starting address of the file and TXTTAB. If
· ;TXTTAB is greater than the starting addres, adjust
.: it.
. ..
Clear the directory flag of the file which you
!deleted.
: That' e a 11
To DELETE A CO File
'!
- 117 -
RAM FILE HANDLING
..
ex. Delete a CO file it9elf
----------------- AXFFFF
-----------------
I
I
: machine prog I
I
:<-- BLOAO
or
Select
=================
: CO2 file
in
-----·------------ MENU
CO fi 1e :-:
BINTAB->: I
I
I
I
00 file9 I
I
--------------
BA file9 .,
I
AX8000 ---------~-----
Fig 8.1
- 118 -
,-
/
:hine prog
---------------- AXFFFF
=================
machine prog
<-- PC
<- STRENO
=================
CO2 file <- "XAAAA
CO file
<- BINTAB
00 files
I
~ I
BA files
:000 -----------------
Fig 8.2
119
r
~··
3. Delete the CO·file and move the data between the STRENO and
"XAAAA.
----------------- AXFFFF
=================
I I
I I
: machine prog :<- PC
<- STRENO
-----------------
I
I
: CO2 file
<- BINTAB
I.
I
00 files
BA files
AX8000 ----------~~--
Fig 8.3
NOTE: PC means Program Counter
- 120 -
RAM FILE HANDLING
- 121 -
RAM FILE HANDLING
- 122 -
RAM FILE HANDLING
- 123 -
...
RAM FILE HANDLING
- 124 -
RAM FILE HANDLING
- 125 -
l
RAM FILE HANDLING
8.7.1 MAKHOL
Make a hole
ADDRESS AX6C0A C AO66012, 27658 >
ENTRY CHLJ points where you want to make a hole
CBCJ size of the hole
EXIT CHLJ and CBCJ are preserved
Carry is set if out of memory
In order to know the free area's size, STRENO
is the best pointer. The amount of the STRENO and
your file's size, in this case, should be less than
CSPJ 120. (The ·sp• means Stack Pointer, as you
know. ) The 120 bytes are reserved for Stack's
operation. If there is a enough room, MAKHOL shifts
the all data between the specified address and STRENO.
If not,· MAKHOL returns with carry set. The flow of
MAKHOL is listed at next page.
- 126 -
RAM FILE HANDLING
/------------¥
MAKHOL
¥------------/
; STRENO + Required bytes
< SP - Stack area ( 120 bytes) :
I
I No
: -----.----> Out of Memory
-------------------------------------
Change the pointers
**
ASCTAB, BINTAB, VARTAB, ARYTAB
and STREND
-----------------~-------------------
-/-----------¥
RETURN
¥-----------/
Fig 8.4
- 127 -
RAM FILE HANDLING
- 128 -
RAM FILE HANDLING
8.7.2 LNKFIL
- 129 -
RAM FILE HANDLING
/---------------¥
LNKFIL
¥---------------/
Mark the all valid directory:
: flag (turn 0 bit of all
: valid directory flag)
:<------------------------------·
Search the lowest link pointer:
: in the marked files in
: directory area
---------------------------
Save the saved link pointer
at this marked files link
pointer field ·
---------------~-----------------
I
I
:
(A) (8)
- 130
RAM FILE HANDLING
CA) (8)
l End of directory
/---------------¥
ENO
¥---------~----/
Fig 8.5
- 131 -
RAM FILE HANDLING
8.7.3 MASOEL
- 132 -
RAM FILE HANDLING ,
8.7.4 CHEAD
...
Search for the end of this BASIC program
ADDRESS AX718 C 34300, 1816)
- 133 -
RAM FILE HANDLING
--~
8.8 SAMPLE PROGRAM
- 134 -
RAM FILE HANDLING
- 135 -
RAM FILE HANDLING
; directory
XCHG ;COEJ name address
LXI H,NAME ;name of the file which
; we want to make
MVI B,NAMLEN;Set name ~ength
CMPNAM:
LOAX 0 ;Get directory's name
CPI M ;Compare with our file
JNZ NOTSAM ;Jump if not same
INX H ;Advance the pointers
INX 0
OCR B
JNZ CMPNAM ;compare next
,•
; Same file name is found
,•
POP H ;Top of the slot address
MOV A,M ;Get directory flag
ANI AB00000010
;Pick up OPEN BIT
ORA A ;File already opened?
JNZ FILAOP ;Jump if file already opened
,•
; Find same name and not opened file
,•
SHLO SLTAOR ;Save it
-CALL OELFIL ;Delete this file
· JMP FINONM ;go to Registration
,•
; Find free slot
,•
XCHG ;COEJ free slot address
LHLO SLTAOR ;Get free slo.t address
; that has been found
MOV A,H ,•
ORA L ;Never found?
JNZ EVERFN ;jump if already found
XCHG ;This is the fir-st time
SHLO SLTAOR
JMP SEANAM ;Check next slot
,•
EVERFN:
XCHG ;Don't renew the address
JMP SEANAM ,•
; To search the directory is done
,•
LHLO SLTAOR ;Is there good free slot?
MOV A,H
ORA L ,•
- 136 -
RAM FILE HANDLING.
4
- 137 -
RAM FILE HANDLING
- 138 -
RAM FILE HANDLING
•
;' Save data into DO file
•
;' ENTRY: CHLJ points directory of the file
,• CDEJ address of source data
• CBCJ length of data
'•
'
MAKHOL EQU AX6C0A ;Make a room for data
LNKFIL EQU AX233A ;Make up starting address
ENDFIL EQU AX1A ;End of DO file
•t
•
'
SAVDAT:
.
'•; Check the directory flag of the file
•
t
MOV A,M ;Get directory flag
PUSH B ;Save data length
MOV B,A ;Save directory flag
ANI Ae11000000·
;Pick up mode bits
CPI AB11000000
;DO file?
JNZ BADFIL ;Jump if not DO file
MOV A,B ;Get flag again
ANI AB00000010
·;Pickup OPEN bit
ORA A ;File already opened?
JNZ FILAOP ;Jump if file already opened
MOV A,B ;Get directory flag
ORI 000000108
;Say this file is opened
MOV M,A
•
';Search end of file
•
' POP B ;Recover DATA length
PUSH H ;Save Top of directory address
PUSH B ;Save DATA length
INX H ;Advance to Address field
MOV A,M ;get address in CHLJ
INX H
- 139 -
I
RAM FILE HANDLING
MOV H,M
MOV L,A ;Set top of the file
,•
SEALOP:
MOV A,M ;Get Data
CPI ENDFIL ;End of file?
JZ FNDEOF ;Jump if end of file
INX H
JMP SEALOP ;Search next
,•
;MAKE A ROOM FOR DATA
,•
POP B ;Recover data lengtH
PUSH D ;Save source address
CALL MAKHOL ;Dig a hole for data
JC MEMFUL ;jump if error detected
POP D ;Recover source address
,•
;copy data in to the hole
,•
COPYLP:
LDAX D ;Get source data
MOV M,A ;save it in~o file
INX H
INX D
DCX B ;Decrement DATA length
MOV A,B ,•
ORA C ;End of data?
JNZ COPYLP ;Continue till end of data
,•
;Make up starting address of other files in
; directory area
,•
CALL LNKFIL
•,
;Turn off the opened bit in directory flag
•,
POP H ;Recover directory address
MOV A,M ;Get directory flag
ANI ~B11111101
;Turn off the flag
MOV M,A ;Renew the flag
RET
,•
;External routines
,•
BADFIL:
; Bad file mode
- 140 -
RAM FILE HANDLING
FILAOP:
.
; File already o~ened
MEMFUL:
; Memory full error..
ENO
- 141 -
,
..
RAM FILE HANDLING
...
Delete some data from DO file
ENTRY: CHLJ Top of the direetory address
CDEJ Offset address of Top data
should be deleted
; CBCJ Length of data should be deleted
,•
MASOEL EQU AX6C3C ;Remove some data
LNKFIL EQU AX233A ;Make up starting address
,•
OELDAT:
,•
;Check directory flag
'• MOV A,M ;Get direetory flag of
; the file
ANI AB11000000
;Pick up VALID bit and ASCII
; bit
CPI AB11000000
;Valid 00 file?
JNZ BADFIL ;Jump if bad file
MOV A,M ;Get direetory flag again
ANI A800000010
;Pick up OPEN bit
ORA A ;Already opened?
JNZ FILAOP ;jump if the file already opened
MOV A,M ;Set opened bit
ORI AB00000010
MOV M,A ;Say, the file is opened
,•
PUSH H ;Save directory address
INX H ;Get start address of the file
MOV A,M •
'
INX H
MOV H,M ,•
MOV L,A ;CHLJ start address of the file
;
DAD D ;Absolute address of the data
; ~hich should be removed
; Delete data
,• CHLJ TOP of the data, CBCJ data length
•,
- 142 -
RAM FILE HANDLING
- 143 -
RAM FILE HANDLING
•
•
; Delete 00 file
•,
; ENTRY.: CHLJ points the directory of the file
,•
MASOEL EQU AX6C3C ;remove data
LNKFIL EQU AX233A ;adjust address field in
; directory area
DELOO:
MOV A,M ;Get directory flag
ANI AB11000000
;Pick up VALID and ASCII bit
CPI "811000000
;Valid do file
JNZ BADFIL ;jump if bad file mode
MOV A,M ;get directory flag
ANI AB00000010
;pick up opened bit
ORA A ;Already opened?
JNZ FILAOP ;jump if already opened
,•
; Calculate the size of the file
•
• PUSH H ;save directory address
INX H ;get start address
MOV A,M ,•
INX H
MOV H,M ;CHLJ start address
MOV L,A
;
PUSH H ;Save start address
SEALOP:
MOV A,M ;end of file?
CPI EOFFIL ,•
INX H ;next field
JNZ SEALOP ;continue till EOF
,•
POP 0 ;Restore start address
MOV A,L ;CHLJ-CDEJ= length
SUB E:
MOV C,A
MOV A,H ,•
S88 0
MOV 8,A ;Set length in CBCJ
- 144 -
tlAN~LING
- 145 -
RAM FILE HANDLING
--·-s -•
8.8.S DELETE SA FILE
•
'
;Delete BASIC file - . . -l
•
;' Asswme that this subroutine i!s used with BASIC
I
• main program
,'•
; ENTRY: CHLJ directory address of the file
,•
MASOEL EQU "'X6C3C ; remove data from file
LNKFIL EQU "'X233A ; make up starting address
CHEAO EQU "X0718; search end of BASIC file
TXTTAB EQU "'XF45O ; lowest address of current
; BASIC program
A$CTAB EQU "XFAE1 ·; Lowest address of 00 files
,•
,•
OELBAS:
MOV A,M ;Get directory flag
c·p1 "B10000000
;BASIC file?
JNZ BAOFIL ;Jump if not BASIC
; file
XCHG ;COEJ directory address
LHLO TXTTAB ;get lowest address of the
;current BASIC program
; (Ue are executing the
; BASIC program with this
; machine subroutine.)
XCHG ;COEJ TXTTAB CHLJ Directory
; address
PUSH H ;save directory address
INX H ;advance to address field
MOV A,M ;get start address of BA file
; which we want to delete
INX H
MOV H,M
MOV L,A ;CHLJ start address
MOV A,H ;compare to TXTTAB
SUB D
JNZ NOSAM ;jump if not same
MOV A,L ;compare lower address
SUB E ,•
JNZ NOSAM ;jump if not same
146 -
RAM FILE HANDLING
- 147 -
RAM FILE HANDLING
; EXTERNAL ROUTINE
•
'
FCERR:
; Illegal function call error
••
BAOFIL:
; Bad file mode error
ENO
- 148 -
RAM FILE HANDLING
-.
; MAKE NEW CO FILE
,•
; ENTRY: CSTRADRJ start address of CO file data
• CLENGTHJ length of data
'•• CEXECADJ execution address
•
•• CHLJ directory address for this CO file
•'
'
MAKHOL EQU "'X6C0A ;make a room·
LNKFIL EQU "'X233A ;make up directory address field
HEADLN EQU 6 ;Header length of CO file
BINTAB EQU "'XFAE3 ; 1owest address of existed co
• files
VARTAS EQU "'XFAES '; 1owest address of Variable
• table
'
MAKECO:
,•
; Refer HOU TO MAKE NEU DO FILE to know how to find
; the directory address for new files •
•
-'
MVI A,""B10100000
;Set direc~ory flag as CO file
MOV M,A ;register it
PUSH H ;save directory address
LHLD LENGTH ;get file l~ngth of new CO
LXI B,HEAOLN;Set header length
DAO B ;Get total length of new CO file
MOV B,H ;Set length in CBCJ
MOV C,L ;
LHLD BINTAB· ;CHLJ lowest address of existed
;CO files
PUSH H ;Save current BINTAB
LHLD VARTAB ;CHLJ just above highest CO file
CALL MAKHOL ;Try to make a hole
JC MEMFUL ;jump if there is no enough room
XCHG ;Save the top address of hole
POP H ;recover BINTAB
SHLD BINTAB ;Adjust BINTAB
XCHG ;restore TOP of hole
- 149 -
RAM FILE HANDLING
POP D
.. -·
;CDEJ directory address
INX 0 ;advance to address field
MOV A,L ;Set start address
STAX
INX
0
D
..
-
MOV A,H •,
STAX D
,•
; To register the file name in directory is omitted •
,•
XCHG ;COEJ top of the vacant room
MVI B,HEAOLN;Set header length
LXI H,STARAO;offset of header data
COPYHD:
MOV A,M ;Get header data
STAX 0 ;store'it in file
INX 0
INX H
OCR B ;end of header data?
JNZ COPYHD :copy 3 address as header
,•
LHLD LENGTH ;Get data length
MOV B,H , ;set length in• CBCJ
MOV C,!:ir-
LHLD STARAD ;CDEJ destination address
;CHLJ source address
COPYLP:
MOV A,M ;copy contents of file
STAX 0
INX 0
INX H
DCX B ;count down
MOV A,B ;end of data?
ORA C
JNZ COPYLP ;continue till end of data
,•
CALL LNKFIL ;make up all start address of
;other files in directory area
RET
•
'• ERROR HANDLING ROUTINE
'•
'
MEMFUL:
• memory ful 1 er-r-or-
'
,•
,• DATA AREA
,•
STARAO: OS 2
LENGTH: OS 2
- 150 -
RAM FILE HANDLING
-~
EXECAO: OS 2
ENO
- 151 -
RAM FILE HANDLING
.~
•
;' DELETE A CO FILE
;
; ENTRY: CHLJ addres of its directory
•
'
MASDEL EQU AX6C3C ;remove data
LNKFIL EQU AX233A ;make up starting address
;in the directory
BINTAB EQU "XFAE3 ; 1owest address of CO files
HEADLN EQU 6 ; 1ength of the header in CO
• file
'
DELCO:
MOV A,M ;Get DIRECTORY flag
CPI "'810100000
;CO file?
JNZ BAOFIL ;Jump if BAO file mode
XRA A •
MOV M,A '
;Clear directory flag
INX H ;Advance to address field
MOV A,M ;Get start address of the CO
;file
INX H
MOV H,M ;CHLJ start address
MOV L,A
PUSH H ;s~ve start address
INX H ;Get file length in the
; header
INX H
MOV C,M ;get length in CBCJ
INX H •
MOV B,M '
LXI H,HEADLN;add header length
DAO B ;
MOV B,H ;Set total length in CBCJ
MOV C,L
POP H ;recover start address
XCHG ;save it at once
LHLO BINTAB ;get lowest address of existed
;CO files
PUSH H ;save it for after adjustment
XCHG ;CHLJ start address
;CBCJ file length
CALL MAS.DEL ;remove the body of the file
POP H ;recover BINTAB
SHLD BINTAB ;adjust BINTAB
- 152 -
RAM FILE HANDLING
;, - .. ·1
•
' CALL LNKFIL ;make up starting address in
;the directory area
RET
; EXTERNAL ERROR ROUTINE
,•
BADFIL:
;Bad file mode
END
- 153 -
r
!
CHAPTER 9
LCD INTERFACE
- 154 -
LCD INTERFACE
•
. ·•
:<------- 240 dots-------------------->:
-----+-------~-------------------------------+
I
I
81 : B2 B3 .
84 BS
64 dots+---------------------------------------+
I
I
B6: B7 BS 89 810
-----+---------------------------------------+
Fig 9.1
- 155 -
r~~ LCO INTERFACE
msb 7 6 5 4 3 2 1 0 lsb
+---+---+---+---+---+---+---+---+
lPA7lPA6lPASlPA4lPA3lPA2lPA1lPA1: OUT ""X89
+-------------------------------+
: X l X l X l X: X l X lP81lPB0l OUT ""XBA
+------------------------------+
PA0 to P87 is associated to 8LOCK1 to BLOCKS
P80,PB1 to BLOCK9,10 respectively.
0 = Not Select/ 1 = Select
Oescr-iption:
Selecting a LCD Block C same meaning as selecting a
Segment Driver IC) .which. you want to access. You
cannot select two blocks at a time.
- 156 -
LCD INTERFACE
msb 7 6 5 4 3 2 1 0 lsb
+---+---+---+---+---+---+---+------+
: 0 : 0 : 1 : 1 : 1 : 0 : 0 : DISP : OUT "'XFE
+---+---+---+---+---+---+---+------+
- 157 -
/
LCO INTERFACE
-
9.3.2.2 Set Address Counter
msb 7 6 5 4 3 2 ·f · 0 lsb
+---+---+---+---+---+---+---+---+
lPG1lPG0lOFS:OF4lOF3:0F2:oF1:oF0:
+---+---+---+---+---+---+---+---+
Select PAGE
PGl PG0
0 1 PAGE0
0 1 PAGE1
1 0 PAGE2
1 1 PAGE3
OFn means 'OFfset counter' in each PAGE.
It must be from 0 to 49.
- 158 -
•
LCD INTERFACE
,I
OFFSET counter- .
PAGE 0<------------------->49(39 if BS/810>
counter- +---+-------------------+
: 1sb: I
I
"800 I
I
I
I PAGE 0
:msbl
+---+---~---------------+
l lsb I
I
"B01 I
I PAGE 1
lmsb
+-----------------------+
: 1sb
"'B10 I
I PAGE 2
:msb
+-----------------------+
:meb
"'B11 PAGE 3
: 1sb
+-----------------------+
Fig 9.2
- 159 -
/
r
, LCD INTERFACE
msb 7 6 5 4 3 -- 2 . 1~
0 lsb
+----+---+---+---+---+---+---+---+
lSPG1lSPG2l 1 : 1 : 1 : 1 l 1 : 1 : OUT "XFE
·+----+----+---+---+---+---+---+---+
Description:
Assume that each LCD block is divided into 4 pages
corresponding with the Display RAM. The combination
with the Page of LCD Block and Display RAM page can
changed. The •sET STARTING PAGE. defines the mapping
bet~een the Page in Display RAM and the Page of LCD
Block.
Ex.
Assume that Starting page is ~et to 2. Then mapping
bet~een Display RAM and LCD PAGE becomes as shown as
follows.
- 160 -
LCD INTERFACE
-LCD BLOCK
Upper +-----------------------+
.,
PAGE2 in Display RAM
is displayed here
+-----------------------+
PAGE3 in Display RAM
is displayed here
+-----------------------+
PAGE0 in Display RAM
is displayed here
+-----------------------+
..
I
Lower +-----------------------+
Fig 9.3
- 161 -
LCD INTERFACE
....
9.3.2.4 Select Addre9s Counter Mode
m9b 7 6 5 4 3 2 1 0
+---+---+---+---+---+---+---+---+
: 0 : 0 : 1 : 1 : 0 : 0 : 1 :u10: ouT AXFE
+---+---+---+---+---+---+---+---+
-· 162 -
LCD INTERFACE
.,
9.3.3 Read Status Read The Status Of Segment Driver.
- 163 -
LCD INTERFACE ··•
.,.
9.3.4 ~rite/Read Display Data
.. -·~-. .
~-
+--+--+--+-~+--+--+--+--+
:O7lO6lDSlD4lO3:D2lD1:O0: IN/OUT "'XFF
·+--+--+--+--+--+--+--+--+
Description:
Read the data from the Display RAM that is pointed by
PAGE and OFFSET counter. If you want read some portion
of the Display RAM, use this command after Setting t~e
PAGE counter and OFFSET counter by ·set Address
Counter· command and ·set Page Counter' command
described before. Note that one dummy read must be
done before using this command in order to get a
correct data.
- 164 -
LCD INTERFACE . .
9.4 SOFTWARE FOR LCD
PAGE COUNTER= 0
OFFSET COUNTER= 0
UP COUNTER MOOE
STARTION PAGE= 0
DISPLAY 0N
Note:
Whenever the power is turned on, LCD is initialized by
the reset pulse of the hard wear. At that time,
Display is turned OFF, Offset Counter is set to count
up mode. Another status is not determined.
- 165 -
LCD INTERFACE
.,..
9.4.1.1 Sample Program For LCD Initialization.
. ,• ---'
; ·In it i a 1 i ze Segment driver •
,•
·---
, Eciuaters
PORTA EQU "X089
PORTS EQU "X08A
LCDCOM EQU "X0FE
LCDSTAT EQU "X0FE
LCDINIT:
DI ; Inhibit disturbance for Por~
A/8
CALL SELALL ; Select all Segment Driver.
CALL LCOBUSY ; Yait until LCD become Ready.
XRA A
OUT LCOCOM . ; Reset Address Counter.
CALL LCOBUSY
MVI A,"X38 ; Offset counter Up mode.
OUT LCDCOM ;
CALL LCOBUSY
MVI A,"X3E ; Set starting PAGE=0
OUT LCOCOM
CALL LCOBUSY
MVI A, ""X39 ; Display ON.
OUT LCDCOM ,•
LCOBUSY:,
; Uait until LCO become Ready.
IN LCDSTAT ; Get LCD status.
RLC ; Move MSB to CF.
JC LCOBUSY ; Wait if LCD is busy.
RET
SELALL:
; Select all Segment Drivers
- 166 -
,-
LCD INTERFACE
MVI A, "XFF ,•
OUT PORTA : S9h
IN PORTS ; Get current status.
ORI 03 ; Select block 9,10.
OUT - PORTS
RET
ENO
- 167 -
LCD INTERFACE ·•
- 168 -
,,.-
LCD INTERFACE ..
9.4.2.1
- . .
Sample Program Of Writing A Character On The LCD.
LOCATE:
; LOCATE 0,0
LXI H, ""X0101 ; To set cursor position
•
• (0,0)
SHLO CSRY •
LXI H, ""X0000 '
SHLO LCTEY
PREP:
;-- Select Block 1 to write (1,1)
DI ; Inhibit disturbance for
; Port A/B of 81C55.
; You need not do DI as
; far as no one
- 169 -
r
LCD INTERFACE
"
; changes the data port of
; 81CSS. You have to consi~er
; other INT routines.
MVI A,"X01
•
OUT PORTA ,•,• Select
-· Block 1
IN PORTS ; Get current status.
ANI "811111100 ; Deselect Block 9/10.
OUT PORTS ••
CALL LCDBUSY ; Wait until LCD become ready.
. MVI
OUT
A,0
LCDCOM
; Page 0,offset 0.
,•
CALL LCOBUSY ,•
MVI A,"800110010 ; Offset counter Up mode.
OUT LCOCOM
CHROUT:
LXI H,FONTA ; Get start Address of Font A.
MVI C,"X06 ; Set Font size.
•
WRITE:
,•
; Write data to Display RAM of LCD
,•
; ENTRY: CHLJ = Font start address.
; CCJ ·= Length of Font.
CALL LCDBUSY ; Wait until LCD become Ready.
MOV A,M ; Get font Pattern to send.
OUT LCOIO : Write to Display RAM of LCD.
INX H ; Up date PTR.
OCR C ; Bump Counter.
JNZ WRITE ; To send next pattern.
; Offset counter is Auto
; increment Mode, so ~e don't
; care about OFFSET counter.
LXI H,CSRX ; Up date Cursor PTR.
INR M ; No check for end of line in
; this program.
LXI - H,LCTEY
INR M
- 170 -
LCD INTERFACE
...
ORI "'800000011
our· PORTB
CALL LCOBUSY • Wait unti 1 LCD become Ready •
MVI A, "'X3F. ,,••
.• St~rting page 0 •
OUT LCOCOM
MVI A,"X00111001 •• Insure display ON •
OUT LCOCOM
EI
RET
LCOBUSY:
IN LCOSTAT ,• Get LCD status •
RLC •• Move msb to CF •
JC LCOBUSY
RET
OB "'X12,""X3C,"'X00
ENO
- 171 -
LCD INT-ERFACE
t
9.4.3 How To Set/reset A Dot On The LCD.
100 CLS
110 FOR Y=9 TO 22
120 FOR X=60 TO 80
130 PSET<X,Y)
140 NEXT X
150 NEXT Y
160'
170 FOR Y=14 TO 18
180 FOR X=64 TO 76
190 PRESETCX,Y)
200 NEXT X
210 NEXT Y
220 ENO
,•
; Sample program for SET/RESET a Dot •
,•
PSET:
DI •, Disable a 11 interrupt
,• to keep correct block
select.
XRA A ,• To set SET flag.
STA SR ,• Set/Reset Flag •
- 172 -
/
LCD INTERFACE
..
LXI B., "X140E ..., CBJ=20 X count,CCJ=14 y
count.
LXI H,"'X0A09 ,• CHJ=X Position,CLJ= Y
Position.
PSETl:
PUSH H ~.,, Save CX,Y) Position.
PUSH B • Save X,Y count •
·CALL MAIN
POP B ,• Restore X,Y count •
POP H ,• Restore X,Y position
INR L •, Advance Y position.
OCR C • Bump Y counter •
JNZ PSETl '
PRESET:
MV.I A,"XFF • To set SR Flag.
STA SR ,•' Set Unplot Flag •
LXI B,"X0C06 • CBJ=12,CCJ=06
LXI H,"'X0E00 •' <CHJ,CLJ>=<14,13>
PRESET1: '
PUSH H • Save X,Y Position.
PUSH B ,•' Save X,Y counter •
CALL MAIN
POP B •, Restore X,Y counter.
POP H ,• Restore X,Y position.
INR L • Advance Y position.
OCR C •' Bump Y counter •
JNZ PRESET! '
RET
MAIN:
•
'•, CHJ = X position
,• CLJ = y Position
,• CBJ = X count
,• CCJ = y count
PUSH H • Save X.Y Position.
CALL DOT ,•' Plot/Unplot a dot at CX,Y)
POP H • Retrieve Position.
INR H •' Advance X POSITION.
OCR B ',• Bump X counter •
JNZ MAIN ,•
RET
DOT:
CALL LMAIN
LOA SR •, Get SR flag.
ORA A •, See if set/reset?
JNZ RESET ,• Branch if Reset.
MOV A,E ,• Get MASK pattern .
- 173 -
LCD INTERFACE
..
ORA D a •f CAJ = data to write.
JMP DISP
RESET:
MOV A,E ,• Get Mask Pattern.
XRI ""XFF ,• Reverse MSK pattern •
ANA D •, CAJ = data to write.
DISP:
MOV D,A
CALL WRITE
DI
MVI A, ""XFF ,• Select all Block.
OUT PORTA
IN PORTS
ORI ""800000011
OUT PORTS
CALL LCDBUSY ,• See if Led Busy.
MVI A,"'800111111 • Starting Page 0
OUT LCDCOM '
CALL LCDBUSY
MVI A,'"'800111001 ,• Display ON.
OUT LCDCOM
EI
RET
LMAIN:
• ENTRY: CHJ·= X po!lition in Block-1
'• CLJ = y Position in Block-1
'• Reg:
'
PUSH H ,• Save X,Y position.
PUSH H
CALL SEL2 • Select Blocl<-2.
CALL SETADR ,'• Set Address of Display RAM.
CALL READ ,• Read· the LCD.
POP H ,• Retrieve X,Y position.
CALL GETMSK ,• Get Mask Pattern.
POP H ,• Retrieve CX,Y> Position
CALL SETADR
RET
WRITE:
,• Fune: Output CODATJ to LCD.
,•
,• Reg: A and Flags.
CALL LCOBUSY
MOV A,D ,• Get Data to r..1rite •
- 174 -
LCD INTERFACE·
•
OUT LCOIO ·•
NOP ; Must be EI at final.
RET
READ:
-l
Entry: Non
Exit: COJ = Current Data in Display RAM.
Reg: A,O and Flags.
CALL LCOBUSY ; Wait until LCD become Ready.
IN LCOIO ; Dummy Read.You must do this
to .
; get correct data.
CALL LCOBUSY •
IN LCOIO ;' Get Valid Data.
MOV O,A ; Save it.
RET
GETMSK:
; Entry: CLJ ·= ·y Position
,•
; Exit: CEJ = Mask Pattern •
,•
; Reg~ A,L,E and Flags.
MOV A,L ; Get Y position.
ANI "B00000111 ,•
MOV L,A ; Set counter.
.MVI A,"B80
MSK1:
RLC
OCR L ; Bump counter.
JP MSK1 ; Branch if not finished.
MOV E,A ; Save Mask pattern.
RET
SETAOR:
•
,'• ENTRY: CHJ =X Position on Block-2
,•
,•
CLJ = Position
y on Block-2
,• FUNC: Set Address
•
,'• Register:
,• A,H,L and Flags •
MOV A,L Get Y position.
- 175 -
r·
LCD INTERFACE ...
RAL ; ; Mbve Bi t4/3 to Bi t7 /6.
RAL
RAL
ANI "'81100'e000 ; Get page.
ORA H ; CAJ = Page and OFFSET.
MOV L,A "' ; Save it.
CALL LCOBUSY ; Wait until LCD become Ready.
MOV A,L ; Retrieve Address.
OUT LCOCOM
RET
LCOBUSY:
; Entry: Non
,•
• Fune: Wait unti 1 LCD become Ready.
,'•
,• Exit: Non
,•
• Reg: A and Flags~
,•'
IN LCDSTAT ; Get LCO status.
RLC ; Set Busy FLG to CF.
JC LCOBUSY ; Wait if LCD is BUSY.
RET
SEL2:
; Select Block-2
;
; Reg: A and Flags •
•
'
OI
MVI A,"'800000010 ; Select Block-2
OUT PORTA
IN PORTS
ANI "'811111100
OUT PORTS
RET
- 176 -
LCD INTERFACE
- 177 -
LCD INTERFACE •'
Fig 9.4
- 178 -
LCD INTERFACE
-~ -~
9.4.5 How To Store The Your Own CG
BLOAO "FONT"
After this sequence, ROM #0, for instance, BASIC, can use the
new Defined CG.
- 179 -
,,•·
LCD INT~RFACE
..•
9.S AVAILABLE SYSTEM WORK AREA
•,
; ENTRY CAJ = character Code (AX20 to AX7E)
,•
EXPAND:
SUI A,AX20 ,•
MOV C,A ,..
ADO C ; *2
ADO A ; *4
ADO C
MOV C,A ; CCJ offset from base of CG.
MVI B,"'X00 ,•
LXI H,CGAOR
DAO B
LXI 8,TEMP
MVI O, "'XS ; Set font data length.
NEXT:
MOV A,M ; Get Font data.
STAX 8
INX H
INX B
OCR D
- 180 -
LCD INTERFACE ...
··--•
JNZ NEXT
ORA A
STA TEMP+S
RET
. -...i
- 181 -
LCD INTERFACE ··!
-··'
9.5.2 VRAM AREA IN SYSTEM Work Area
•.
"'.' 182 -
LCD INTERFACE
.. .
9.5.3 Reverse The Attribute Of The Specified Area,
+---------------------------------------------+
:c 1,1):( 2,1)l( 3,1): : <39, 1 ) : C40 , 1 >:
+--------------------------------------------+
:< 1,2):( 2,2):( 3,2): : <39 , 1 ) : <40 , 1 ) :
+--------------------------------------------+
+--------------------------------------------+
:c 1,8)1( 2,8)1( 3,8): : <39 , 8 >I <40 , 8 > :
+--------~-----------------------------+
AXFA60 Bit0 (01,1)
Bit1 (02,1)
Bit2 (03,1)
Bit3 (04,1)
Bit4 (05,1)
BitS (06,1)
Bit6 (07,1)
Bit? (08,1)
AXFA61 Bit0 (09,1)
Bit1 (10,1)
I
. I
- 183 -
•,:.;, ;.,:·
'
--~
·- -
- .. -·
:. -:.
....
CHAPTER 10
KEYBOARD INTERFACE
i--?A.1
l
·i-------·'----f80
Fig 10.1
- 184 -
KEYBOARD INTERFACE
.. J.
The abbreviation PAn (PA7, PA6, ••• , PA0) and PBn
means the bit of· PORT A and B of 81CSS. Please refer to the
follo~ing sections about I/O ports. And also, KDn (K07, KO6
•• , KD0) represents the bit of the KEYIN, Input port for the
Keyboard. -' 4
- 185 -
KEYBOARD INTERFACE
f
10.1.1 I/0 Port For Keyboard
msb 7 6 s 4 3 2 1 0 lsb
+---+---+---+---+---+---+---+---+
:KS7lKS6:KSSlKS4:KS3:KS2lKS1:KS0: OUT AXB9
+-------------------------------+
: X: X: X: X: X : X: X :KSS: OUT AXBA
+-------------------------------+
KSS ••. KS0 KEYBOARD Strobe
0 = Strobe OFF
1 = Strobe ON
- 186 -
KEYBOARD INTERFACE .t
. . "
.msb 7 6 s4 3 2 1 0 1sb
.
+---+---+---+---+---+---+---+---+
:KD7lKD6:KDSlKD4:KD3:KD2lKD1:KD0: IN AXEB
+---+---+---+---+---+---+---+---+
- 187 -
KEYBOARD INTERFACE
- 188 -
KEYBOARD INTERFACE
10.2
,.
SOFT WARE FOR KEYBOARD OPERATION.
3. Strobe off
- 189 -
KEYBOARD INTERFACE
. '
10.2.1.1 Sample Program Reading Keyboard.
,•
; Read CURRENT KEY BOARD STATUS •
,•
; Note: Make sure Keyboard strobe is
• not disturbed while reading the key board •
,'• You have to care of the other interrupts •
,•
; Equator
PORTA EQU "X89 ; Keyboard Strobe Port
PORTS EQU "XBA • ditto
KEVIN EQU "XES '; Keyboard data Port.
ORG "XF000
REAOKEY:
LXI B,KYOATA ; Get PTR for buffer.
MVI A,"XFF ; Disable normal key strobe
OUT PORTA ,•
IN PORTS ; Get PortB Status.
ANI "XFE ; SET B0=0ff.
OUT PORTS ; Activate Strobe for
,• Special key •
IN KEYIN ; Read keyboard.
STAX B ; Save Data.
IN PORTS ; Get St8tue of Port B.
ORI "X01 ; Set B0=0n.
OUT PORTS ; Strob9 off.
MVI A,"B11111110
NOMAL:
INX B ; Prepare PTR for key Buffer
; for next data.
OUT PORTA ; Strobe On
MOV D,A
IN KEYIN ; Get data.
STAX B ; Store it.
MVI A,"XFF
OUT PORTA ; Strobe off.
MOV A,D ; Retrieve strobe data.
RLC ; Strobe for next column.
- 190 -
KEYBOAROCE
1
.... ....
.
• JC NOMAL
RET ; All done return to caller.
•
·- ,• PB0
' OS ·1 column
OS 1 ,• PA0 ditto
OS 1 • PA1 ditto
OS 1 '• PA2 ditto
OS 1 •' PA3 ditto
OS 1 '• PA4 ditto
OS 1 •' PAS ditto
OS 1 '• PA6 ditto
OS 1 ,•' PA7 ditto
•, Be careful that
•, Bit OFF means key
• is depressed •
'
SNO
- 191 -
. ~
CHAPTER 11
CMT INTERFACE
- 192 -
CMT INTERFACE
'l
- 193 -
CMT INTERFACE
SIO
high +-------+ I
I
+-------+ +--------
low +-------+ +-------+
I
I
- 194 -
CMT INTERFACE
- 195
CMT INTERFACE
- 196 -
CMT INTERFACE
-...--.;
11.1.4 I/0 Port For CMT
msb 7 6 s 4 3 2 - 0 · 1sb
+----+-~--+----+----+------+--------+
: XX : XX: XX : XX :REMOTE: XXXXXX : OUT "'X90
+----+----+----+----+-----+--------+
REMOTE CMT Motor control.
0 = CMT Motor OFF
1 = CMT Motor ON
Description:
The current status of this por-t is saved at
SYSSTAT("'XFE44), so you have to update this area when
you want to change the statl.J!S of this port.
msb 7 6· S 4 3 2 1 0 lsb
+---+---+---+---+---+---+---+---+
lTM2lTM1: 0 : 0 : ? : ? : 1 : 1 : OUT "XB8
+---+---+---+---+---+---+---+---+
- 19'] -
,,.
CMT INTERFACE:
TM2 TM1
0 0 NOP
0 1 Stop
1 0 --- Stop after Terminal Count
1 1 Start-J
- 198
CMT INTERFACE
......
11.2 SOFTWARE FOR CMT
,•
• Turn on the motor •
,•'
CMTON:
LOA "'XFE44 . ,• Get SCP port status •
ANI "'B11110111 • See if Motor ON?
RNZ '• then r"eturn •
ORI "B00001000 ,•' Bit 4 on •
OUT SCP • Turn on Motor •
STA "'XFE44 '• Up-date Sep status •
RET '
'•; .. Turn off CMT Motor •
•
'
CMTOFF:
LOA "'XFE44 ,• Get SCP Status •
ANI "'811110111 ,• Bit 4 OFF.
OUT SCP • Turn off Motor •
STA "'XFE44 ,•' Up-date SCP status •
RET
- 199 -
CMT INTERFACE
_,.; _,..,
i1.2.2 Baud Rate Generati~n
+-----------+-----------------+
: BAUD RATE: NUMBER OF STATE:
: for 1 Bit
+-----------+-----------------+
75 bps : 32448
+-----------------------------+
150 16224
+-----------------------------+
300 8112
+-----------------------------+
600 4056
+-----------+--------------.--+
1200 2028
+-----------+-----------------+
Fig 11.3
- 200 -
CMT INTERFACE
.'!' p-,
11.2.3 Write A Data To The CMT
- 201 -
CMT INTERFACE
; HOLD1 gives
...
,• 24 * CHLJ + 7 (+18>
; states delay. (+18) means "CALL" instruction Status.
; So HOLD giv 7 s 4043 states delay including "CALL" of Caller.
-4 • •
,
HOLD:
..... .~
- 202 -
. CMT INTERFACE
.. ,
11.2.4 Reading A Data From The CMT
,•
; Sample Program for Reading a BYTE.
,• Assume Called with Interrupt disable •
READ:
CALL BIT! • 10: Search for start
JC READ '
;10/7: Wait unti 1 Start bit
• •• has come •
LXI H,·???? ,•' 10:
CALL HOLD1
MVI C,8 • 7: Read 8 BIT.
BYTE!: '
CALL BITI • 18:
MCV' A,B ,
•' 4:
RLC ,• 4: Move CF to Bit-0.
MOV B,A ,• 4:
OCR C ,• 4: Bump counter •
JNZ BYTE! ;10/7: Read next BIT.
RET . ,• 10: No check for Stop bit.
,•
; Get a BIT .
,•
; EXIT: CF= 1 if MARK.
,• CF= 0 if SPACE •
,•
BIT!:
CALL SYNC ,• 18:
MOV A,D ,• 4: Get counter •
CPI 16 ,• 7: See whether MARK
,• •• or SPACE •
,• •• If MARK then CF=l,
•, •• else CF=0 •
PUSH PSW 12: Save CF.
LXI H,??? • 10: Assume MARK.
JC BITI1 '
;10/7: Good assumption.
LXI H,??? ,• 10:
BITI1:
CALL HOLD! ,• 18:
POP PSU •, 10:
- 203 -
CMT INTERFACE
- 204 -
• _.J
CHAPTER 12
SERIAL INTERFACE
- 205 -
...,_ ..., .,
SERIAL INTERFACE
-- -2~6 -
SERIAL INTERFACE
- 207 -
SERIAL INTERFACE
"-i
12.1.1.2 UART Mode Control
-~
msb 7 - S 4 3 1
·:+-------+----+----+----+---+---+
xxxxx lCLS2:CLS1: PI :EPE:sas: OUT "XD8
+-------+----+----+----+---+---+
S8S Stop Bit Select
0 = 1 bit
1 = 2 bits 00
(*) When Data length is 5 bits,
Stop Bits is 1.5 bit.
EPE Even Parity Enable
0 = Odd Parity
1 = Even Parity
(Meaningless if Pl= 1)
PI Parity Inhibit
0 = Parity Enable.
1 = Parity Disable
CLS2/1 Character Length Select
"800 = 5 bits
"B01 = 6 bits
"B10 = 7 bits
"811 = 8 bits
- 208 -
SERIAL INTERFACE
-..:•1 .::t
I
12.1.1.3 UART Status Read
msb 4 3 2 1 0 lsb
+-------+----+----+----+----+------+
: XXXXX :TBRE: PE : FE l OE :dcd/dr-: IN "'XDB
+-------+----+----+----+----+------+
dcd/dr- OCO/OR on off C0=on/1=off)
OE Over--r-un Err-or- (!=Detected)
FE Framing Err-or- Cl=Detected)
P~ Parity Err-or- (!=Detected)
TBRE Transmit Buffer- Register Empty
1 = Ready to receive data to transmit.
- 209 -
I
SERIAL INTERFACE
1:
set a Baud Rate use blow value.
--------+---------+-------~-+
ud Rate : AXBC ., AXBO
I
--------+---------+---------+
75 00 48
·--------+-~-------+---------+
150 . : 68 45
·--------+--------+---~-----+
300 00 42
-~-------+---------+---------+
600 00 41
--------+---------+-~-------+
1200 80 40
---------+---------+---------+
2400 40 40
---------+--------+-~-------+
2400 40 40
---------+---------+---------+
4800 20 40
----------+---------+---------+
9600 10 40
----------+---------+---------+
19200 08 40
-----------+---------+---------+
Fig 11.1
- 210 -
SERIAL INTERFACE
:-, . .,
NOTE:
- 211 -
SERIAL INTERFACE
msb lsb
+--+--+--+--+--+--+--+--+
:D7lD6:Ds:D4:D3:D2:D1:00: IN/OUT Axes
+--+--+--+--+--+--+--+--+
Note:
If the data length is less than 8 bits, Output
data must be right justified. Input data is right justified
by UART.
- 212 -
SERIAL INTERFACE
1. Select Channel
2. Set Baud Rate.
3. Set transfer mode.
- 213 -
SERIAL INTERFACE
-~f
12.2.1.1 Sample Program ••• How To Initialize SERIAC Port
i .
INITSERI:
; ENTRY: CCJ = USER IO.
; CBJ = Baud rate specifier. ASCII Number (1 to 9)
; Same Number of "STAT" of TELCOM.
See if Serial Port is available.
- 214 -
tf
SERIAL INTERFACE
·J
i
! .
ORA A • No one use Serial I/0?
JZ SELECT ,•' then branch.
CMP C • SAME USER?
.. JZ
·sTc
RET
SELECT ,•'
·.-,
•
. Th~:m branch.
Set Error.FLG.
Re~urn to caller.
'
SELECT:
; Reserve Serial Port-------
DI ; Inhibit all disturbance.
MOV A,C ; GET USER ID.
STA COMACT ; Set User ID. Be sure reset
; Use ID to @0 after all task
; finished,else the serial
; port
; can not be shared to
; another user.
RRC ; Move Bit0-1 to Bit 6-7
RRC
MOV C,A ,• Save it.
LOA SYSSTAT • Get current SCP status.
ANI "'B00111111 ',• cancel channel contro 1 •
ORA C ,
• Set new channel control
• bits •
OUT SCP •' Select channe 1 •
STA SYSSTAT ',• Update SCP status.,
·--
, Set BAUD RATE--------------
SETBAUO:
MOV A,B ,• Get BAUD RATE IO.
STA SERMODE • Update Baud rate Specifier.
SBI •1 • '• Convert to Binary Number.
RLC ,•' *2,Because table entry is
• 2 bytes •
LXI H,TIMTBL •'
MOV C,B ,'• CCJ = Offset
MVI B,0
DAD B
SHLO BAUORT • Save entry point for
,•'
Music routine.
,•Music routine in ROM #0
•, destroy temporary changes
the timer count and
,• reinitializes it with
,• this entry data after
• finish •
.
,' Refer Chapter 12.3
MOV A,M ,• Get Lot..1er value.
- 215 -
SERIAL INTERFACE
OUT TIMEL •
INX H '
MOV A,M ; Get Higher Value.
OUT TIMEH
MVI A,"XC3 .• ; -l'o 9tart timer.
OUT ""X88 ; Uee this value to
; etart Timer •.
~
- 216 -
SERIAL INTERFACE
....-,
12.2.2 SEND A Data To T~e Serial Port
WRITE:
IN "'XD8 ; Get UART status.
CPI "800010000 ; See if transmitter buffer
r--. ; register Empty?
JZ WRITE ; Wait TBR become empty.
MOV A,C ; Get character to send •
OUT ....XC8 ; Send it to the serial port.
RET
- 217 -
I
SERIAL INTERFACE
--f
12.2.3 Read A Data From Serial Port.
READ: ~
PUSH H ,• Save registers. ti
PUSH D ~
PUSH B i~
PUSH PSW i
IN "'XC8 ,• Read the data
MOV L,A ,• Save it •
IN "'XD8 ,• Get error status •
ANI "'B00001110 ,• Strip error bit.
MOV H,A ,•
SHLO BUFFER
POP PSW ,• Restore Registers.
POP B
POP D
t~
POP H r
;~
EI '
~';
RET ~
l
}
BUFFER OS 1 ,• Got Data.
OS 1 ,• Error status .
~~
[
V
~
i,;
~
t
~
- 218 -
SERIAL INTERFACE
-~ ··t
12.3 AVAILABLE SYSTEM AREA.
~- You may want to-use the sy~tem area for your use. In
this section, the available work area of ROM #0 is described.
Make sure to keep the compatibility with System ROM, if you
want use this area.
"X00 = No user
"X01 = SI02
AX02 = SI01
"X03 = RS-232C
- 219 -
SE~IAL. INTERFACE
BAUORT C"'XFE4A)
This points the tab 1e of the Baud rate.. Refer to the
Chapter 12.2.1.1 ·sample Program.
- 220 -
,: .... ··.~
_,.
......... -----··--
CHAPTER 13
BARCOOE READER
. ~~B
~ G-~G-~e - - , 1?1~
5 ,...,___
7711
'Ice. Fi'i~ {3.1
- 221 -
l.·
BARCOOE REAOE.R
- 222 -
--
CHAPTER 14
PARALLEL INTERFACE
lsb 7 6 S .4 3 2 1 0 lsb
+---+---+---+---+---+---+---+---+
:Po7:Po6:Pos:Po4:Po3:Po2:Po1:Po0: ouT Axs9
+---+---+---+---+---+---+~--+---+
- 223 -
PARALLEL INTERFACE
msb 7 6 5 4 3 2 1 0 lsb
+--+--+--+--+--+----+----+----+
:xx:xx:xx:xx:xx:susv:sLCT: xx: IN Axse
+--+--+--+--.+--+----+----+----+
msb 7 6 5 4 3 2 1 0 lsb
+--+--+----+--+--+--+--+--+
:xx:xx:PsTs:xx:xx:xx:xx:xx: ouT Ax90
+--+--+----+--+--+--+--+--+
- 224 -
PARALLEL INTERFACE
-------·--+
BUSY
-------------+ +-----
T1,T2 >= 1.0 uSec
1.0 uSec < T3 < 600uSec
Fig 14.1
- 225 -
PARALLEL INTERFACE
,•
,•
•,
600000
;-- Ec;uater
SCP EQU "'X90 ; System Control Port.
PORTA EQU "'XB9 ; Printer Data Port.
PORTC EQU "'XBB ; Printer Status Port.
SYSSTAT EQU "'XFE44 ; SPC status.
START:
LXI H,BUF ; Set PTR.
MVI C,10+2 ; Set data length.
PRINT:
IN PORTC ; Get Printer status.
ANI 6 ; Strip BUSY,SLCT bits.
XRI 2 ; See if ready.
JNZ PRINT ,• if not,then wait.
DI ; Inhibit disturb for Port A
; of 81CSS.
MOV A,M ; Get character to Print.
OUT PORTA Put data on the DATA line.
LOA SYSSTAT Get SCP status.
MOV B,A Save It.
· ORI ""800100000 Set STROBE.
OUT SCP
MOV A,B
OUT SCP
MOV 8, ""X03 ; Please set appropriate
; value for your Printer.
- 226 -
PARALLEL INTERFACE
WAIT:
OCR 8
JNZ WAIT
EI
...
.'.
INX H
.... ~
; Point to Next
OCR C
JNZ PRINT
RET
BUF: 08 'ABCDEFGHIJ'
DB 13,10
END
- 227 -
/
....
CHAPTER 15
HARDWARE
- 228 -
HARDWARE
S\"STc.\l SLOT
I i
Pin number I Sigr:a/ name I
Remarks
I I
1 voo +S V
2 voo +S V
3 AOO
I Adc:-ess/Oata 0
4 AC4 Addra:s/Oata 4
.5 .A.01 Address/Data 1
6 ACS Address/Data S
7 A02 Address/Cata 2
8 A06 AddressiOata 6
9 A03 Address/Data 3
10 A07 Address/Data 7
11 NC No C0nr.e~ion
12 NC No C;:nnec:io r.
13 AS Address 8
Fig 15.1
- 229 -
,,,.-
HAROUA'RE
...
Pin number
I Signal name
A9
I Remarks
Address 9
15
16 A13 Address 13
17 A10 Address 10
18 A14 Addresl i4
19 Al 1 Address 11
20 Ai5 I Acld:-es~ 15
21 A16
i No Conr:ec::ion
22 A18 No Connec:tion
23 A17 No Connec:ion
25 NC Ne C,nnec:ion
.
26 NC No Connec:tion
27 RO Read .,
28 WR Write
.
29 10/M 10 OR Memory
31 HOLO HOLO
32 HOLOA HO LO Acknowtedge
Fig 15.2
- 23~ -
HARDWARE
·&.--·fl
-··.r~
--:4 ---'!
Pin number
I Signal name
INTR
I Remarks
INTERRUPT
33
36 READY I READY
40 NC No Connec:ion
43 CLJ< Clock
45 GNO Ground
46 GNO Ground
47 NC No Connection
48 NC No Connection
Fig 15.3
- 231 -
HARDWARE
1. Vdd COut)
If you don't use the BCD, this Pin can supply with
the current of 50mA or so.
2. A00-A07 <In/Out)
Lower 8 bits of the memory address Cor I/0 address)
appear- on the bus during the first clock cycle of a
machine cycle. It then becomes the data bus during the
other cycles.
3. A8-A15 COut)
The most significant 8 bits of the memory address or
the I/0 address. The output goes off during Hold mode,it
then becomes •H• level, because it is connected to a pull
up resister (100k Ohm). inside.
4. /RO COut/3-state)
The read control signal, 3-state during Hold mode.
6. IO/M COut/3-stater
When this signal is •H• level and IL. level,
- 232 -
/
HARDWARE
f -~
7. ALE (Out/3-state)
It is used to strobe the address information
( A00-A07). 3-state during Hold mode.
8. HOLD CIn)
The CPU, upon receiving the hold request, will
relinquish the use of the bus as soon as the completion of
the current bus transfer. When the Hold is acknowledged,
the /RO, /WR, IO/M, ALE lines are 3-stated and the
A08-A015 lines are •H• level.
- 233 -
HAR~ARE·
4liHf38
IOIM I ~~1
Gr
1-
~
CONi;;oL
Y! I .
Tis
_A/4
IGZ
IC
Y.:
y4.
I
1
----
5.J.Ni<
d'"IJ~
,4o2D
Al3 ,a Ys ~
Ai2 Y' I Rrr
( y71
I L.c!5
Fig 15.4
15. E <Out>
It is used as a memory enable signal of the read or
urite cycle. Eis the logical OR (active high) of /RO and
/WR.
Fig 15.5
- 234 -
HARDWARE
- 235 -
HARDWARE
15.1.3 DC Characteristics
-------------------~----------------------
Symbol Drive capacity (mA)
• -;00:;o;---------------4~4--=..---~--------
.
----------------------------------------
A8-A1S 4.4
/RD,/WR,IO/M
ALE,RESETO 4.4
HLOA,/INTA,CLK 2.0
E,/ROME,/BANK 3 1.1
Fig 15.6
- 236 -
,/
HARDWARE
15.1.4 AC Characteristics
··-< ---~----·
. j ·_
---- .-
~,I
.:
""'t-
.....
"Z'
-=~
2:
n
"M
I
,J
~
<'
Q,
-
:-' .z.
- .--
,. ~ ..."' - ·--
- :i- -
L-- I
~
c
'-1
i
i-
i-
i
I
I I - -I
I -I ' .... I
I
-
i'
i
I
I
I
! ~
!
'
'
- .! loo{
r.:-.... ~
:-J
f-.
I~
: I
r-~
-
..
~-~
~
1 ;'
I '
!
...
t
I
>-
<,.;
-
~
t:.:
I
~I
I.I.lo
IJ
I '
C:
~I
c::.
~ ,. I
-;
>
.
,. I .
~ ~ ..: ..: ).
~ J
.___ Q -:-
i::i I
f- ~ -< ,' ...: ....~
..;:
.... -,
:.. ~ :1oo
.:.
- ~
,-
... I
' 1
I
iI
I I
= ... ~
,_
lz
.
>-
~
...,:ilC C
0.
C)
C
I.I
Q:.
~
Q '.~
~ < < Ci:
Fig 15.7
- 237 -
HARDWARE
......
I X >< lJ I
-·~
·< ~'.
-·
• I
- •---
·~,..·.-:'7... --- ·:· I-
.
I
.... I
' -I
~
' f
~ - ... -
-·
_.i
II
...
f- . -- ...
I
•
-, I I
i
i
l-
L -- ....
,
-
I
1
i
'
,.
i'
!
•••
_
!
__.JI
-a - -·
~
1
1:!
<
c-,
-
Q
I Ji.
--- .- ~ -fr
I
I
l- i
~ I -; I
~
Q
Q --.
'
i!
i.
~
J It !'
;
- ,-, -
I
. ~ f
~ .....I, ,.,
.
.;; .:,
i ~! !
I I"'"!
~:
...-
.,., 4' I
- ,- - l
Q
i.....
t ~ f
I
: ... I
• :~ I
:;
I :: I
-· r~ ""1
I""'
I . ~ Ii , I
i
I II I I
Fis 15.8
- 238 - /
HARDWARE
-
"
--- --
I min (l\S) typ CnSl l'IIGl:( CnS, --
··-~-,..., - __..._...
------. -----~
1
ta~ l - J407
. tl..GX I t
112
.
t,u. I
I
rr2 I
i,:.u.
i
I
!
I
7i. I I
I
t~ ! 16:? I I
142
t,4~ I :r·1 I
! I
! I
t..: I i ...,- ~ II i
!
i ,. ..
tAD I I I
~
=~~ I I I
I
-.· -
-o.;
t:11) II I
I
334-
;
!
: tc: !2S I I
. ,
t~. I
I
163 .
t~CM i I
0 I
1
I
'
tw0&.
I I
I 7S I
ta. I
I
13 I I I
two I 88 I I
I
to,, Il
srs I r
I
t';rrl-!
I 0 I
I
I I
Fig 15.9
- 239 -
F
t HARDWARE
I\X BFFt= r - -J
..
RAM~3 RAM;:4 I
/\t.ieee
I
RAM address
- 240 -
HARDWARE
I;
----
V' :-.-~,-
I
:~-i -----. ---··
:\~ C~2::J F.AM P.;M RAM
ffiii!:lr i :ANi<='2 i·8~Nl#3
I! I :....--- _!- - - -
,,
I
I
-----------------------
,,;-, ------ ----- --·-
·-=..i
--~~t:'.f. - •-- - ••
r Si'i:AAM -------~
~M
Siuii;:.l.1
Fis 15.10
- 241 -
HARDWARE
·--.,..~-- ----~'~="J~.~--··------~·~1~;~~-----_-__
---~IQ~~,_ .. ·
.. I~ l: ~-
-.. ~ ~~~ .,- ----
l ~ I
-x
i I
11
i_-
~-, ~-
~) :,d~"i C',:
-
,., ~
= I ! i.
;it
:r. - ~-
- -··-----
71
.. ._..:J ,..
!
;
'·
;
:
!,'__J*.
I---'-i~i ~~!,1·___.
~ 1
I
i I '-" ,
'; •-r.lt
'ill~~-=~f',
J I
: -
!
1:~~:<
g -¾~ '
:t-~<"'0:···,----
I
I
!
I I
1&: , I ~-
! ~
I
l
I 31: I I ...?-,
i
i
i
~ 1
;;
~
I
I
I ·s
:=
I
' i
:
C:
-~
I ·;:;
:
~
s
lI
(..:
• c-~;-
~--~o::::i:~,,---- !! -' • • o_ ~:1:J, •
~-~--~
------,11~ ~~ '~l
~1, ,-/ ~'fii :1"~..-----.
~-.
I-·
~ 1_ _ _:i::..·----...L....~
~------,J JJ
il
I !
Fig 15.11
- 242 -
HARDWARE
IAIJ'
LADRS
OIM '
~
! ',001r.Q 4-0Hl'TS-· t:.G - . - . ·-- -
,...___ Ya..,_-----~
A!la I jro rG/ . Yi-y,------~
,.
~
:,l,N K.;t I
--,----.W ~
At1
.4Z2 I1 ,1=~
2Q;----.:
•., J"'H:
.. l ,.~ :n ,
Ya I
_{___/--
_
!l't.i(;:.;-4
,&, .
ll
i.. ~,.,
I I ,·
a "I
-y,;·
i . D - - -;•.'.t(,S•-
;
i --1LJ -
--+0--1
i
,;..:..·J:<
~ ---..:.. I
i ~i,,::J?
.
I ;
. :n? --=5\:-1
:t-~:u --;--.:,___,./
'f.,./o.;~
Fig 15.12
~I ' @2 '1@1·1:-;®
_~CD; I f · ©lCVt®tI I i
LAERII O I O I O I O I o/ 0 I I I '
UDR2 I O I O I O I f I l I I I O I ( I
HADRI j O I I , Io r I I I0 0 I
HADR2 I O ~ 0 I I0 0 I I I0 0
Fi9 15.13
- 243 -
r:
HAROUARE
·--~ - 244 -
HARDWARE
- 24S -
HARDWARE
:-----------
1011x010 0
------------------------
Port 8 Output
*LCD Chip Select
*Buzzer Control
·' *RS-232C Control
*Auto Power Off
Control
1011X011 I
------------------------
Port C Input
*Clock Data
*Printer Status
*BCR Data
*RS-232C Status
, 1011X100 0 Timer Resister-
Clower 8 bits)
*Lower 8 bits of counter-
1011X101 0
.------------------------
: Timer Resister
: (upper 8 bits)
l*Upper- 6 bits of counter
l*Mode Select
1100XXXX :I/01 UART:
6402: Data Urite/Data Read
--------------~:
1101XXXX : 0:
:-----------------------
Control
1101XXXX f I 3-S-:
I
I
I .
Buff: Input Port
I *UART Status
*Low Power Signal
~----------------------~-----------------------
1110XXXX : I : 3-S-:
Buff: Keyboard Input
-----------------------------------------------:
1111XXX0 : 0: LCOC: Command Write/Status
Read
---------------;
1111XXX1 : 0 :
:------------------------:
: Data Ur-ite/Data Read
~-----------------------------------------------
Fig 15.14
- 246 -
HARDWARE
11 0 0 1 0 0 0 0: OUT AX90
7 6 5 4 3
:SELA:SELB:PSTB:TSTB:REMOTEI
----------------
REMOTE CASSETTE
------------
MOTOR CONTROL
0 motor Off
1 motor On
TSTB CLOCK COMMAND STROBE
0 Strobe Off
1 Strobe On
PSTB PRINTER STROBE
0 Strobe Off
1 Strobe On
SEL A SEL B SERIAL INTERFACE SELECT
0 0 Not used
0 1 SI02
1 0 SIOl
1 1 RS-232C
- 247 -
HARDWARE
:1 0 1 0 0 0 0 1l OUT ~Al 4 ~
3 2 1 · 0
---------------------------------
lHAR02lHARD1lLAOR2lLADR1l
- ·---- 248 -
HARDWARE
I
.! : 1 0 1 0 0 0 0 0: IN "XA0 .-4
7 6 3 2 1 0
- 249 -
HAROUARE
:1 0 1 1 1 0 0 1: OUT AXB9
7 6 s 4 3 2 1 0
lPA7lPA6:PA5:PA4lPA3:PA2lPA1:PA0:
lP07:P06lP05lP04lP03:P02:P01lP01:
lKS7:KS6lKS5:KS4lKS3lKS2lKS1lKS0:
*Port B Output
:1 0 1 1 1 0 1 0: OUT ""XBA
- 2se -
HARDWARE
7 6 5 4 3 2 1 0
----------------------------------
:---:---: :DcD1:--: :
:RTS:DTR:BELL:APO:RD :MC:PB1:PB0:
• ---------~-----------~--~~----:---
----------------------------------
· :Kss:
----------------------------------
PB1 -- PB0 LCD Chip Select
- 251
HARDWARE
*'Pol"'t C Input
:1 0 1 1 1 0 1 1: IN "'XBB
_..J J
5 4 3 2 1 0
.-----------------------------------
I --- : --- : I :
:osR:CTSLBCR:BUSYiSLCT:cor:
----~------------------------------
CDI Clock Data Input Port
SLCT PRINTER BUSY
0 Printer Ready
1 P,-intel"' Busy
BCR Bar Code Reade,- Data Input Port
- 252 -
HARDWARE
:1 0 1 1 1 1 0 0: OUT/IN AXBC
----------------- -~. ~
7 6 5 4 3 2 1 0
---------------------------------
lTL7lTL6lTLSlTL4lTL3lTL2lTL1lTL0:
:1 0 1 1 1 1 0 1: OUT/IN AXBO
7 6 S 4 3 2 1 0
lM2:M1:THS:TH4lTH3:TH2lTH1lTH0:
•
THS -- TH0 Timer Counter Upper 6 bit
M2 M1
0 0 This-mode transmits a single-
square wave which the first
half of the number of count
is high and remaining 1s low.
(Mode 0)
0 1 This mode continually transmits
a Mode 0 type square wave.
(Mode 1)
1 0 Thi9 mode transmits a L-pulse
(single pulse) during one
clock when finishing the
terminal count.
(Mode 2)
1 1 This mode c6ntinually transmits
a Mode 2 type pulse.
(Mode 3)
- 253 -
HARDWARE
-------------------
:1 1 0 ~ 1 0 0 0: IN1qur ?fC8
UART DATA PORT
*Command Write
:1 1 0 1 1 0 0 0: our AxDs
:cLS2:CLS1lPI:EPE:ses:
Pl PARITY INHIBIT
0 Generate parity and check
1 Inhibit generating parity
- 254 -
HARDWARE
and check
- 255 -
HARDWARE
*Status read
:1 1 0 1 1 0 0 0: IN AXO8
..i
----------------- - .....
7 4 3 2 1 0
0 On
1 Off
OE Overrun Error
1 Detected
FE Framing Error
1 Detected
PE Parity Error
1 Detected
- 256 -
HARDWARE
:1 1 1 0 1 0 0 0: IN -.iXE8~ .
:1 1 1 1 1 1 1 0: IN/OUT AXFE
* Data Write/Read
:1 1 1 1 1 1 1 1: IN/OUT AXFF
- 257 -