home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPMHELP
/
Z80MR.HLP
< prev
next >
Wrap
Text File
|
2000-06-30
|
25KB
|
615 lines
Introduction
Editing MAC Source Files
Phased Code - General
Phased Code - Label+OFFSET Method
Invoking the Assembler
Assembler Syntax - Fields
Label Field
Operation and Operand Fields
Comment Field
Numbers and Bases
Operators - Arithmatic, Logical & Conditional
Macros
Pseudo-Ops
Pseudo-Ops - Conditional Assembly
Listing Options Pseudo-Ops (.PRN)
Error Reporting
:Introduction
Z80M╥á i≤ ß Z8░ macr∩ assemble≥ witΦ synta° closel∙ followinτ RMA├ anΣá MAC« ì
I⌠ assemble≤ standarΣ Z8░ mnemonic≤ int∩ aε Inte∞ He° format«á Thσ resultinτ ì
filσá (whicΦá ha≤á ß .HE╪ extension⌐ caε bσ translateΣ t∩ ß .CO═á filσá witΦ ì
LOAD.COM.
:Editing MAC Source Files
Fo≥á thσ mos⌠ par⌠ .MA├ file≤ caε easil∙ bσ translateΣ t∩ .AZ═ witΦ ver∙ fe≈ ì
changes«á Unfortunatel∙á M8░ i≤ a≤ extremel∙ versatilσ assemble≥ whicΦá wheε ì
useΣá t∩á it≤ ful∞ advantagσ contain≤ somσ pseudo-op≤á anΣá directive≤á tha⌠ ì
Z80M╥á doe≤á no⌠á understand«á ╔ wil∞ revea∞ thσ mos⌠ commoεá oµá thesσá anΣ ì
providσ somσ hel≡ oε gettinτ arounΣ theφ iε thi≤ file.
Renamσ thσ filσ t∩ havσ ß .AZ═ extension«á Edi⌠ thσ file« Nea≥ thσ beginninτ ì
oµá thσá filσ yo⌡ wil∞ seσ thσ pseud∩ o≡ tha⌠ tell≤ M8░ wha⌠á mnemonic≤á yo⌡ ì
wil∞á bσá using«á M8░ caε handlσ botΦ Z8░ anΣ 808░ mnemonics«á Yo⌡ caεá eveε ì
switcΦ iε thσ middlσ oµ thσ program«á Tw∩ pseudo-op≤ .Z8░ anΣ .808░ tel∞ thσ ì
assemble≥ whicΦ mnemonic≤ t∩ recognize«á Iµ therσ i≤ ß .Z8░ therσ deletσ it« ì
Iµá therσ i≤ ß .808░ therσ yo⌡ wil∞ neeΣ t∩ ruε thσ prograφ througΦ aεá 808░ ì
t∩ Z8░ translato≥ (likσ XLATE2.CO═ oε disδ K17)«
~
XLATE▓ i≤ ß grea⌠ translato≥ oε 808░ onl∙ files« I⌠ als∩ wil∞ onl∙ translatσ ì
thσ 808░ mnemonic≤ iε ß filσ tha⌠ ha≤ both« Unfortunatel∙ therσ arσ ß couplσ ì
oµá Z8░ mnemonic≤ tha⌠ arσ thσ samσ a≤ 808░ mnemonic≤ anΣ wil∞ bσá dutifull∙ ì
translateΣ b∙ XLATE2« Thσ probleφ i≤ tha⌠ thσ mnemonic≤ arσ thσ samσ bu⌠ thσ ì
instruction≤ the∙ represen⌠ arσ not«á S∩ thσ filσ wil∞ assemblσ O╦ bu⌠á wil∞ ì
ruε witΦ unpredictablσ results« Aε example.
JP is a valid Z80 mnemonic. It is also widely used since
it is an unconditional jump (JMP in 8080)
JP is also a valid 8080 mnemonic. It is the jump on parity
instruction.
S∩á ß Z8░ J╨ i≤ translateΣ a≤ iµ i⌠ wa≤ thσ 808░ J╨ whicΦ wil∞ makσ i⌠ J╨á ╨ ì
iεá thσá outpu⌠á file«á BaΣ news«á Thi≤ iε itselµ i≤ enougΦ t∩ makσá i⌠á to∩ ì
undependablσá t∩ usσ oε dua∞ mnemoniπ files«á T∩ avoiΣ thσ grieµ yo⌡ caεá d∩ ì
onσ oµ tw∩ things:
Translate the 8080 sections by hand if they are small enough.
~
Split the file into smaller files where the mnemonics change.
Run the 8080 sections through the translator. You can let the
assembler rejoin the files using the *INCLUDE statement or
use pip or your editor to rejoin and assemble the whole mess.
Macro≤ g∩ througΦ Z80M╥ prett∙ wel∞ fo≥ thσ mos⌠ par⌠ but¼á yo⌡ wil∞ neeΣ t∩ ì
precede the parameters with # signs (including locals).
Als∩ therσ arσ somσ macr∩ pseudo-op≤ tha⌠ arσ no⌠ supporteΣ (als∩ no⌠ widel∙ ì
used)«á Iµá somσ onσ write≤ Z80M╥ macro≤ t∩ substitutσ fo≥ thesσ (anΣ ßá MO─ ì
operator⌐á pleasσ senΣ i⌠ iε anΣ we'l∞ includσ i⌠ iε thσ macr∩ librar∙á tha⌠ ì
wσ arσ developinτ fo≥ thi≤ assembler.
.phasσ anΣ .dephasσ arσ useΣ t∩ makσ thσ assemble≥ generatσ labe∞á addresse≤ ì
fo≥á somσá othe≥á par⌠ oµ memor∙ thaε wherσ thσ filσ wil∞á bσá loaded«á Seσ ì
PhaseΣ Codσ fo≥ details.
:Phased Code - General
Onσá oµ thσ limitation≤ oµ thi≤ assemble≥ i≤ thσ lacδ oµ ß .PHAS┼ directive« ì
Thi≤á directivσ cause≤ thσ assemble≥ t∩ generatσ addresse≤ fo≥á ßá differen⌠ ì
sectioε oµ memor∙ fo≥ label≤ thaε thσ actua∞ placσ thσ codσ i≤ t∩ bσ loaded« ì
ORGinτá a⌠ highe≥ locatioε late≥ iε thσ prograφ anΣ jumpinτ therσ wil∞ causσ ì
thσá entirσ areß oµ memor∙ betweeε 100╚ anΣ thσ enΣ poin⌠ oµ thσ prograφá t∩ ì
bσ saveΣ resultinτ iε ß hugσ .CO═ filσ wheε loadeΣ witΦ LOAD.COM«
Therσá arσ man∙ way≤ t∩ phasσ codσ anΣ stil∞ enΣ u≡ witΦ ß reasonablσá sizeΣ ì
CO═ file« Herσ ╔ wil∞ presen⌠ tw∩ oµ thσ mos⌠ commoε methods.
:Phased Code- Label+OFFSET Method
Iεá orde≥ fo≥ codσ t∩ bσ assembleΣ iε onσ areß t∩ ruε iε another¼á ou≥á onl∙ ì
concerε i≤ ho≈ thσ addresse≤ arσ calculateΣ b∙ thσ assembler«á Normally¼á aε ì
assemble≥á set≤á ß locatioε counte≥ wheε i⌠ see≤ aεá OR╟á pseudo-op«á A≤á i⌠ ì
produce≤á eacΦá bytσ oµ thσ i⌠ increment≤ thσ locatioε counte≥ t∩á calculatσ ì
thσ nex⌠ address« Iµ i⌠ find≤ ß label¼ i⌠ set≤ thσ label'≤ addres≤ accordinτ ì
t∩ thi≤ locatioε counter«á Thσ programme≥ ha≤ anothe≥ methoΣ oµ settinτá thσ ì
addres≤ oµ labels¼ witΦ EQU« Iµ ever∙ labe∞ iε thσ prograφ take≤ thσ forφ oµ ì
Label+OFFSE╘ wherσ thσ offse⌠ i≤ ß constant¼ theε thσ assemble≥ wil∞ producσ ì
thσá codσ t∩ ruε iε higΦ memor∙ whilσ creatinτ ß filσ tha⌠ wil∞ loaΣ iεá lo≈ ì
memory.
~
WitΦá thi≤á methoΣá yo⌡ woulΣ spli⌠ thσ abovσ prograφ int∩á tw∩á parts¼á thσ ì
loade≥ anΣ thσ codσ tha⌠ i≤ t∩ bσ relocated« Yo⌡ caε assemblσ thσ loade≥ anΣ ì
picδá aε arbitrar∙ sourcσ addres≤ fo≥ thσ codσ t∩ bσ relocateΣá (sa∙á 200h)« ì
Theε yo⌡ caε assemblσ thσ relocatablσ portioε witΦ aε higΦ ORG« (8000╚ say)« ì
No≈ yo⌡ caε joiε thσ tw∩ HE╪ file≤ togethe≥ witΦ DDT.CO═ readinτ iε thσ higΦ ì
portioεá witΦ aε OFFSET«á T∩ ge⌠ thσ offse⌠ usσ DDT'≤ He° suφ anΣ differencσ ì
commanΣ iε thσ forφ of:
H<desired load address>,<ORG address>
Thσá seconΣ numbe≥ wil∞ bσ thσ OFFSET«á No≈ wσ caε usσ DD╘ t∩ joiε thσá tw∩ ì
files.
DDT LOADER.HEX
H200,8000
8200 8200 ; in this case both numbers are the same (we want
; second
IPHASE2.HEX ; prepare to load file
R8200 ; read in with offset
^C ; exit to CPM
SAVE 1 PHASE3.COM ; and the com file is created
:Invoking the Assembler
Z80MR TEST <carriage return>
Thσá assemble≥á wil∞á reaΣ iε thσ filσ TEST.AZ═ froφ thσ curren⌠á drivσá anΣ ì
creatσ aε objec⌠ filσ TEST.HE╪ anΣ ß listinτ filσ TEST.PRN.
Eithe≥ oµ thσ outpu⌠ file≤ (o≥ both⌐ ma∙ bσ omitted«á Iε addition¼ thσ file≤ ì
ma∙ bσ locateΣ oε differen⌠ drives« Sincσ thσ sourcσ filσ mus⌠ alway≤ havσ ß ì
.AZ═ extentioε wσ ma∙ usσ thσ extentioε t∩ contro∞ thσ output.
Z80MR TEST.sol
Thσ lette≥ iε thσ 'sº positioε tell≤ thσ assemble≥ wherσ t∩ finΣ thσá sourcσ ì
filσá anΣ ma∙ bσ an∙ disδ drivσ lette≥ froφ ┴ t∩ D«á Thσ lette≥ iε thσá 'oº ì
positioεá tell≤ thσ assemble≥ wherσ t∩ locatσ thσ objec⌠ filσ anΣ ma∙ bσ A-─ ì
a≤á abovσ o≥ ┌ iµ thσ filσ i≤ no⌠ desired«á Thσ lette≥ iε thσá 'lºá positioε ì
tell≤á thσ assemble≥ wha⌠ t∩ d∩ witΦ thσ listinτ file«á I⌠ caε bσ an∙á drivσ ì
lette≥á froφá A-─ o≥ ┌ iµ thσ filσ i≤ no⌠ desired«á Iε additioε thσá listinτ ì
filσ ma∙ bσ sen⌠ t∩ thσ consolσ iµ aε ╪ i≤ iε tha⌠ position.
:Assembler Syntax - Fields
Assembler≤á arσ almos⌠ alway≤ fielΣ orienteΣ somσ t∩ ß greate≥á degreσá thaε ì
others«á ┴á fielΣ i≤ ß flexiblσ positioε iε thσ linσ oµ codσ witΦ respec⌠ t∩ ì
thσ righ⌠ margin« Thi≤ assemble≥ recognize≤ ┤ field≤ iε aε assembl∙ languagσ ì
sourcσ line: Label, Operation, Operand and Comment
Thσá assemble≥ know≤ wheε i⌠ ha≤ reacheΣ thσ enΣ oµ ß fielΣ wheε i⌠á see≤á ß ì
'fielΣá delimiter'«á Thi≤ caε bσ ß spacσ o≥ ß taΓ fo≥ thi≤ assemble≥á thougΦ ì
somσá requirσá tab≤á s∩ i⌠ i≤ ß gooΣ habi⌠ t∩ alway≤ usσ taΓá character≤á a≤ ì
delimiters.
:Label Field
┴á symbo∞á i≤á ß worΣ useΣ t∩ represen⌠ ßá number«á Symbol≤á tha⌠á refe≥á t∩ ì
addresse≤á arσá calleΣá labels«á Thσ assignmen⌠ oµ ß numbe≥ t∩ ßá labe∞á caε ì
eithe≥ bσ defineΣ a≤ thσ line≤ below
TEN EQU 10
START EQU 100H
or calculated by the assembler as an address for branching instructions:
START: JP FINISH
NOP
NOP
FINISH: JP START
Also notice that the label is optional and is only for the programmers
conveniance.
~
Label≤ mus⌠ appea≥ iε thσ labe∞ field«á Somσ assembler≤ allo≈ yo⌡ t∩á inden⌠ ì
label≤ bu⌠ thi≤ onσ won't.
START EQU 100H
START: JP FINISH
èWil∞á givσá yo⌡ ß problem«á Thσ EQ╒ mus⌠ bσ iε thσ operatioε fielΣá anΣá thσ ì
labe∞ iε thσ labe∞ field.
Mos⌠á assembler≤ requirσ tha⌠ thσ undefineΣ label≤ bσ terminateΣ iε ßá coloε ì
bu⌠ thi≤ assemble≥ doe≤ no⌠ requirσ ß coloε fo≥ symbol≤ iε columε 1.
START JP FINISH
wil∞á no⌠ generatσ aε erro≥ bu⌠ colon≤ arσ anothe≥ gooΣ habi⌠ anΣ als∩á makσ ì
you≥ codσ morσ readable.
~
Thi≤ assemble≥ onl∙ examine≤ thσ firs⌠ si° character≤ oµ an∙ labe∞ o≥ symbo∞ ì
s∩ tha⌠ iµ thσ followinτ label≤ werσ useΣ iε thσ samσ program
FINISH1 EQU 1000H
FINISH2 EQU 2000H
A 'D' error (duplicate symbols) would be generated.
:Operation and Operand Fields
Thσá operatioε fielΣ follow≤ thσ labe∞ fielΣ anΣ ma∙ eithe≥ contaiε ß Z8░ o≡ ì
codσá mnemonic¼á aεá assemble≥ directivσ (o≥ pseud∩ op)¼á o≥ ßá macr∩á call« ì
Assemble≥ directive≤ anΣ macro≤ arσ describeΣ late≥ iε thi≤ file« Thi≤ fielΣ ì
wil∞á usall∙á contaiεá thσá mnemoniπá fo≥á ßá Z8░á instruction«áá Somσáá Z8░ ì
instruction≤á onl∙ usσ thi≤ fielΣ whilσ other≤ contaiε aε operanΣ whicΦ wil∞ ì
bσ locateΣ iε thσ operanΣ field.
GOBACK: OR A
RET Z
LD A,0FFH
RET
Thσá wa∙á Z8░á mnemonic≤á werσ designed¼á thσ numbe≥á oµá nmenonic≤á iεá thσ ì
operatioεá portioε oµ instruction≤ i≤ kep⌠ t∩ ß minimuφ sincσá thσá operand≤ ì
reall∙á distinguisΦ thσ difference≤ betweeε simila≥ instructions«á Thσ firs⌠ ì
linσ abovσ i≤ ß gooΣ examplσ oµ this«á Thσ operatioε i≤ aε 'ORº operatioε oε ì
thσá numbe≥á iε thσ accumulato≥ (implied⌐ witΦ anothe≥á register«á I⌠á make≤ ì
sensσ tha⌠ thσ operanΣ shoulΣ bσ thσ registe≥ containinτ thσ othe≥ numbe≥ iε ì
thσá 'ORº operation«á Iε Z8░ assembl∙ languagσ thi≤ i≤ thσ case«á Thσá firs⌠ ì
linσá OR'≤á thσá accumulato≥á witΦ thσ accumualato≥á (useΣá t∩á seσá iµá thσ ì
accumulato≥á contain≤á ß 0)«á Noticσ tha⌠ thσ seconΣ linσ use≤á thσá operanΣ ì
fielΣ t∩ contaiε thσ conditioε fo≥ ß conditiona∞ jum≡ (iε thi≤ casσ thσ zer∩ ì
flag)«á Thσá thirΣá linσ use≤ thσ operanΣ fielΣ t∩ contaiε botΦá thσá targe⌠ ì
registe≥á fo≥á ßá loaΣá anΣá thσá numbe≥á t∩á load«á Thσá las⌠á linσá i≤á aε ì
unconditiona∞á returε whicΦ use≤ thσ samσ operato≥ (RET⌐ a≤ thσá conditiona∞ ì
returεá bu⌠ doe≤ no⌠ usσ thσ operanΣ fielΣ becausσ therσ arσ n∩ conditon≤ t∩ ì
placσ there«á Thi≤ structurσ make≤ Z8░ program≤ mucΦ morσ readablσ thaε 808░ ì
program≤á a≤á wel∞á a≤ makinτ thσá instruction≤á easie≥á t∩á remember«á Thσ ì
followinτ i≤ thσ samσ codσ writteε witΦ 808░ mnemonics« Noticσ thσ differen⌠ ì
philosoph∙ oε thσ usσ oµ thσ fields.
GOBACK: ORAè RETZ
MVI A,0FFH
RET
Als∩á thσ L─ commanΣ iε thσ Z8░ i≤ useΣ fo≥ al∞ datß move≤ whilσ 808░á user≤ ì
mus⌠ remembe≥ ß differen⌠ mnemoniπ fo≥ differen⌠ type≤ oµ moves.
8080 Z80
MOV H,A LD H,A
MVI H,00 LD H,00
LXI H,0000 LD HL,0000
:Comment Field
Comment≤ arσ no⌠ limiteΣ t∩ thσ commen⌠ fielΣ anΣ caε actuall∙ bσ thσ entirσ ì
line«á Al∞á assembler≤ recognizσ thσ semicoloε a≤ thσ beginninτ oµ ß commen⌠ ì
anΣ mos⌠ ignorσ thσ res⌠ oµ thσ line«á Fo≥ compatabilit∙ betweeεá assembler≤ ì
i⌠ i≤ ß gooΣ t∩ begiε comment≤ witΦ ß semicolon«á Bu⌠ fo≥ thi≤ assemble≥ thσ ì
followinτ method≤ oµ insertinτ comment≤ arσ gooΣ syntax.
1. Beginning a line with an '*' in column one causes the assembler to ignore
therest of the line except if one of the assembler commands (described below)
immediately follows the asterisk (no embedded spaces).
2. A semicolon will cause the assembler to consider everything following it
to be considered a comment.
3. The first blank encountered following the beginning of the operand field
wil∞ causσ thσ assemble≥ t∩ conside≥ thσ res⌠ oµ thσ linσ t∩ bσ considereΣ ß ì
comment.
:Numbers and Bases
Thσá assemble≥á wil∞á accep⌠á number≤ iε HE╪ (basσ 16⌐ BINAR┘á (basσá 2⌐á o≥ ì
DECIMAL«á He° number≤ mus⌠ enΣ witΦ aε ╚ anΣ binar∙ number≤ mus⌠ enΣ iε ß B« ì
Decima∞ number≤ shoulΣ havσ n∩ suffi° letter« Wheε ß HE╪ digi⌠ begin≤ witΦ ß ì
letter¼ thσ lette≥ shoulΣ bσ precedeΣ witΦ ß 0.
LD A,0F3H
OR 01001000B
LD HL,4000H+28
:Operators
Arithmetic Operators
+ arithmetic addition.
- arithmetic subtraction
* arithmetic multiplication
/ arithmetic division (truncating the result)
Logical Operators (Bit Manipulation)
& (or .AND.) logical AND operation
^ (or .OR.) logical OR operation
.XOR. logical exclusive OR operation
\ (or .NOT.) logical inversion
.SHR. shift left operand to right by right operand
.SHL. shift left operand to left by right operand
.HIGH. byte value is assigned the high byte of a 16 bit value
.LOW. byte value is assigned the low byte of a 16 bit value
~
Conditional Assembly Operators ( return TRUE or FALSE to IF )
= (or .EQU.) logical equivalence
> (or .GT.) greater than
.UGT. unsigned greater than
< (or .LT.) less than
.ULT. unsigned less than
:Macros
Macro≤á havσ ß forφ tha⌠ i≤ uniquσ anΣ mus⌠ bσ followeΣ closel∙ fo≥á correc⌠ ì
results« Thσ genera∞ forφ oµ ß macr∩ is:
name MACRO #parameter1,#parameter2,....
instruction
instruction
instruction
.
.
.
ENDM
Thσá namσ i≤ thσ symbo∞ tha⌠ wil∞ bσ useΣ t∩ invokσ thσ macro«á MACR╧á i≤á ß ì
keyworΣá tha⌠ wil∞ indicatσ t∩ thσ assemble≥ tha⌠ ß macr∩ i≤ beinτá defined« ì
Thσá parameter≤á alway≤á mus⌠ begiε witΦ ß '#º sigε iε macro≤ anΣá the∙á arσ ì
seperateΣ b∙ commas«á Thσ instructioε caε bσ Z8░ instructions¼ o≥ an∙ oµ thσ ì
assemble≥ command≤ listeΣ abovσ incudinτ conditionals«á Thσ instructioεá caε ì
als∩á bσá anothe≥ macr∩ cal∞ (calleΣ nesteΣ macros⌐ bu⌠ onl∙ iµá thσá nesteΣ ìèmacr∩ ha≤ beeε alread∙ defined« Thσ END═ keyworΣ tell≤ thσ assemble≥ tha⌠ i⌠ ì
ha≤á reacheΣá thσ enΣ oµ thσ codσ tha⌠ mus⌠ bσ assembleΣ wheε thi≤ macr∩á i≤ ì
called« D∩ no⌠ usσ ß coloε behinΣ thσ macr∩ name.
Bu⌠á wha⌠ abou⌠ usinτ addres≤ symbol≤ iε macros┐á Ho≈ caε wσ avoiΣá thσá 'Dº ì
erro≥á iµá wσá cal∞ thσ macr∩ morσ thaε once«á Thσ othe≥ keyworΣá uniquσá t∩ ì
macro≤á i≤á LOCAL«á Thi≤ make≤ thσ assemble≥ generatσ it≤ owεá uniquσá labe∞ ì
ever∙á timσá thσ macr∩ i≤ expandeΣ iε ß program«á Followinτ thσá worΣá LOCA╠ ì
(whicΦ mus⌠ bσ oε thσ seconΣ linσ oµ thσ macro⌐ arσ thσ symbol≤ wσ wan⌠á thσ ì
compile≥ t∩ generatσ uniquσ label≤ for«á Thesσ symbol≤ mus⌠ als∩ bσ procedeΣ ì
witΦ ß '#º sign.
AJUMP MACRO
LOCAL #ADR_Z,#BACK
OR A
JR Z,#ADR_Z
LD A,40H
JR #BACK
#ADR_Z: LD A,04H
#BACK: LD DE,0
ENDM
The macro itself is not really useful but it is correct and shows the use
of local labels.
:Pseudo-Ops
ORG <expr> ; Sets the origin of the code or section of code. Actually
╗ái⌠ set≤ thσ referencσ numbe≥ tha⌠ thσ assemble≥ use≤ t∩
áááááááááááááááá: generatσ addresse≤ fo≥ label≤ anΣ instructions.
; <expr> could be a number or a previously defined symbol.
; e.g. ORG 0
; ORG START
END <symb> ; Determines the end of an assembly language program. <symb>
; if present describes the first executable instruction of
; the program.
~
DW wordlist
DEFW wordlist
; Both of these have identical meanings. In assembly language
; programs, 8 bit values are called bytes and 16 bit
; values are called words. Addresses are assembled with the
; most significant byte (MSB) following the least significant
; byte (LSB) because this is how the microprocessor handles
; these values. The DW pseudo-op allows us to describe these
; values in the way we are used to (MSB first) and still
; assemble correctly for the processor.
; DW 8000H
; will assemble the same as
; DB 00H
; DB 80H
;è ; If more than one word is to follow a DW following values
; should be seperated by commas
; e.g. DW 8000H,0F000H,0000H
; The wordlist can also be symbols
; e.g. START: JP FINISH
; DW START,FINISH
; FINISH: JP START
DDB wordlist
; This pseudo-op is a way of assembling 16 bit values with
; the MSB first (opposite of DW).
; DDB 8000H
; will assemble the same as
; DB 80H
; DB 00H
DB bytelist
DEFB bytelist
DEFM bytelist
DATA bytelist
; These four pseudo-ops have identical meanings. The bytelist
; can be one byte or multiple bytes seperated with commas.
; The bytes can be any mix of symbols, ascii characters in
; quotes, or numbers on the same line. This is familiar
; code in Kaypro programs:
;
;ESC EQU 1BH
;CLRSCR EQU 1AH
;CRLF DDB 0D0AH
;
; ORG 100H
;
; LD DE,MES
; LD C,9
; CALL 5
; RET
;
;MES: DB CLRSCR
; DB ESC,'=',12+20H,12+20H
; DB '*Your Message Here *',CRLF
; DB '*Or Here*','$'
;
; END
;
; If you've been waiting for an example to enter assemble
; and run, try this one out. Just enter it (with out the
; semicolons of course) assemble it and run it as described
; in AZM-COM.DOC.
;
; The program clears the screen, positions the cursor at
; row 12 column 12 and prints the message using the BDOSè ; function 9 (print string).
;
; The symbol CLRSCR is defined by an EQU to the hex code to
; clear the screen on the Kaypro (^Z).
;
; The cursor positioning sequence on the Kaypro consists of
; the two lead-in characters (escape and an equals sign) and
; then the row+20H and the column+20H.
;
; Since the next bytes are just a carriage return, line feed
; pair the second part of the message will appear at the
; left side of the screen. We could include extra DB's to
; position the cursor anywhere on the screen if we like.
;
; BDOS function 9 (summoned by loading a 9 in the C register
; and calling 0005H) prints the characters it finds at the
; address in the DE registers until it sees a '$'.
~
DS n
DEFS n ; Reserve data space ( n bytes ). This is used to position
; allocate or label data storage space in a program. n is
; a number describing the number of bytes reserved.
; DS 16
; Reserves 16 bytes. The next instruction will be located
; 16 bytes from the location counter when the DS was
; encountered.
~
label EQU <expr>
;
; The EQU sets the label equal to the expression. The
; label should not be terminated with a colon when used
; with an EQU pseudo-op. The label can be any symbol
; (byte or word) and the <expr> a number in any of the
; following forms:
; SWEET EQU 16 ;decimal
; SWEET EQU 10H ;hex
; SWEET EQU 00010000B ;binary
;
; With this assembler the EQU must be located in the
; operation field.
; A label defined with an EQU cannot be redefined later
; in the program.
~
label DEFL <expr>
;
; This assigns the value of the <expr> to the label like
; the EQU pseudo-op but a label defined with a DEFL can
; be redefined later in the program.
*INCLUDE <filename>
; This pseudo-op causes the assembler to stop assemblingè ; lines in the file it is presently in and read in the
; file <filename>. It then begins assembling lines in this
; included file until it reaches the end of the file when
; it returns to the original file and resumes assembling
; lines in it once more. The <filename> can be any CPM
; filename.ext though if the extent is left off it looks
; for the given filename with an extent of .LIB. The asterisk
; must appear in column 1 with the word INCLUDE immediately
; following with no embedded spaces.
;
;*INCLUDE Z80MACRO ; will begin assembly on
; the file Z80MACRO.LIB
:Pseudo-Ops - Conditional Assembly
IF <expr>
ELSE
ENDIF
Conditional assembly is a way of writing a single program so that
it can be assembled different ways or with different options by
only changing a couple of lines of codes. When the assembler
encounters an IF pseudo-op it evaluates the symbol <expr>. IF
<expr> is non-zero it assembles the following lines until it reaches
an ELSE or an ENDIF. If <expr> is 0 the lines are ignored until
the assembler encounters an ELSE or an ENDIF. If the ELSE is
encounter the assembler begins assembling lines again. The ENDIF
pseudo-op causes the assembler to resume assembling all lines.
You can not have an IF without an ENDIF.
~
Any of these pseudo-ops must appear in the operation field.
TRUE EQU 0FFH
FALSE EQU 0
KPRO2 EQU TRUE
KPRO10 EQU FALSE
IF KPRO2
BITPRT EQU 1CH
ELSE
BITPRT EQU 14H
ENDIF
:Listing Options Pseudo-Ops (.PRN)
There are a number of listing options. All of these options only effect
the print file (.PRN). The options include some for debugging as well as
some for the actual format of the file on the page. The .PRN file is the
basic tool assembly language programmers have for examining the output ofèthe assembler. The pseudo-ops beginning with an asterisk must begin in
column 1.
*EJECT
( or EJEC ) ; The next line of the listing should be placed at the top
; of the next page.
*HEADING ; Place the text ( following this command ) on the top of
; each page. Usually used to date the listing file.
TITLE 'text' ; Place the text in the quotation marks (either double or
; single on the top of each page in the listing file.
SPAC n ; Leave n blank lines in the listing. Used to leave white
; space in the file with out using a page break.
~
*LIST ON
*LIST OFF ; Turn the listing on or off. This is usually used to omit
; long comments or certain sections from the .PRN file.
*MACLIST ON
*MACLIST OFF ; Turn the expansion of macros on or off. Seeing how the
; macros are being expanded is handy for optimizing code
; but can waste paper when that is no longer the area of
; interest.
~
LIST options
NLIST options ; These pseudo-ops allow you to turn any of the supported
; listing file options on (LIST) or off (NLIST) without
; changing the other options. Both of these pseudo-ops
; must be followed with one or more of the following option
; letters. If these pseudo-ops is used some options are
; on by default ( marked with (on) in the following list.
;
; A ; List all bytes in DB, DW, DDB, etc. Otherwise
; ; only the bytes that can fit in one line are
; ; included in the listing ( others are implied ).
; B ; Place symbol table into object file.
; G ; Place system generated symbols into object files
; I (on); List lines of conditional code following a false
; ; conditional. If off only the code actually
; ; assembled is listed.
; M (on); Expand macros in listing files
; O (on); Produce an object module. That is show the bytes
; ; being generated by the assembler otherwise just
; ; the source and (optionally) macro expansions.
; R ; use absolute displacement for JR and DJNZ
; S (on); List source code in listing file
; T (on); List symbol table in listing file
; X ; Generate and list cross references in listing file
; Z ; Generate an error for Z80 only opcodes. Allows youè ; ; to write in Z80 mnemonics for an 8080 processor.
:Error Reporting
D ; Duplicate symbol definition. You will see this error
; message if you do any of the following:
; Use the same symbol twice.
; FORMATX
; FORMATC
; will generate an error (only 6 significant
; characters).
; Upper and lower case symbols with the same letters
; FORMAT:
; format:
; are identical to the assembler.
; Assigning a different value to a symbol that was
; previously defined with a EQU pseudo-op.
; If you are going to reassign use DEFL.
E ; Relocation error. I believe this occurs if the assembler
; cannot reassign an address as expected.
F ; Format Error. You will see this if you break any of the
; rules regarding field use and macro format.
~
K ; Keyword error. This means you tried to use one of the
; assemblers reserved words or pseudo-ops as a symbol.
; ORG: JP END
; NOP
; END: JP ORG
; is in very bad taste.
L ; Label error. The attempt to assign a value to a lable was
; unsuccessful. Also remember that labels do not end in a
; colon when preceding EQU.
; START: EQU 100H ; is bad news
; START EQU 100H ; is perfect
M ; Missing label. The symbol you are using was never defined.
N ; Macro nesting error. Macros can be nested (that is a macro
; can call another macro) but if the nesting gets to deep
; the assembler will quit and give you one of these. Also,
; you can only call macros that were previously defined.
~
O ; Op code error. If you see this, look in the operation and
; operand fields. Consult the mnemonic table. People
; switching over from 8080 will see a few of these.
P ; Phase error. A 2 pass assembler builds a symbol table on
; the first pass and generates the object code on the second.
; If a number that it calculates for a symbol on the first
; pass does not agree with a number it generates in theè ; pass this error is shown check the symbols in the line
; the error appeared.
Q ; Questionable operand. Actually theres no question about it
; it is a bad operand. Typo's give you these as well as
; blowing op code format. Usally easy to find your mistake.
S ; Syntax error. You broke one of the syntax rules described
; above.
T ; Symbol table full. Not much you can do with this except
; pare down the code.
~
U ; Undefined symbol. You used a symbol but forgot to define
; it in with an EQU.
V ; Value error. Usually means you are trying to do a 16
; bit operation with an 8 bit number or the other way
; around.