home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
dpl.zip
/
DPL.DOC
< prev
next >
Wrap
Text File
|
1988-07-13
|
34KB
|
829 lines
================================
Doug's Programming Language
================================
TABLE OF CONTENTS
1. What's needed
Hardware required.
Programs you must supply.
Installing the code on a hard drive.
Compiling the sample programs.
2. Basic program structure
3. Data declarations
Predefined global variables
DEFINE declaration
ENDREC declaration
FILE declaration
INTEGER declaration
RECORD declaration
SET declaration
STRING declaration
4. Executable Instructions
CURSOR int,int
CALL routine param-1 param-2 param-3 param-4
CLOSE file
DECODE string,integer
ENCODE integer,string
GOTO addr
HSTOI integer,string
IF...
INKEY str,WAIT
ITOBS string,integer,length
ITOHS string,integer
MATH EXPRESSIONS
NOTE file,dd
OPEN INPUT, file
POINT file,dd
READ file,string,length
READB file,record
RETURN
STOP
STRING CONCATENATION
WRITE file,string
WRITEB file,record
5. Bibliography
M╙á DO╙á anΣá Macr∩á Assembler¼á aka¼á MASM¼á arσá trademark≤á oµ ì
Microsoft corporation.
èDoug's Programming Language -- DPL, Version 2.22
Copyright (c) 1988 Douglas S. Cody, All rights reserved.
.paè W h a t 's N e e d e d
Hardware Required.
The minimal system configurable recommended to use DPL is:
IBM PC or Compatible w/256k ram.
MS, PC DOS 2.0 or higher.
2 floppy disk drives.
Monochrome or CGA video adapter & monitor.
The optimal system configurable recommended to use DPL is:
IBM PC or Compatible w/640k ram.
MS, PC DOS 2.0 or higher.
1 floppy disk drive and a hard drive of
ten megabytes, or higher.
Monochrome, CGA, EGA video adapter & monitor.
Programs You Must Supply.
Iε orde≥ t∩ program¼á assemble¼á anΣ ruε program≤ writteε iε ì
DPL¼ thσ followinτ program≤ mus⌠ bσ madσ available:
Microsoft MASM, MAKE, LINK, and LIB, versions 3.0
through 5.0.
Thesσá program≤ wil∞ havσ t∩ bσ iε thσ curren⌠ director∙á o≥ ì
iε thσ "PATH". See your DOS manual for setting "PATH"s.
Installing the Code on a Hard Drive.
Thσ DP╠ releasσ diskettσ contain≤ tw∩ batcΦ file≤ fo≥ movinτ ì
thσá wholσ releasσ t∩ ß targe⌠ diskettσ o≥ harΣ drive«á Thσ firs⌠ ì
batcΦ filσ i≤ called¼á "MOVE.BAT"«á I⌠ wil∞ cop∙ al∞ thσ corσ DP╠ ì
routine≤á anΣá suppor⌠ file≤ t∩ ß giveεá drive\path«á Thσá seconΣ ì
batcΦá filσ i≤ called¼á "MOVEAPP.BAT"¼á anΣ i⌠ contain≤á al∞á thσ ì
samplσ applicatioε routines¼á programs¼á anΣ suppor⌠ files«á EacΦ ì
batch file is invoked like the following example:
C:\DPL>MOVE A:
C:\DPL>MOVEAPP A:
Thσá paramete≥á followinτ thσ batcΦ filσ namσ indicate≤á thσ ì
target [drive][path] that the will receive the DPL files.
To create a backup of the release from drive A: to drive B:
1. Install a blank, formatted diskette in drive B:
2. Install the DPL release diskette in drive A:è 3. At the DOS prompt, type "A:" and the ENTER key.
4. Type "MOVE B:" and the ENTER key. All the core
routines, libraries & support files will be copied.
5. Type "MOVEAPP B:" and the ENTER key. All the application
routines, programs & support file will be copied.
To copy the release from drive A: to the hard drive, C:.
1. If the current disk is not drive C, then type "C:"
and the ENTER key.
2. If the current disk is drive C, then type "CD\"
and the enter key.
3. Type "MKDIR DPL" and the ENTER key.
4. Type "CD DPL" and the ENTER key.
5. Install the DPL release diskette in drive A:
6. Type "A:" and the ENTER key.
7. Type "MOVE C:" and the ENTER key. All the core
routines, libraries & support files will be copied.
8. Type "MOVEAPP C:" and the ENTER key. All the application
routines, programs & support file will be copied.
Compiling the Sample Programs.
U S I N G F L O P P Y D I S K S
Fo≥ thosσ oµ yo⌡ usinτ onl∙ tw∩ flopp∙ disks¼ you'l∞ wan⌠ t∩ ì
creatσá ß specia∞ developmen⌠ diskettσ containinτ onl∙ thσá file≤ ì
needeΣ t∩ develo≡ code«á Thσ batcΦ filσ named¼ "MOVEDEV.BATó wil∞ ì
cop∙ thosσ file≤ t∩ ß targe⌠ drive« Follo≈ thσ instruction≤ belo≈ ì
t∩ creatσ thi≤ specia∞ disk:
1. Install the DPL release diskette in drive A:
2. Install a blank, formatted diskette in drive B:
3. At the DOS prompt, type "A:" and the ENTER key.
4. Type "MOVEDEV B:" and the enter key. All the required
files will be copied to this diskette.
5. Copy any DPL source files, such as, LIST.D, to drive B:
Oncσá thσ developmen⌠ diskettσ i≤ finished¼á inser⌠ i⌠á int∩ ì
drivσá A:«á Placσá thσ diskettσ contaiεá Microsoft'≤á MASM.EX┼á ª ì
LINK.EX┼ int∩ drivσ B:«á A⌠ thσ DO╙ prompt¼á typσ "PATH=B:\;ó anΣ ì
thσ returε key« Thi≤ allow≤ thσ Microsof⌠ softwarσ t∩ bσ founΣ b∙ ì
DO╙á wheεá attemptinτ t∩ compilσ thσ DP╠ programs«á Yo⌡á arσá no≈ ì
read∙ t∩ compilσ somσ code«á Thσ DP╠ samplσ program¼ "LIST.Dó ha≤ ì
beeεá copieΣ t∩ thσ developmen⌠ diskettσ t∩ allo≈ yo⌡ t∩ practicσ ì
compiling«á T∩ compilσ thi≤ program¼ type¼ "─ LISTó anΣ thσ ENTE╥ ì
key. Thσá batcΦá file¼áá "D.BATóá wil∞á invokσá thσá DP╠á prepas≤ ì
compiler¼ MASM¼ theε LINK.
Oncσ thσ compilσ i≤ done¼ thσ DO╙ promp⌠ wil∞ return.
è
U S I N G H A R D D R I V E
Iµá yo⌡á arσá usinτ ß harΣ disδ drive¼á you'rσ iεá thσá bes⌠ ì
developmen⌠ environment« Thi≤ allow≤ yo⌡ t∩ storσ al∞ DP╠ codσ iε ì
onσá subdirectory¼á anΣá al∞á thσ Microsof⌠á codσá iεá it'≤á sub-ì
directory«á Placσ thσ patΦ t∩ thσ Microsof⌠ softwarσ iε thσ envi-ì
ronmen⌠á PAT╚á b∙ typinτ "PATH=\[MAS═ PATH]ó a⌠ thσá DO╙á prompt« ì
Oncσ thi≤ i≤ done¼á ente≥ thσ DP╠ subdirectory¼á anΣ you'rσ read∙ ì
t∩á work«á Assuminτ al∞ thσ codσ ha≤ beeε installeΣ iε thi≤á sub-ì
directory¼á type¼á "─á LISTó anΣ thσ ENTE╥ key«á Thσ batcΦá file¼ ì
"D.BATóá wil∞ invokσ thσ DP╠ prepas≤ compiler¼á MASM¼á theε LINK« ì
Oncσ thσ compilσ i≤ done¼ thσ DO╙ promp⌠ wil∞ return.
.paè B a s i c P r o g r a m S t r u c t u r e
DPL i≤ ß macr∩ languagσ usinτ higΦ leve∞ languagσ synta° fo≥ it'≤ ì
instructions«á I⌠ doe≤ no⌠ limi⌠ thσ programme≥ froφ usinτ nativσ ì
8088áá code¼áá bu⌠á make≤á programminτá easie≥á b∙á automaticall∙ ì
declarinτá segment≤ anΣ thσ prograφ entrypoint«á Comment≤ ma∙á bσ ì
declareΣá iε standarΣ 808╕ fashioε b∙ placinτ ß semi-coloε t∩ thσ ì
lef⌠ oµ thσ comment'≤ bod∙ oµ text«á Thσ basiπ prograφá structurσ ì
i≤ a≤ follows:
PROG NAME
;
; data goes here
;
BEGIN NAME
;
; code goes here
;
ENDPGM NAME
Thσ keyworΣ "PROGó declare≤ thσ beginninτ oµ thσ prograφ anΣ ì
open≤ u≡ thσ datß segment«á Thσ datß segmen⌠ wil∞ continuσá unti∞ ì
thσá keyworΣ "BEGINó i≤ encountered«á Oncσ "BEGINó i≤ found¼á thσ ì
datß segmen⌠ i≤ endeΣ anΣ thσ codσ segmen⌠ wil∞ begin«á Thσá codσ ì
segmen⌠ wil∞ bσ endeΣ wheε thσ keyworΣ "ENDPGMó i≤ encountereΣ a⌠ ì
thσá enΣá oµ thσ sourcσ file«á Iε betweeε thσ datß anΣ codσá seg-
ments¼ thσ stacδ segmen⌠ i≤ declareΣ usinτ ß 25╢ word stack.
Thi≤ maiε procedurσ i≤ declareΣ a≤ ß "FARó procedurσ anΣá i≤ ì
thσ entrypoin⌠ fo≥ thσ program«á Anothe≥ valiΣ wa∙ oµ declarinτ ß ì
prograφá i≤ usinτ thσ keyword¼á "SUBPGMó iε lie⌡ oµ "PROG"«á Thi≤ ì
wil∞á givσá thσá prograφ ß publiπ namσ a≤á wel∞á a≤á declarσá thσ ì
entrypoin⌠ t∩ bσ ß NEA╥ procedure«
Thσá NAM┼á oµá thσá prograφ caε bσ an∙á name¼á bu⌠á mus⌠á bσ ì
declareΣá threσ time≤ iε thσ program«á Thσ NAM┼ declaratioεá mus⌠ ì
follo≈ the keywords¼ PROG¼ SUBPGM¼ BEGIN¼ anΣ ENDPGM.
Thσá followinτá arσ tw∩ example≤ oµá thσá shortes⌠á program≤ ì
writteε iε DPL:
Example #1 : Example #2
:
PRO╟ NAM┼ ║ SUBPG═ NAME
; : ;
BEGIN NAME : BEGIN NAME
; : ;
ENDPGM NAME : ENDPGM NAME
Sincσá DP╠ control≤ thσ segmen⌠ declarations¼á thσ prograφ i≤ ì
limiteΣ t∩ 64δ oµ code¼á 64δ oµ data¼á anΣ 64δ oµ stacδá segment« ì
Othe≥ segment≤ ma∙ bσ declared¼ bu⌠ wil∞ bσ nesteΣ dependinτ upoε ì
location«á Iµá ß segmen⌠ i≤ declareΣ withiε thσ boundarie≤ oµ thσ ì
"PROG/SUBPGMó anΣ "BEGINó statement¼ i⌠ wil∞ bσ nesteΣ withiε thσ ì
datß segment«á Likewise¼á iµ thσ segmen⌠ i≤ declareΣ betweeεá thσ ì
"BEGINó anΣ "ENDPGMó statement¼ i⌠ wil∞ bσ nesteΣ withiε thσ codσ ì
segment.
.PAè D a t a D e c l a r a t i o n s
DP╠á support≤á simplσ datß types¼á bu⌠ doe≤á no⌠á limi⌠á thσ ì
programme≥á froφá buildinτá othe≥ types«á Thσá basiπá datßá type≤ ì
supporteΣá arσá 1╢ bi⌠ integer≤ anΣ ASCII┌ strings«á Thσá 1╢á bi⌠ ì
integer≤á arσ considereΣ t∩ bσ signeΣ integer≤ anΣ thereforσ wil∞ ì
bσ manipulateΣ appropriately« File≤ arσ supporteΣ whicΦ allo≈ thσ ì
prograφá t∩ addres≤ an∙ disδ filσ o≥ logica∞ device¼á sucΦ a≤ thσ ì
keyboarΣ o≥ screen.
Predefined Global Variables
DP╠ declare≤ certaiε commoε variable≤ fo≥ thσ programmer« A≤ ì
oµá thi≤á revision¼á thσ followinτá variable≤á arσá automaticall∙ ì
declared:
SE╘ STATUS,0░ ╗ 1╢ bi⌠ intege≥ whicΦ contain≤ thσ
; return result of various reads
; and writes.
SE╘ ZERO,0░á ╗ ┴ intege≥ácontaininτáßázer∩ value.
DEFINE BEEP,07 ; ASCII Bell alarm (^G)
DEFINE EJECT,12 ; ASCII Form Feed (^L)
SE╘á @DPLVE╥ ╗ Curren⌠ versioε oµ DP╠ásuppor⌠
; routines
VIDPAGE DB ? ; Current active video page
CRTFLAG DB ? ; A byte indicating which video
; adapter is installed:
; Monochrome = 00
; CGA card = 01
; EGA Mono emul = 02
; EGA CGA emul = 03.
; Bit 0 = Monochrome(0),CGA(1)
; Bit 1 = EGA(1)
; Bit 2 = VGA(not implemented yet)
Thσá keyword¼á "STATUS"¼á i≤á maintaineΣ b∙ DP╠ t∩ returεá thσ ì
resul⌠á oµ an∙ attempteΣ reaΣ o≥ writσ usinτ DOS«á Thσá followinτ ì
error codes are returned in STATUS from IO:
0 = All okay 10 = Invalid environment
1 = End of File encountered 11 = Invalid format
2 = File not found 12 = Invalid access code
3 = Path not found 13 = Invalid data
4 = No handle available, all used 14 = not used
5 = Access denied 15 = Invalid drive specified
╢ ╜ invaliΣ handlσ 1╢ ╜ Attemp⌠ t∩ removσ
7 = Memory control block destroyed directory
╕ ╜ Insufficien⌠ memor∙ 17 = Not same device
9 = Invalid memory block address 1╕ ╜ N∩ morσ file≤ to be
found
Iµá yo⌡ havσ no⌠ noticed¼á al∞ thσ returε codes¼á excep⌠ #1¼á arσ ì
standarΣá DO╙ returε codes«á Codσ #▒ serve≤ ßá dua∞á purpose«á Iε ì
read≤á anΣ writes¼á thi≤ valuσ woulΣ indicatσ aε EOF«á Iε openinτ ìèanΣá closinτ files¼á i⌠ retain≤ it≤ origina∞ DO╙á meaning«á Sincσ ì
STATU╙á i≤á jus⌠ ß 1╢ bi⌠ integer¼á i⌠ ma∙ als∩ bσá useΣá b∙á thσ ì
programmer¼ fo≥ example¼ t∩ holΣ ß returε codσ froφ ß subroutine.
D E F I N E -- pre-initialized string declaration
DEFINE msg0,'This is the first message declared'
DEFINE BEEP,07
DEFINE ESC_SEQ,<1BH,'[31;40m'> ; ANSI.SYS ESC sequence
Thσá datßá declaration¼á "DEFINEóá allow≤á thσá programme≥á t∩ ì
declarσ ß strinτ witΦ ß pre-initializeΣ value«á Thi≤ strinτá wil∞ ì
havσ it'≤ maximuφ lengtΦ determineΣ b∙ thσ lengtΦ oµ thσ message« ì
Thσá seconΣ examplσ abovσ show≤ ho≈ t∩ declarσ ß onσ bytσá strinτ ì
usinτ aε ASCII contro∞ characte≥ value«á Thσ lengtΦ oµ thσ strinτ ì
wil∞á bσá thσ datß lengtΦ ½ 1«á Thσá DEFIN┼á macr∩á automaticall∙ ì
provide≤ ß nul∞ bytσ a≤ ß strinτ terminator«á This¼ anΣ al∞ othe≥ ì
datßá declarations¼á mus⌠á precedσá thσá "BEGINóá statement«á Thσ ì
maximuφá lengtΦ i≤ determineΣ b∙ MASM's limitations.
E N D R E C -- End of record marker
RECORD recname,length
STRING strname,length
INTEGER num
ENDREC recname
Thσ ENDRE├ declaratioε mark≤ thσ enΣ oµ thσ datß record«á I⌠ ì
i≤á useΣá iεá conjunctioεá witΦá thσá RECOR─á declaration«áá Thi≤ ì
statemen⌠á mus⌠á alway≤ bσ useΣ t∩ terminatσ ß recorΣá t∩á insurσ ì
correc⌠ memor∙ allocatioε fo≥ thσ entirσ record«á This¼á anΣá al∞ ì
othe≥ datß declarations¼ mus⌠ precedσ thσ "BEGINó statement.
F I L E -- Define a file device
FILE CONSL, 'CON'
FILE PRT, 'LPT1', A
FILE AFILE, 'WORK.DAT', A, BUFFA
FILE DSKFIL, 'WORK.DAT', B
FILE BFILE, 'WORK.DAT', B, BUFFB
FILE RNDFIL, 'WORK.DAT', R, RKEY
BUFFER BUFFA,512
BUFFER BUFFB,512
INTEGER RKEY
Thσá filσ declaratioε set≤ u≡ ß filσ declaratioε fo≥ accessinτ ì
DO╙ devices«á Thσ declaratioε come≤ iε fivσ parts║ 1⌐ thσ keyworΣ ì
FILE¼á 2⌐á thσá interna∞á namσ oµ thσ devicσ t∩ bσá useΣá b∙á thσ ì
program¼ 3⌐ thσ externa∞ ASCII┌ strinτ namσ giveε t∩ DO╙ wheε thσ ì
filσá i≤á opened¼á 4⌐á thσá devicσ class¼á anΣ 5⌐á ßá buffe≥á fo≥ ì
sequentia∞ files¼á o≥ recorΣ KE┘ fo≥ randoφ files«á Thσ differen⌠ ìèpart≤á arσ separateΣ b∙ commas«á Thσ devicσ clas≤á indicate≤á thσ ì
typσ oµ datß expecteΣ t∩ bσ writteε o≥ reaΣ froφ thσ device/file« ì
Thσá fou≥á classe≤ arσ "Aó fo≥ ASCII¼á "Bó fo≥á binary¼á "Róá fo≥ ì
randoφ access¼ anΣ defaul⌠ fo≥ characte≥ device≤ (defaul⌠ assume≤ ì
variablσ lengtΦ ASCII)« Thσ file≤ classes¼ "A"¼ "B"¼ anΣ default¼ ì
arσáá sequentia∞áá acces≤á files«áá Buffer≤á oµá 25╢á byte≤áá arσ ì
automaticall∙ declareΣ fo≥ "Aó anΣ "Bó filσ types« Thσ programme≥ ì
ma∙á declarσ differen⌠ buffer≤ fo≥ filσ classe≤ "Aó anΣá "B"¼á a≤ ì
seeεá iεá thσá abovσ example≤ fo≥ "AFILEó anΣá "BFILE"«á Thi≤á i≤ ì
useful¼á fo≥á examplσá t∩ speedu≡ disδ I/╧á b∙á declarinτá large≥ ì
buffers¼ thu≤ requestinτ fewe≥ read≤ froφ DOS.
NOTE!!íá Thσ buffe≥ sizσ represent≤ thσ larges⌠ singlσ piecσ ì
oµ datß whicΦ ma∙ bσ reaΣ froφ thσ file╗á therefore¼á iε orde≥ t∩ ì
reaΣ string≤ o≥ record≤ ove≥ 25╢ byte≤ iε length¼á thσ programme≥ ì
MUS╘á providσ ß buffe≥ a⌠ leas⌠ thσ sizσ oµ thσ larges⌠ strinτ o≥ ì
recorΣ t∩ bσ reaΣ froφ that file.
Randoφá acces≤ file≤ havσ ß KE┘ declaration«á Thσ ke∙á i≤á ß ì
namσ oµ aε intege≥ t∩ bσ useΣ iε recorΣ locatioε calculations« T∩ ì
acces≤á ß giveε recorΣ iε ß randoφ file¼á pu⌠ thσ recorΣ locatioε ì
numbe≥á int∩á thσá ke∙ theε reaΣ o≥ writσ t∩ thσá file«á Thσá ke∙ ì
numbe≥á i≤ simila≥ iε functionalit∙ t∩ aεá array'≤á subscript«á ┴ ì
gooΣá perspectivσá oµ ß randoφ filσ i≤ t∩ vie≈ i⌠ a≤ aε arra∙á oµ ì
records¼á wherσá thσá ke∙á i≤ thσ subscrip⌠á t∩á thσá array«á Thσ ì
followinτá codσ segmen⌠ show≤ ho≈ t∩ reaΣ thσ 5tΦ recorΣá froφá ß ì
file:
;---------------╝áDATA VARIABLES >----------------
FILE RFILE,'DATA.FIL',R,RKEY
INTEGER RKEY
;
RECORD RREC,13
STRING STR,8
INTEGER NUM
ENDREC RREC
;---------------╝áCOD┼áEXECUTIO╬ >----------------
RKEY = 5
READB RFILE,RREC
;-------------╝áEND COD┼áEXECUTIO╬ >--------------
Thσ subscrip⌠ t∩ thσ file¼á RKEY¼á i≤ se⌠ t∩ thσ valuσ oµ 5«á Thσ ì
read or write can then be attempted by the program.
I N T E G E R -- 16 bit integer declaration
INTEGE╥ num0
Thσá intege≥á declaratioεá set≤ u≡ ß 1╢ bi⌠ worΣ iεá thσá datß ì
segmen⌠ withou⌠ ß predefineΣ value«á I⌠ i≤ initializeΣ t∩ zer∩ b∙ ì
thσ macr∩ statement«á This¼ anΣ al∞ othe≥ datß declarations¼ mus⌠ ì
precede the "BEGIN" statement.è
R E C O R D -- File record declaration
RECORD recname,length
STRING strname,length
INTEGER num
ENDREC recname
Thi≤á declaratioε identifie≤ thσ "recnameó a≤ thσá beginninτ ì
oµ ß datß record« Thσ abovσ examplσ show≤ ho≈ t∩ declarσ ß recorΣ ì
witΦá onσá strinτá elemen⌠ anΣ onσ intege≥á element«á Thσá ENDRE├ ì
statemen⌠ mus⌠ bσ addeΣ t∩ terminatσ thσ recorΣ declaration«á Seσ ì
thσ sectioε oε ENDREC« Thσ lengtΦ giveε iε thσ RECOR─ declaratioε ì
i≤á thσ tota∞ lengtΦ oµ al∞ variablσ element≤ withiε thσá record« ì
STRIN╟á length≤á arσá alway≤ arσ ▒ greate≥á thaεá therσá declareΣ ì
length«á INTEGER╙á arσ tw∩ byte≤ iε length«á RECORD≤ declaration≤ ì
ma∙ no⌠ bσ nested«á This¼á anΣ al∞ othe≥ datß declarations¼á mus⌠ ì
precedσáá thσá "BEGINóá statement«áá Seσá thσá sectioεá oεáá FIL┼ ì
declarations for more on record size limitations.
S E T -- 16 bit integer declaration
SET ONE,1
SET X99,99
Thσá SE╘ declaratioε set≤ u≡ ß signeΣ 1╢ bi⌠ worΣ witΦ ßá pre-ì
defineΣ value« I⌠ i≤ identica∞ t∩ thσ INTEGE╥ declaration¼ excep⌠ ì
thσ programme≥ supplie≤ aε initia∞ valuσ t∩ thσ word«á This¼á anΣ ì
al∞ othe≥ datß declarations¼ mus⌠ precedσ thσ "BEGINó statement.
S T R I N G -- Undefined string declaration
STRING name,length
STRING wor_string,132
Thσá STRIN╟ declaratioε allow≤ thσ operato≥ t∩ declarσ ßá nul∞ ì
string¼á ╪á numbe≥ oµ byte≤ iε length«á Thσ tota∞ lengtΦá oµá thσ ì
strinτ i≤ thσ lengtΦ ½ 1«á This¼ anΣ al∞ othe≥ datß declarations¼ ì
mus⌠á precedσá thσ "BEGINó statement«á Thσ maximuφ lengtΦ ma∙á bσ ì
u≡ t∩ 64k¼á bu⌠ remember¼á DP╠ onl∙ provide≤ ON┼ datß segmen⌠á oµ ì
u≡á t∩á 64k╗á therefore¼á sucΦá ß strinτ woulΣá fil∞á thσá entirσ ì
segment«á Seσ thσ sectioε oε FIL┼ declaration≤ fo≥ morσ oε strinτ ì
lengths.
.paè E X E C U T A B L E I N S T R U C T I O N S
C U R S O R -- Move the video cursor.
CURSOR 1,5
CURSOR 1,int
CURSOR int,int
CURSOR row,col
Thi≤ instructioε move≤ thσ vide∩ curso≥ t∩ thσ X/┘á coordinatσ ì
giveεá b∙ thσ parameters«á Thσ parameter≤ ma∙ bσ eithe≥ ß numeriπ ì
litera∞ o≥ intege≥ iε an∙ combination«á Thσ valiΣ row≤ arσ ░ thr⌡ ì
24«á Thσ valiΣ column≤ arσ ░ thr⌡ 79« B∙ movinτ thσ curso≥ ou⌠ oµ ì
thσ valiΣ range≤ effectivel∙ make≤ thσ cursor disappear.
C A L L -- DPL call with parameter passing in registers.
CALL routine param-1 param-2 param-3 param-4
CALL CALC 05 NUM
Thσá DP╠á pre-pas≤ compile≥ examine≤ eacΦ CAL╠ statemen⌠á iε ì
thσ sourcσ filσ lookinτ fo≥ paramete≥ passinτ t∩ thσá subroutine« ì
Parameter≤ ma∙ bσ listeΣ t∩ thσ righ⌠ oµ thσ subroutinσ namσ witΦ ì
space≤á betweeεá eacΦ one«á Thσ parameter≤ passeΣ arσá placeΣá iε ì
register≤á AX,BX,CX,D╪á respectively«á ▒á - ┤ parameter≤á ma∙á bσ ì
passeΣ t∩ thσ subroutine«á NOTE║á Paramete≥ passinτ i≤ limiteΣ t∩ ì
passinτ thσ ADDRES╙ oµ thσ variable¼á NO╘ thσ actua∞ valuσ oµ thσ ì
variable«á Thi≤á differ≤ witΦ somσ commoε programminτá languages¼ ì
sucΦ a≤ ├ anΣ PASCAL«á Sincσ DP╠ doe≤ no⌠ maintaiε tigh⌠á contro∞ ì
ove≥á variablσá declarations¼á i⌠á doe≤ no⌠ kno≈á thσá differencσ ì
betweeεá strinτá variablσá name≤á anΣá intege≥á variablσáá names╗ ì
therefore¼á i⌠á applie≤ ß blanke⌠ rulσ oµ passinτ addresse≤ only« ì
Litera∞áá value≤á arσá thσá exceptioεá anΣá arσá passeΣá t∩áá thσ ì
subroutine«á Thσá litera∞á value≤ arσ limiteΣá t∩á aεá expressioε ì
resultinτ iε ß 1╢ bi⌠ value.
C L O S E -- Close a file.
CLOSE file
Thi≤ functioε close≤ ß previousl∙ openeΣ file«á Iµ thσ filσ wa≤ ì
openeΣ fo≥ output¼á anΣ enΣ oµ filσ marδ i≤ writteε anΣ thσá filσ ì
i≤ closed« Al∞ pertinen⌠ datß i≤ theε entereΣ int∩ thσ directory« ì
Iµ thσ filσ wa≤ openeΣ fo≥ input¼ thσ filσ wil∞ bσ closeΣ witΦ n∩ ì
change≤ t∩ thσ directory«á Oncσ ß filσ i≤ closed¼á n∩ morσ acces≤ ì
wil∞á bσ alloweΣ unti∞ i⌠ i≤ reopened«á Thσ appropriatσ DO╙ erro≥ ì
codσ wil∞ returned in STATUS.
.paèD E C O D E -- Convert decimal ASCIIZ string to signed binary
integer format.
DECODE integer,string
DECOD┼á wil∞ conver⌠ ß numeriπ ASCI╔ strinτ int∩ ßá signeΣá 1╢ ì
bi⌠á intege≥á value«á Thσá valuσ wil∞ bσ storeΣ iεá thσá provideΣ ì
integer«á Thσ conversioε wil∞ bσ madσ froφ lef⌠ t∩ righ⌠ anΣ wil∞ ì
continuσá unti∞ ß noε numeriπ ASCI╔ characte≥ o≥ enΣ oµá linσá i≤ ì
encountered« ValiΣ numeriπ ASCI╔ character≤ fal∞ withiε thσ rangσ ì
oµ '0º - '9'«á ┴ negativσ sigε i≤ alloweΣ t∩ thσ righ⌠ o≥ lef⌠ oµ ì
thσ numbers« Iµ ß non-numeriπ valuσ i≤ encountered¼ ┴ STATU╙ oµ ▒ ì
wil∞ bσ returneΣ and the integer will be set to zero.
E N C O D E -- Convert signed binary integer to ASCIIZ
decimal string.
ENCODE string,integer
Thi≤á instructioεá wil∞ conver⌠ ß signeΣ 1╢ bi⌠ valuσ int∩á aε ì
ASCII┌ strinτ representation« Thσ maximuφ lengtΦ oµ thσ converteΣ ì
strinτ caε bσ ╢ characters¼á therefore╗ thσ targe⌠ strinτ mus⌠ bσ ì
ßá minimuφ oµ ╢ character≤ iε orde≥ t∩ protec⌠ agains⌠ corruptinτ ì
memor∙á followinτ thσ string«á Thσ actua∞ decima∞á representatioε ì
createΣá b∙ ENCOD┼ ma∙ bσ les≤ thaε ╢ character≤ iεá length«á An∙ ì
value over 32767 will be considered negative.
G O T O -- Unconditional jump.
GOTO addr
Thσá GOT╧ commanΣ i≤ converteΣ int∩ aε 808╕ 'JMPº instruction« ì
Thσá rangσ oµ thσ jum≡ wil∞ bσ intra-segment¼á unles≤ thσá targe⌠ ì
addres≤ i≤ ß FA╥ type«á Therσ wil∞ no⌠ bσ an∙ checδ t∩ seσ iµ thσ ì
targe⌠á addres≤á caε bσ reacheΣ b∙ ß shor⌠á jump«á Thi≤á forφá oµ ì
optimization will normally be done by the assembler.
H S T O I -- Hex string to integer conversion.
HSTOI integer,string
Thi≤á instructioε wil∞ conver⌠ ß HE╪ strinτ int∩ ßá signeΣá 1╢ ì
bi⌠ binar∙ value«á Thσ conversioε wil∞ operatσ froφ lef⌠ t∩ righ⌠ ì
anΣá wil∞ enΣ wheε ß non-he° characte≥ ("0"-"9"¼á o≥ "a"-"f"⌐á o≥ ì
enΣ oµ linσ i≤ encountered.
╔á╞á -- Conditiona∞ jum≡ suppor⌠ fo≥ábyte¼áword¼áo≥
strinτ comparisons.
IF BYTE addr EQ addr GOTO addr
IF BYTE addr LT addr CALL addr param param param paramè IF BYTE addr EQ addr RETURN
IF WORD addr LE addr GOTO addr
IF WORD addr NE addr CALL addr param param
IF WORD addr EQ addr RETURN
IF STRING addr EQ addr GOTO addr
IF STRING addr NE addr CALL addr param param param param
IF STRING addr EQ addr RETURN
Thσá DP╠á I╞ statemen⌠ give≤ thσ programme≥ thσá capabilit∙á t∩ ì
makσ comple° comparisoε witΦ ease«á Thσ I╞ statement≤ cove≥ ever∙ ì
typσ oµ comparisoε anΣ condition« ┴ truσ resul⌠ t∩ thσ comparisoε ì
alway≤á result≤ iε ß changσ t∩ thσ prograφ counter«á Thσ instruc-ì
tioε followinτ thσ comparison¼á GOTO¼á CALL¼á o≥ RETUR╬ arσá al∞ ì
standarΣá DP╠ instructions«á Seσ eacΦ sectioε fo≥ detail≤ oεá thσ ì
synta° oµ eacΦ oµ thσ instructions.
Thσá I╞á statement≤ allo≈ ß ful∞ rangσ oµ test≤ t∩ bσ madσá fo≥ ì
intege≥á comparisons«á Strinτ comparison≤ arσ limiteΣ t∩ "EQóá o≥ ì
"NEó tests« The following is a explanation of each comparison:
NE - Not equal to
LT - Less than
LE - Less than or equal to
EQ - Equal to
GE - Greater than or equal to
GT - Greater than
I N K E Y -- Scan the keyboard for one character
INKEY
INKEY str
INKEY str,WAIT
INKEY ,WAIT
Thi≤á instruction≤á use≤ thσ BIO╙ keyboarΣá interrup⌠á 16╚á t∩ ì
retrievσá ß typeΣ key«á A≤ thσ abovσ example≤á show¼á thσá targe⌠ ì
strinτá i≤á optional«á Thσá returneΣ valuσ i≤ storeΣá iεá thσá A╪ ì
registe≥á upoεá returε froφ thσ BIO╙ call.
Thσá firs⌠á tw∩ example≤ wil∞ no⌠ sto≡ thσ executioε oµá thσ ì
program¼á whereas╗á thσá las⌠ tw∩ example≤ wai⌠ fo≥ ß ke∙á t∩á bσ ì
typed« Thσ DP╠ keyworΣ STATU╙ wil∞ bσ se⌠ t∩ ▒ iµ ß ke∙ i≤ found¼ ì
otherwise╗á i⌠á wil∞á bσ se⌠ t∩ 0«á Thσ targe⌠ strinτ mus⌠á bσá ß ì
minimuφ oµ ▓ byte≤ long« Tw∩ byte≤ wil∞ bσ returneΣ froφ thσ BIO╙ ì
anΣá storeΣá iε thσ string«á Thσ firs⌠ bytσ wil∞ bσ thσá "normaló ì
key¼ sucΦ a≤ thσ lette≥ "A"« Iε thi≤ casσ thσ seconΣ bytσ wil∞ bσ ì
reporteΣ a≤ ß binar∙ zero«á Thσ seconΣ bytσ reporteΣ i≤ thσá scaε ì
code«á Iµá thσá ke∙ wa≤ ß functioε key¼á thσ firs⌠ bytσá wil∞á bσ ì
binar∙ zero¼ anΣ thσ seconΣ bytσ wil∞ bσ thσ scaε code.
.paèI T O B S -- Convert binary integer to Binary string
ITOBS string,integer,length
ITOBS string,0255h,8
Thi≤á commanΣ convert≤ ß 1╢ bi⌠ intege≥ int∩ ß strinτ oµá "0"≤ ì
anΣ "1"≤ fo≥ ß binar∙ representation« Thσ lengtΦ oµ thσ strinτ i≤ ì
determineΣ b∙ thσ lengtΦ declaration«á A≤ aε example¼ iµ jus⌠ thσ ì
leas⌠á significan⌠á bytσ oµ thσ 1╢ bi⌠ worΣ i≤ t∩á bσá converted¼ ì
jus⌠ givσ thσ instructioε aε ╕ bytσ lonτ length«á Thσ intege≥ ma∙ ì
bσ ß address o≥ ß litera∞ value.
I T O H S -- Convert binary integer to ASCII hex string
ITOHS string,integer
ITOHS string,0256
Thi≤á commanΣ wil∞ takσ ß 1╢ bi⌠ intege≥ valuσ aε creatσ ßá ┤ ì
bytσá he° string«á Thσ targe⌠ strinτ mus⌠ bσ ß minimuφ oµ ┤ byte≤ ì
iε length¼ o≥ ß memory overrun will occur.
═ ┴ ╘ ╚ -- DP╠ámatΦ routine≤áfo≥áarithmeticáanΣ Boolean
expressioε evaluation
result = int * 05 + int / 2 - 3 SHL 2 MOD 256
DP╠ provide≤ fo≥ signeΣ 1╢ bi⌠ mathematica∞ expression≤ witΦ ß ì
simplσ lef⌠ t∩ righ⌠ evaluation«á Thσ lengtΦ oµ thσ expressioε i≤ ì
limiteΣá t∩á ß maximuφ strinτ oµ 13▓á characters«á Thσá followinτ ì
mathematical operations are valid:
* Multiplication / Division
+ Addition - Subtraction
AND Logical And OR Logical OR
XOR Exclusive OR SHL Shift left
SHR Shift Right MOD Remainder
N O T E -- Note the current file pointer.
NOTE file,dd
Thi≤á instructioε retrieve≤ thσ curren⌠ filσ pointe≥ froφá thσ ì
specifieΣá filσ anΣ store≤ i⌠ iε thσ specifieΣ 3▓ bi⌠á lonτá worΣ ì
storage«á Thi≤á instructioε i≤ useΣ iε conjunctioε witΦ thσ POIN╘ ì
instructioεá t∩á creatσá ßá limiteΣ forφá oµá randoφá acces≤á fo≥ ì
sequentia∞á disδá files«áá B∙á "NOTE"inτá ßá file¼áá theεá later¼ ì
"POINT"inτ t∩ it¼ datß ma∙ bσ rereaΣ o≥ rewritten.
.paèO P E N -- Open a file
OPEN INPUT, file
OPEN OUTPUT, file
OPEN IO, file
DP╠á use≤ thσ DO╙ filσ handlσ methoΣ oµ filσ control«á Wheεá ß ì
filσá i≤ opened¼á DO╙ return≤ ß handlσ whicΦ wil∞á bσá associateΣ ì
witΦ tha⌠ filσ unti∞ i⌠ i≤ CLOSED«á Thσ allowablσ mode≤ oµ acces≤ ì
fo≥ file≤ arσ INPUT¼ OUTPUT¼ or¼ IO.
Iε orde≥ t∩ acces≤ an∙ oµ thσ computer≤ devices¼á usinτ ß filσ ì
i≤ thσ easies⌠ method« Thσ logica∞ devicσ fo≥ thσ screen/keyboarΣ ì
('CON'⌐á ma∙á bσ openeΣ a≤ INPUT¼á OUTPUT¼á o≥á IO«á Thσá printe≥ ì
('LPTx'⌐á woulΣ bσ openeΣ a≤ OUTPUT«
Iµ ß disδ filσ i≤ openeΣ a≤ IO¼á DP╠ attempt≤ t∩ opeε thσ filσ ì
withou⌠á resettinτá thσá filσ pointer«á Thi≤ i≤ donσá s∩á no⌠á t∩ ì
destro∙ an∙ datß iε thσ file«á Iµ thσ filσ i≤ no⌠ found¼ theε DP╠ ì
wil∞ creatσ thσ file.
Iµá ß filσ i≤ openeΣ a≤ OUTPUT¼á DP╠ wil∞ opeε o≥á creatσá thσ ì
file¼á theεá rese⌠ thσ filσ pointe≥ t∩ thσ beginninτ oµ thσ file¼ ì
thu≤á clearinτ an∙ datß froφ thσ file«á Wheε thσ filσ i≤á closed¼ ì
thσá director∙ entr∙ i≤ modifieΣ t∩ reflec⌠ thσ las⌠ update¼á anΣ ì
curren⌠ size.
Wheε readinτ files¼á duσ t∩ thσ sequentia∞ acces≤á method¼á i⌠ ì
ma∙ bσ necessar∙ t∩ star⌠ readinτ froφ thσ beginning« Thi≤ ma∙ bσ ì
accomplisheΣá b∙ closing¼á theε re-openinτ thσ file«á Thi≤ reset≤ ì
thσ filσ pointer≤ t∩ thσ beginninτ oµ the file.
DP╠ provide≤ fo≥ erro≥ code≤ t∩ bσ returneΣ t∩ thσá applicatioε ì
througΦá thσá STATU╙á integer«áá Thi≤á intege≥á i≤á automaticall∙ ì
declareΣá b∙á DP╠á anΣ i≤ se⌠ t∩ thσ resultinτ MS-DO╙á valuσá fo≥ ì
openinτ ß file«á Consul⌠ aε MS-DO╙ manua∞ fo≥ thσ returneΣ value≤ ì
fo≥ Functioε 3Dh« Thesσ value≤ wil∞ be returned in STATUS.
P O I N T -- Point to a location in the file.
POINT file,dd
Thi≤á instructioεá move≤á thσ filσ pointe≥á t∩á ßá specifieΣ ì
locatioε iε thσ file« POIN╘ i≤ useΣ iε conjunctioε witΦ thσ NOT┼ ì
instructioεá t∩á creatσá ßá limiteΣ forφá oµá randoφá acces≤á fo≥ ì
sequentia∞ disδ files«á POIN╘ ha≤ aε identica∞ counterpar⌠ iε thσ ì
├ programminτ language¼ "LSEEK"« B∙ "NOTE"inτ ß file¼ theε later¼ ì
"POINT"inτ t∩ it¼ datß ma∙ bσ rereaΣ o≥ rewritten« Applicablσ DO╙ ì
error codes are returned in STATUS.
.PAèR E A D -- Read a variable length ASCII string from an opened
file
READ file,string,length
Thi≤ commanΣ read≤ datß froφ ß device/filσ anΣ place≤ thσ datß ì
iε thσ string«á Thσ maximuφ amoun⌠ datß reaΣ i≤ determineΣ b∙ thσ ì
"lengthó iε thσ statement«á Thσ strinτ ma∙ bσ shorte≥ iµ aε CR/L╞ ì
i≤á encountereΣá durinτá thσ read«á Iµ aεá erro≥á occur≤á iεá thσ ì
attempteΣ read¼ thσ DO╙ erro≥ codσ wil∞ bσ returneΣ iε STATUS.
R E A D B -- Read a fixed number of bytes from an opened file
READB file,record
Thi≤ commanΣ read≤ datß froφ ß device/filσ anΣ place≤ thσ datß ì
iε thσ record.á Thσ maximuφ amoun⌠ datß reaΣ i≤ determineΣ b∙ thσ ì
lengtΦ oµ thσ record«á Thi≤ instructioε mus⌠ bσ useΣ t∩ reaΣ froφ ì
"Bóá anΣá "Ró typσ oµ files«á Thσ norma∞ REA─ wil∞á no⌠á worδá oε ì
binar∙á anΣá randoφ files«á Iµ aε erro≥ occur≤ iεá thσá attempteΣ ì
read¼ thσ DO╙ erro≥ codσ wil∞ bσ returneΣ iε STATUS.
R E T U R N -- Subroutine return statement
RETURN
Thi≤ statemen⌠ i≤ identica∞ t∩ thσ returε statemen⌠ iεá nativσ ì
808╕ code«á I⌠ ma∙ bσ useΣ b∙ itself¼á o≥ iε aε I╞ statement« Thσ ì
followinτ subroutinσ demonstrate≤ it'≤ use:
SUB PROC NEAR
IF WORD FLAG EQ ZERO RETURN
.
.
RETURN
SUB ENDP
S T O P -- Terminate the program's execution
STOP
STOP 1
STOP int
Thi≤á instructioε give≤ contro∞ bacδ t∩ DO╙ anΣ als∩ allow≤á ß ì
completioεá codσá t∩ bσ se⌠ iε DOS«á Thσ completioε codσá caεá bσ ì
testeΣ witΦ thσ "ERRORLEVELó DO╙ command«á Also¼á thσ codσ caε bσ ì
retrieveΣ b∙ anothe≥ prograφ froφ DOS« Thσ codσ ma∙ bσ ß literal¼ ì
o≥á intege≥á variable«á Jus⌠á thσ leas⌠ significan⌠ bytσá oµá thσ ì
completioε codσ wil∞ bσ returneΣ t∩ DOS.
.paèS T R I N G C O N C A T E N A T I O N
str0 $= str1 + str2 + str3 + str4 + str5
DP╠ allow≤ string≤ t∩ bσ concatenateΣ togethe≥ anΣ thσá resul⌠ ì
placeΣ int∩ ß targe⌠ string«á Thσ synta° i≤ almos⌠ identica∞ t∩ ß ì
mathematica∞á expressioε excep⌠ fo≥ tw∩ things║á 1⌐ Onl∙ thσ plu≤ ì
sigεá ("+"⌐ i≤ alloweΣ iε thσ expression¼á anΣ 2⌐ iε lie⌡ oµá thσ ì
equa∞á sign¼á ßá specia∞á equatσ symbo∞ pair¼á "$=óá i≤á useΣá t∩ ì
designatσ strinτ concatenation.
W R I T E -- Write an ASCIIZ string to an opened file
WRITE file,string
WRITE file,string,CR
WRITE file,,CR
Thi≤ statemen⌠ allow≤ thσ programme≥ t∩ writσ datß ou⌠ t∩á an∙ ì
device/file«á Iµá thσá keyworΣá C╥á (a≤ showεá iεá thσá las⌠á tw∩ ì
examples⌐ i≤ given¼á theε ß CR/L╞ wil∞ bσ appendeΣ t∩ thσ output« ì
Thσá thirΣ examplσ show≤ ho≈ ß CR/L╞ caε bσ accomplisheΣá withou⌠ ì
firs⌠á printinτá ß string«á Iµ thσ programme≥ want≤ t∩á prin⌠á aε ì
integer¼á theε thσ intege≥ wil∞ firs⌠ havσ t∩ bσ converteΣ int∩ ß ì
string¼ theε printed.
W R I T E B -- Write a record to an opened file
WRITEB file,record
Thi≤á instructioε write≤ thσ content≤ oµ thσ recorΣá ou⌠á t∩ ì
thσá giveε file«á Thi≤ statemen⌠ mus⌠ bσ useΣ t∩ writσ t∩ "Bó anΣ ì
"Ró typσ oµ files«á Thσ standarΣ WRIT┼ instructioε wil∞ no⌠á worδ ì
oε binar∙ anΣ randoφ files«á Thσ appropriatσ DO╙ erro≥ code≤ wil∞ ì
bσ returneΣ iε STATUS«
.paè B i b l i o g r a p h y
Thσ developmen⌠ oµ DP╠ ha≤ beeε evolvinτ fo≥ ove≥ tw∩ years« ì
Admittedly¼á thσá directioεá ha≤á beeε oε thσ basi≤á oµá "╔á neeΣ ì
this..."¼á anΣ "wouldn'⌠ i⌠ bσ nea⌠ if..."«á Iε othe≥ words¼á it≤ ì
thσá produc⌠ oµ creepinτ enhancement¼á thougΦ thσá integrit∙á ha≤ ì
beeε protecteΣ b∙ m∙ visioε oµ creatinτ ß soliΣ assembl∙ languagσ ì
developmen⌠ environment«á Durinτ thσ coursσ oµ investigatioεá anΣ ì
research¼á ╔ havσ reaΣ anΣ studieΣ man∙ publications¼á whicΦ havσ ì
haΣ ß direc⌠ influencσ oε thi≤ endeavor«á Thσ followinτ i≤ ß lis⌠ ì
oµ thσse publications:
Borland International, Inc. TURBO C., 1987
IBM AT Technical Reference Manual. IBM Corp., 1985
IBM PC Technical Reference Manual. IBM Corp., 1983
Microsoft Macro Assembler. Microsoft, 1985
Osborne/McGraw Hill. Using TURBO C., 1988
Osborne/McGraw Hill. Advanced TURBO C., 1988
Duncan, Raymond. Advance MS-DOS. Microsoft Press, 1986
Coffron, James W. Programming the 8086/8088. SYBEX, 1983
Hyman, Michael I. Memory Resident Utilities, Interrupts,
and Disk Management with MS & PC DOS. MIS, 1986
Jourdain, Robert. Programmer's Problem Solver for the IBM
PC, XT & AT. Brady Communications Co. 1986
Kernighan, Brian W. & Ritchie, Dennis M. The "C"
Programming Language. Bell Telephone Labs, Inc. 1978
Norton, Peter. Programmer's Guild to the IBM PC.
Microsoft Press, 1985
Wadlow, Thomas A. Memory Resident Programming on the IBM PC.
Addison-Wesley Publishing Co., 1987
Young, Michael J. Performance Programming Under MS-DOS.
SYBEX, 1987