Date post: | 13-Feb-2018 |
Category: |
Documents |
Upload: | elreyleon1 |
View: | 217 times |
Download: | 0 times |
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 1/65
What is an Assembler?
An assembler is a program that translates symbolic code (assembly language) into executable objectcode. This object code can be executed with a 80C5!compatible microcontroller. "# you ha$e e$erwritten a computer program directly in machine!recogni%able #orm& such as binary or hexadecimal
code& you will appreciate the ad$antages o# programming in symbolic assembly language.
Assembly language operation codes (mnemonics) are easily remembered (' #or mo$e instructions&A** #or addition& and so on). +ou can also symbolically express addresses and $alues re#erenced inthe operand #ield o# instructions. ,ecause you assign these names& you can ma-e them as meaning#ulas the mnemonics #or the instructions. or example& i# your program must manipulate a date as data&you can assign it the symbolic name *AT/. "# your program contains a set o# instructions used as atiming loop (executed repeatedly until a speci#ic amount o# time has passed)& you can name theinstruction group T"'/123.
An assembly program has three parts4
'achine instructions ! Code the machine can execute. *etailed discussion o# the machine
instructions is in the hardware manuals o# the 80C5 microcontroller.
Assembler directi$es ! *e#ine the program structure and symbols& and generate non
executable code (data& messages& and so on.).
Assembler controls ! et assembly modes and direct assembly #low.
Un ensamblador es un programa que traduce el código simbólico (lenguajeensamblador) en código objeto ejecutable. Este código objeto puede serejecutado con un microcontrolador 80C51-compatible. i alguna !e" #a escritoun programa de ordenador directamente en la m$quina de %orma reconocible& como
código binario o #e'adecimal& apreciar$n las !entajas de la programación enlenguaje ensamblador simbólico.
En el lenguaje sembler los códigos de las operación (mnemotcnicos) son%$ciles de recordar (*+, para las instrucciones de mo!er& para la suma& as/ sucesi!amente). ambin puede e'presar simbólicamente las direcciones los !alores de re%erencia en los operando en el campo de las instrucciones.ebido a que asigne estos nombres& se puede #acer como signi%icati!a como losmnemotcnicos para las instrucciones. or ejemplo& si tu programa debemanipular una %ec#a como datos& puede asignarle el nombre simbólico 2EC3. iel programa contiene un conjunto de instrucciones utili"ado como un calendariode bucle (ejecutado !arias !eces #asta una determinada cantidad de tiempo que#a pasado)& usted puede nombrar a la instrucción grupo 4*E67++.
Un programa en asembler tiene tres partes• 4nstrucciones de m$quina - Código de la m$quina puede se
ejecutado. etallada e'plicación de instrucciones de m$quina est$en los manuales #ard9are del 80C51 microcontrolador.
• ssembler directi!as - e%inir la estructura de los♣ programas los s/mbolos& no generar código ejecutable (datos& mensajes&etc.).
• ssembler controles : 2ija los modos del ensamblador.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 2/65
Assembly Statements6ome 7 riting Assembly 3rograms 7 Assembly tatements
Assembly program source #iles are made up o# statements that may include controls&
assembler control statements& or 805 'C9 instructions (mnemonics). or example4
;47E(emo rogram <1)
CE= 0000#
>* ;
E?
This example program consists o# #our statements. $TITLE is a directi$e& CSEG and END
are control statements& and JMP is an 805 'C9 instruction.
Each line o an assembly !ro"ram can contain only one #irectie% controlstatement% or MC& instr'ction( Statements m'st be containe# in e)actly one line(M'lti*line statements are not allo+e#.
Statements in ),- assembly !ro"rams are not col'mn sensitie( Directies% controlstatements% or MC& instr'ctions may start in any col'mn( "ndentation used in the
examples in this manual is done #or program clarity and is neither re:uired nor expected bythe assembler. The only exception is that arguments and instruction operands must be
separated #rom directi$es& control statements& or 'C9 instructions by at least one space.
All ),- assembly !ro"rams m'st incl'#e the END control statement( This control
statement signals to the assembler that this is the end o# the assembly program. Any 'C9
instructions& directi$es& or control statements #ound a#ter the END control statements areignored. The shortest $alid assembly program contains only an END control statement.
Controls6ome 7 riting Assembly 3rograms 7 Assembly tatements 7 Controls
Assembler controls instruct the assembler how to process subse:uent assembly language
instructions. Controls also pro$ide a way #or you to de#ine program constants and reser$espace #or $ariables.
Assembler controls direct the operation o# the assembler when generating a listing #ile orobject #ile. Typically& controls do not impact the code that is generated by the assembler.
Controls can be speci#ied on the command line or within an assembler source #ile.
The conditional assembly controls are the only assembler controls that will impact the code
that is assembled by the A),- assembler. The I.& ELSE& ENDI.& and ELSEI. assemblercontrol statements pro$ide a power#ul set o# conditional operators that can be used to
include or exclude certain parts o# your program #rom the assembly.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 3/65
The topic Control tatements describes the a$ailable assembler controls in detail andpro$ides an example o# each. e#er to this topic #or more in#ormation about control
statements.
Instr'ctions6ome 7 riting Assembly 3rograms 7 Assembly tatements 7 "nstructions
Assembly language instructions speci#y the program code that is to be assembled by the
A),- assembler. The A),- assembler translates the assembly instructions in your programinto machine code and stores the resulting code in an object #ile.
Assembly instructions ha$e the #ollowing general #ormat4
@ label A mnemonic @ operand A @ & operand A @ B& operand A @ comment A
Where
label symbol name that is assigned the address at which the instruction is located.
mnemonic is the AC"" text string that symbolically represents a machine language
instruction.
operand is an argument that is re:uired by the speci#ied mnemonic .
comment is an optional description or explanation o# the instruction. A comment maycontain any text you wish. Comments are ignored by the assembler.
e#er to the x5 microcontrollers 805 "nstruction et 'anual& where they are listed by
mnemonic and by machine language opcode& #or more in#ormation about assemblerinstructions.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 4/65
Comments6ome 7 riting Assembly 3rograms 7 Comments
Comments are lines o# text that you may include in your program to identi#y and explain the
program. Comments are ignored by the A),- assembler and are not re:uired in order to
generate wor-ing programs.
+ou may include comments anywhere in your assembler program. Comments must be
preceded with a semicolon character (;). A comment can appear on a line by itsel# or canappear at the end o# an instruction. or example4
#is is a comment
?+ #is is also a comment
hen the assembler recogni%es the semicolon character on a line& it ignores subse:uenttext on that line. Anything that appears on a line to the right o# a semicolon will be ignored
by the A),- assembler. Comments ha$e no impact on object #ile generation or the codecontained therein.
Symbols an# Symbol Names6ome 7 riting Assembly 3rograms 7 ymbols and ymbol <ames
A symbol is a name that you de#ine to represent a $alue& text bloc-& address& or registername. +ou can also use symbols to represent numeric constants and expressions.
Symbol Names
ymbols are composed o# up to = characters #rom the #ollowing list4
A >& a %& 0 ?& 1& and @
A symbol name can start with any o# these characters except the digits 0 ?.
ymbols can be de#ined in a number o# ways. +ou may de#ine a symbol to represent anexpression using the E/& or SET control statements4
?U*DE624,E EU 5
UE627= E 1
27E627= E 0
+ou may de#ine a symbol to be a label in your assembly program4
7DE71 >?F 0& 7DE71
+ou can de#ine a symbol to re#er to a $ariable location4
E476DU22E GG#
ymbols are used throughout assembly programs. A symbolic name is much easier to
understand and remember than an address or numeric constant. The #ollowing topics
pro$ide more in#ormation about how to use and de#ine
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 5/65
Labels6ome 7 riting Assembly 3rograms 7 2abels
A label de#ines a place (an address) in your program or data space. All rules that apply tosymbol names also apply to labels. hen de#ined& a label must be the #irst text #ield in a
line. "t may be preceded by tabs or spaces. A colon character (4) must immediately #ollowthe symbol name to identi#y it as a label. nly one label may be de#ined on a line. or
example4
7DE71 H
7DE7H label b itsel%
?U*DE D HI& JJ& K4?=K& 0 label at a message
C+L *+, M& <1H3 label in a program
"n the abo$e example& 2A,/2& 2A,/2B& <9',/& and C3+ are all labels.
hen a label is de#ined& it recei$es the current $alue o# the location counter o# the currently
selected segment. e#er to 2ocation Counter #or more in#ormation about the locationcounter.
+ou may use a label just li-e you would use a program o##set within an instruction. 2abelscan re#er to program code& to $ariable space in internal or external data memory& or can
re#er to constant data stored in the program or code space.
+ou may use a label to trans#er program execution to a di##erent location. The instruction
immediately #ollowing a label can be re#erenced by using the label. +our program can jumpto or ma-e a call to the label. The code immediately #ollowing the label will be executed.
+ou may use labels to pro$ide in#ormation to simulators and debuggers. A simulator ordebugger can pro$ide the label symbols while debugging. This can help to simpli#y the
debugging process.
2abels may only be de#ined once. They may not be rede#ined.
Location Co'nter6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 2ocation Counter
The Ax5 assembler maintains a location counter #or each segment which contains theo##set o# the instruction or data being assembled. The location counter increments a#ter
each line by the number o# bytes o# code or data in that line.
The location counter is initiali%ed to 0 #or each segment& but may be changed using the 01Gstatement.
The dollar sign character (D) may be used in an expression to obtain the current $alue o#
the location counter. or example& the #ollowing uses the location counter to determine thelength o# a string.
msg D K#is is a messageK& 0
msg6len EU ;-msg
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 6/65
+ou may use the location counter in instructions. or example& the #ollowing creates anin#inite loop4
>* ; N#ile (1)
&sin" 0!eran#s an# E)!ressions6ome 7 riting Assembly 3rograms 7 9sing perands and /xpressions
perands are arguments& or expressions& that are speci#ied along with assembler directi$es
or instructions. Assembler directi$es re:uire operands that are constants or symbols. orexample4
,,, EU J
10#
Assembler instructions support a wider $ariety o# operands than do directi$es. ome
instructions re:uire no operands and some may re:uire up to = operands. 'ultiple operandsare separated by commas. or example4
*+, H& <0
The number o# operands that are re:uired and their types depend on the instruction or
directi$e that is speci#ied. "n the #ollowing table& the #irst #our operands can also beexpressions. "nstruction operands can be classi#ied as one the #ollowing types4
0!eran# Ty!e Descri!tion
"mmediate *ata ymbols or constants the are used as an numeric $alue.
*irect ,it Address ymbols or constants that re#erence a bit address.
3rogram Addresses ymbols or constants that re#erence a code address.
*irect *ata Addresses ymbols or constants that re#erence a data address.
"ndirect Addresses "ndirect re#erence to a memory location& optionally with o##set.
pecial Assembler ymbol egister names.
S!ecial Assembler Symbols6ome 7 riting Assembly 3rograms 7 pecial Assembler ymbols
The Ax5 assembler de#ines and reser$es names o# the ),- register set. These prede#ined
names are used in ),- programs to access the processor registers. ollowing& is a list o# theeach o# the 805& 80C5'E& and B5 registers along with a brie# description4
1e"ister Descri!tion
A epresents the 805 Accumulator. "t is used with many operations including
multiplication and di$ision& mo$ing data to and #rom external memory& ,ooleanoperations& etc.
DPT1 The *3T register is a F bit data pointer used to address data in E*ATA or
C*/ memory.
PC The 3C register is the F bit program counter. "t contains the address o# the
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 7/65
next instruction to be executed.
C The Carry #lag; indicates the status o# operations that generate a carry bit. "t is
also used by operations that re:uire a borrow bit.
A2 The A and , register pair used in '92 and *" instructions.
13 * 14 The eight 8 bit general purpose 805 registers in the currently acti$e register
ban-. A 'aximum o# #our register ban-s are a$ailable.A13 *A14
epresent the absolute data addresses o# 0 through G in the current register
ban-. The absolute address #or these registers changes depending on theregister ban- that is currently selected. These symbols are only a$ailable when
the 9"<H assembler statement is gi$en. e#er to the 9"<H assemblerstatement #or more in#ormation on selecting the register ban-. These
representations are suppressed by the <A/H directi$e o## the Cx5compiler.
P13%P1-
The 9ni$ersal 3ointer egisters o# the 80C5'E architecture. 9ni$ersal 3ointer
can access the complete F', address space o# the 80C5'E. 30 iscomposed o# registers & B& and =. 3 is composed o# registers 5& F&
and G.
EPT1 Additional extended data pointer register o# the 80C5'E architecture. /3Tmay be used to access the complete memory space.
Imme#iate Data6ome 7 riting Assembly 3rograms 7 "mmediate *ata
An immediate data operand is a numeric expression that is encoded as a part o# themachine language instruction. "mmediate data $alues are used literally in an instruction to
change the contents o# a register or memory location. The pound (or number) sign (I) mustprecede any expression that is to be used as an immediate data operand. The #ollowing
shows some examples o# how the immediate data is typically used4
*L6,7 EU 503 an equate smbol
*+, &4+6+H direct memor access to
*+, &<0E0# load 0'E0 into t#e accumulator
*+, &<0'8000 load 0'8000 into t#e data pointer
?7 &<1H8 ? t#e accumulator 9it# 1H8
O7 &<022# O+ 9it# 0%%#
*+, 5&<*L6,7 load 5 9it# t#e !alue o% *L6,7
Memory Access6ome 7 riting Assembly 3rograms 7 'emory Access
A memory access reads or writes a $alue in to the $arious memory spaces o# the A5
system.
*irect memory access encodes the memory address in the instruction that to reads or
writes the memory. ith direct memory accesses& you may access $ariables in the memoryclass *ATA and ,"T.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 8/65
"ndirect memory accesses uses the content o# a register in the instruction that reads orwrites into the memory. ith indirect address operands it is possible to access all memory
classes o# the A5.
The examples in *ATA and ,"T show how to access the di##erent memory classes o# an A5
system.
DATA6ome 7 riting Assembly 3rograms 7 'emory Access 7 *ATA
'emory locations in the memory class *ATA can be addressed with both direct and indirect
memory accesses. pecial unction egisters () o# the A5 ha$e addresses abo$e 0x80in the *ATA memory class. locations can only be addressed with direct memory
accesses. An indirect memory access to s is not supported in the A5 microcontrollers.
E)am!le or all 53,- ariants
PPm!ar E=*E? de%ine a E=*E? o% class
E= PPm!ar,7UE 1 reser!e 1 DLE in space
4+6+H 003 special %unction register
,7UEH H03 absolute memor location
PPmprog E=*E? C+E de%ine a segment %or program code
E= PPmprog
*+, &4+6+H direct memor access to
&,7UE
*+, ,7UEH&
*+, 1&<,7UE load address o% ,7UE to 1
&Q1 indirect memor access to ,7UE
2IT6ome 7 riting Assembly 3rograms 7 'emory Access 7 ,"T
'emory locations in the memory class ,"T are addressed with the bit instructions o# the
805. The pecial unction egisters () that are located in bit!addressable memorylocations can be addressed with bit instructions. ,it!addressable locations are4 806&
886& ?06& ?86& 0A06& 0A86& 0,06& 0,86& 0C06& 0C86& 0*06& 0*86& 0/06& 0/86& 006&and 086.
E)am!le or all 53,- ariants
PD4Pmbits E=*E? D4 de%ine a E=*E? o% class D4
E= PD4Pmbits
27= D4 1 reser!e 1 Dit in D4 space
1 G03 8051 2 +1
=EE?67E D4 1.H =EE? 7E on 4B+ + 1.H
PPmprog E=*E? C+E de%ine a segment %or program code
E= PPmprog
ED =EE?67E 1.H R 1
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 9/65
>D 27=&is6on direct memor access to
ED 27=
C7 CC.5 reset bit 5 in register
is6on C7 27=
C7 =EE?67E 1.H R 0
IDATA6ome 7 riting Assembly 3rograms 7 'emory Access 7 "*ATA
ariables in this memory class are accessed $ia registers 0 or .
E)am!le or all 53,- ariants
P4Pm!ars E=*E? 4 de%ine a E=*E? o% class 4
E= PEDPmbits
DU22E 100 reser!e 100 Dtes
PPmprog E=*E? C+E de%ine a segment %or program code E= PPmprog
*+, 0&<DU22E load t#e address in 0
*+, &Q0 read memor location bu%%er
4?C 0 increment memor address in 0
*+, Q0& 9rite memor location bu%%erS1
EDATA6ome 7 riting Assembly 3rograms 7 'emory Access 7 /*ATA
The /*ATA memory is only a$ailable in the <E3 80C5'E.
"n the <E3 80C5'E& the /*ATA memory can be accessed $ia /3T or the 9ni$ersal3ointers 30 and 3. 9ni$ersal 3ointers can access any memory location in the F',address space.
E)am!le or N6P 53C,-M6
PEPm6seg E=*E? E de%ine a E=*E? o% class E
E= PEPm6seg
4?= 100 reser!e 100 Dtes
PPmprog E=*E? C+E de%ine a segment %or program code
E= PPmprog
*+, 1&<DLE0 4?= load address o% 4?= in 0
*+, H&<DLE1 4?=
*+, J&<DLEH 4?=
*+, &Q0 load %irst bte o% 4?= in
6DATA6ome 7 riting Assembly 3rograms 7 'emory Access 7 E*ATA
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 10/65
The E*ATA memory class can be accessed with the instruction 'E $ia the register *3T.A single page o# the E*ATA memory can be also accessed $ia the registers 0& . At the C
Compiler le$el this memory type is called !#ata and the segment pre#ix @3*@ is used. Thehigh address #or this pdata page is typically set with the 3B register. ,ut in new 805
$ariants there are also dedicated special #unction registers that de#ine the E*ATA pageaddress.
E)am!le or all 53,- ariants
POPm6seg E=*E? O de%ine a E=*E? o% class O
E= PEPm6seg
ODU22E 100 reser!e 100 Dtes
PPm!ars E=*E? O 4?=E de%ine a paged O segment
E= PPm!ars
,1 1 reser!e 1 bte
PPmprog E=*E? C+E de%ine a segment %or program code
E= PPmprog
*+, H&<34=3 PPm!ars load page address register
*+, &<ODU22E load address
*+,O &Q access !ia
*+, 1&<,1 load address
*+,O Q1& access !ia 0 or 1
C0DE6ome 7 riting Assembly 3rograms 7 'emory Access 7 C*/
C*/ memory can be accessed with the instruction 'C $ia the *3T register.
E)am!le or all 53,- ariants
PC+Pm6seg E=*E? C+E de%ine a E=*E? o% class C+E
E= PC+Pm6seg
D7E D 1&H&T&8&0'10 a table 9it# constant !alues
PPmprog E=*E? C+E de%ine a segment %or program code
E= PPmprog
*+, &<D7E load address o% table
*+, &<J load o%%set into table
*+,C &QS access !ia *+,C instruction
Pro"ram A##resses6ome 7 riting Assembly 3rograms 7 'emory Access 7 3rogram Addresses
3rogram addresses are absolute or relocatable expressions with the memory class C*/ or
/C*/. Typically& program addresses are used in jump and call instructions. or indirect jumps or calls& it is re:uired to load a program address in a register or a jump table. The
#ollowing jumps and calls are possible4
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 11/65
Pro"ramA##resses Descri!tion
SJMP J7 JN7 8 1elatie 9'm!s include conditional jumps (CJNE% DJN7% J2% J2C%JC& J) and the unconditional SJMP instruction. The addressable
o##set is KB8 to LBG bytes #rom the #irst byte o# the instruction
that #ollows the relati$e jump. hen you use a relati$e jump inyour code& you must use an expression that e$aluates to the code
address o# the jump destination. The assembler does all the o##setcomputations. "# the address is out o# range& the assembler will
issue an error message.
ACALL AJMP In:bloc; 9'm!s an# calls permit access only within a BM,yte
bloc- o# program space. The low order bits o# the programcounter are replaced when the jump or call is executed. or *allas
=?0 contiguous mode the bloc- si%e is 5BM, or ? bits. "# ACALL or AJMP is the last instruction in a bloc-& the high order bits o# the
program counter change and the jump will be within the bloc-#ollowing the ACALL or AJMP.
LCALL LJMP Lon" 9'm!s an# calls allow access to any address within aFNM,yte segment o# program space. The low order F bits o# theprogram counter are replaced when the jump or call is executed.
or *allas =?0 contiguous mode4 the bloc- si%e is F', or BN bits.n <E3 80C5'E4 i# LCALL or LJMP is the last instruction in a
FNM,yte segment& the high order bits o# the program counterchange and the jump will into the segment #ollowing the LCALL or
LJMP.
ECALL EJMP E)ten#e# 9'm!s an# calls allow access within the extended
program space o# the <E3 80C5'E.
CALL JMP Generic 9'm!s an# calls are two instruction mnemonics that do
not represent a speci#ic opcode. JMP may assemble to SJMP%
AJMP% LJMP or EJMP. CALL may assemble to ACALL% LCALL orECALL. These generic mnemonics always e$aluate to aninstruction& not necessarily the shortest& that will reach the
speci#ied program address operand.
E)am!le or all 53,- <ariants
EO? C+E (m6%unction)
CE= J
>* e't6int an interrupt !ector
PPmintr E=*E? C+E de%ine a segment %or program code
E= PPmintr
e't6int >D 27=&%lag6+
4?C m6!ar
%lag6+ C7 27=
E4
PPmprog E=*E? C+E 4?D7+C a segment 9it#in a H blocV
E= PPmprog
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 12/65
%unc1 C77 sub6%unc 9ill generate C77
loop C77 m6%unction e'ternal %unction -W 7C77
*+, &m6!ar
>?F loop
E
sub6%unc C7 27= *+, 0&<H0
loop1 C77 m6%unction
>?F 0&loop1
E
E)am!le +ith EJMP% ECALL or N6P 53C,-M6
EO? EC+E2 (m6%ar%unc)
eset EU EC+E 02200003 eset location on H51
PPm6seg E=*E? EC+E de%ine a E=*E? o% class E
E= PPm6seg
%unc1 +C 2 %ar %unction called 9it# EC77
C77 %uncH generates 7C77
C77 m6%ar%unc generates EC77
>?D 2lag&mlab
E>* eset
mlab EE
E?
%uncH +C ?E
C77 m6%ar%unc generates EC77
E E?
E)!ressions an# 0!erators6ome 7 riting Assembly 3rograms 7 /xpressions and perators
An operand may be a numeric constant& a symbolic name& a character string or an
expression.
perators are used to combine and compare operands within your assembly program.
perators are not assembly language instructions nor do they generate A5 assembly code.They represent operations that are e$aluated at assembly time. There#ore& operators can
only handle calculations o# $alues that are -nown when the program is assembled.
An expression is a combination o# numbers& character string& symbols& and operators that
e$aluate to a single =B bit binary number (#or A54 F!bit binary number). /xpressions aree$aluated at assembly time and can& there#ore& be used to calculate $alues that would
otherwise be di##icult to determine be#orehand.
The #ollowing topics describe operators and expressions and how they are used in A5
assembly programs.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 13/65
N'mbers6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 <umbers
<umbers may be speci#ied in hexadecimal (base F)& decimal (base 0)& octal (base 8)& and
binary (base B). The de#ault representation is decimal. A decimal& octal& or binary numbers
#irst character must always be a digit (0!?). 6exadecimal numbers whose #irst character isnot a digit (0!?) must be pre#ixed with a %ero (0).
The base o# a number is speci#ied by the last character in the number. A number that isspeci#ied without an explicit base is interpreted as decimal number.
The #ollowing table illustrates $arious types o# numbers4
2ase S'i) Le"al Characters E)am!les
6exadecimal 6&h 0!?& A!& a!# B=N6 ??6 B=6 0A006 06
*ecimal *&d 0!? B=N F55?0* B0d B=
ctal &o&O&: 0!G GG GGGGo B5 B=o GGGGG
,inary ,&b 0! , 00, 0000,
Note
6exadecimal numbers may be written using C notation. or example& 3)-=A2.
6exadecimal numbers must begin with a 0 i# the #irst digit is A!.
The dollar sign character (D) may be used in numbers to ma-e them more readable
(as long it is not the #irst or last character). or example4
1111;0000;1010;0011D - is equi!alent to - 1111000010100011D
1;H;J;T - is equi!alent to - 1HJT
Characters6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 Characters
AC"" characters may be used in an expression to generate numeric $alues. /xpressionsmay ha$e up to two AC"" characters enclosed in single :uotes (). 'ore than two
characters in an expression causes an error. ollowing are se$eral examples4
E)!ression <al'e
A 00Nh
A, NNBh
a 00Fh
ab FFBh
/rror4 <ull string is in$alid.
A,C /rror4 'ore than B characters.
Characters may be used anywhere in your program as a immediate data operand. orexample4
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 14/65
7EE6 EU KK
E *+, Q0& <K2K
UDD & <K0K
Character Strin"s
6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 Character trings
Character strings can be used in combination with the D2 assembler statement to de#inemessages that are used in your Ax5 assembly program. Character strings must be
enclosed within single :uotes (). or example4
EL*= D Kress an Ve to continue.K
generates the hexadecimal data (50h& GBh& F5h& G=h& G=h& B0h& J F/h& G5h& F5h& B/h)
starting at >EMSG. +ou can mix string and numeric data on the same line. orexample4
E+7*= D KEnd o% lineK& 00#
appends the $alue 00h to the end o# the string En# o line.
Two successi$e single :uote characters can be used to insert a single :uote into a string.
or example4
*=O D K4?KK U+E EU4E 3EEPK.
Location Co'nter
6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 2ocation Counter
The Ax5 assembler maintains a location counter #or each segment which contains the
o##set o# the instruction or data being assembled. The location counter increments a#tereach line by the number o# bytes o# code or data in that line.
The location counter is initiali%ed to 0 #or each segment& but may be changed using the01G statement.
The dollar sign character (D) may be used in an expression to obtain the current $alueo# the location counter. or example& the #ollowing uses the location counter to
determine the length o# a string.
msg D K#is is a messageK& 0
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 15/65
msg6len EU ;-msg
+ou may use the location counter in instructions. or example& the #ollowing creates anin#inite loop4
>* ; N#ile (1)
0!erators6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators
perators may be unary (re:uiring one operand) or binary (re:uiring two operands). The
combination o# an operator and its operand(s) is an expression. 3arentheses may be used inexpressions with multiple operators to speci#y the order in which operators are e$aluated. "#
no parentheses are used in an expression& operator precedence determines the e$aluationorder.
ollowing is the operator precedence table4
M2TE
Leel 0!erators
@
B N0T BIGB L0W2TE3 2TE- 2TE= 2TE
W01D3 W01D=M2TE
= &nary &nary :
N F M0D
5 :
F SBL SB1
G AND 01 601
8 E/ NE H LT H LTE H GT GTE
@ Assembler 0!erator6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators 7 ( )
Synta)
<one.
E)am!le
<one.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 16/65
Assembler 0!erator6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators 7 P
Synta)
operand * operand
Descri!tion
The multiplication operator (P) multiplies the speci#ied absoluteoperands. The result is absolute.
See Also F& M0D
E)am!le
*+, 1&<JXT
*+, H&<GGXT5
Assembler 0!erator6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators 7 L
Synta)
+ operand
operand + operand
Descri!tion
The plus sign (L) is used as the unary plus operator and as the additionoperator.
The unary plus operator is used to assign a positi$e $alue to the speci#ied
operand . This operator does e##ecti$ely nothing to alter the $alue o# the
operand .
The addition operator is used to add the $alues o# two operands which
may be absolute or relocatable. The type o# the resulting expression isdetermined by the operand types as shown in the #ollowing table4
0!eran# Ty!es 1es'ltin" E)!ression Ty!e
absolute L absolute absolute
absolute L relocatable relocatable
relocatable L absolute relocatable
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 17/65
relocatable L relocatable /rror4 <ot allowed.
Note
As a general rule& relocatable expressions must e$aluate to a
relocatable symbol plus or minus an optional constant $alue
(displacement).
See Also :
E)am!le
lab' *+, 1& <1HJTS5MI8
*+, H& lab'S10#
: Assembler 0!erator6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators 7 !
Synta)
- operand
operand1 - operand2
Descri!tion
The minus sign (!) is used as the unary minus operator and as the
subtraction operator.
The unary minus operator is used to change the sign o# the speci#ied
operand . "# the $alue o# the operand is positi$e& the sign is changed to
negati$e. "# the $alue is negati$e& it is changed to positi$e.
The subtraction operator is used to subtract the $alue o# operand2 #romthe $alue o# operand1. The speci#ied operands may be absolute or
relocatable. The type o# the resulting expression is determined by theoperand types as shown in the #ollowing table4
0!eran# Ty!es 1es'ltin" E)!ression Ty!e
absolute ! absolute absolute
absolute ! relocatable /rror4 <ot allowed.
relocatable ! absolute relocatable
relocatable ! relocatable absolute
. elocatable operands are allowed i# both are de#ined in the sameparent section. /xternal operands are not allowed.
Note
As a general rule& relocatable expressions must e$aluate to a
relocatable symbol plus or minus an optional constant $alue
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 18/65
(displacement).
See Also
E)am!le
lab' *+, 1& <5MI8-1HJT
lab *+, H& lab-lab'
F Assembler 0!erator6ome 7 riting Assembly 3rograms 7 /xpressions and perators 7 perators 7 Q
Synta)
operand1 / operand2
Descri!tion
The di$ision operator (Q) di$ides the $alue o# operand1 by the $alue o#
operand2. ,oth operands must be absolute. The result is absolute.
See Also & M0D
E)am!le
*+, 1&<1HBT
*+, H&<GGBG
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 19/65
Control Statements6ome 7 Control tatements
The Ax5 Assembler pro$ides a number o# control statements that permit you to de#ine
symbol $alues& reser$e and initiali%e storage& and control the placement o# your code.
These statements should not be con#used with processor instructions or with assemblerdirecti$es. They do not produce executable code and& with the exception o# the *,& **& and
* statements& they ha$e no direct e##ect on the contents o# code memory. These controlschange the state o# the assembler& de#ine user symbols& and add in#ormation to the object
#ile.
Control statements may be di$ided into the #ollowing categories4
A##ress Control
Statement Descri!tion
E<EN orces the location counter to the next e$en address.
01G ets the location counter to a speci#ies o##set or address.
&SING peci#ies which register ban- to use.
Con#itional Assembly
Statement Descri!tion
I. ,egins an I.:ELSE:ENDI. bloc-.
ELSEI. ,egins an alternate I. bloc-.
ELSE,egins an
ELSE bloc-.
ENDI. Terminates an I. bloc-.
Memory Initialiation
Statement Descri!tion
D2 Allocates memory #or one or more de#ined byte $alues.
DD Allocates memory #or one or more de#ined double word $alues.
DW Allocates memory #or one or more de#ined word $alues.
Memory 1eseration
Statement Descri!tion
D2IT eser$es space #or one or more bits.
DS eser$es space #or one or more bytes.
DS2 eser$es space #or one or more bytes.
DSD eser$es space #or one or more double words.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 20/65
DSW eser$es space #or one or more words.
Proce#'re Declaration
Statement Descri!tion
ENDP *e#ines the end o# a #unction.
LA2EL Assigns an address to a symbolic name.
P10C *e#ines the beginning o# a #unction.
Pro"ram Lin;a"e
Statement Descri!tion
E6TE1N *e#ines external symbols.
E6T1N *e#ines external symbols.
NAME peci#ies the name o# the current module.P&2LIC *e#ines symbols which may be used in other modules.
Se"ment Control
Statement Descri!tion
2SEG *e#ines an absolute bit segment.
CSEG *e#ines an absolute code segment.
DSEG *e#ines an absolute data segment.
ISEG *e#ines an absolute idata segment.
1SEG elects a relocatable segment.
SEGMENT *e#ines a relocatable segment.
6SEG *e#ines an absolute xdata segment.
Symbol Deinition
Statement Descri!tion
2IT *e#ines an address in bit space.
C0DE *e#ines an address in code space.
DATA *e#ines an address in data space.E/& ets a permanent symbol $alue.
IDATA *e#ines an address in idata space.
LIT Assigns a text string to a symbol name.
S2IT *e#ines a bit .
SET ets or resets a symbol $alue.
S.1 *e#ines a byte .
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 21/65
S.1-K *e#ines a word .
6DATA *e#ines an address in xdata space.
Miscellaneo's
Statement Descri!tion
E1101 Henerates an error message.
END ignals the end o# the assembly module.
Note
. This directi$e is a$ailable in the AE5 Assembler only.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 22/65
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 23/65
Symbols an# Symbol Names6ome 7 riting Assembly 3rograms 7 ymbols and ymbol <ames
A symbol is a name that you de#ine to represent a $alue& text bloc-& address& or register
name. +ou can also use symbols to represent numeric constants and expressions.
Symbol Names
ymbols are composed o# up to = characters #rom the #ollowing list4
A >& a %& 0 ?& 1& and @
A symbol name can start with any o# these characters except the digits 0 ?.
ymbols can be de#ined in a number o# ways. +ou may de#ine a symbol to represent an
expression using the E/& or SET control statements4
?U*DE624,E EU 5UE627= E 1
27E627= E 0
+ou may de#ine a symbol to be a label in your assembly program4
7DE71 >?F 0& 7DE71
+ou can de#ine a symbol to re#er to a $ariable location4
E476DU22E GG#
ymbols are used throughout assembly programs. A symbolic name is much easier tounderstand and remember than an address or numeric constant. The #ollowing topics
pro$ide more in#ormation about how to use and de#ine symbols.
Labels
Labels are special cases of symbols. Labels are used only before statements that
have physical addresses associated with them.
Examples of such statements are assembly language instructions, data storage
directives (DB and DW, and data reservation directives (D! and DB"#. Labels must
follow all the rules of symbol creation with the additional re$uirement that they be
followed by a colon. #he following are legal examples of label uses%
#&BLE')'*+#L'*+!#&+#!%
DB -,,/,0,1,2 (Data storage
3E!!&4E% DB 56EL75 (Data storage
8&"&BLE!% D! - (Data reservation
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 24/65
B"#'8&"&BLE!% DB"# 9 (Data reservation
!#&#% 38 &,:/0 (&ssembly language instruction
Directies
The Ax5 Assembler pro$ides a number o# directi$es you may use to control source #ile assembly.*irecti$es are composed o# one or more letters or digits and& unless otherwise speci#ied& may bespeci#ied a#ter the #ilename on the command line or within the source #ile when preceded by a dollarsign (D). or example4
51 *7E.51 L*D+7 EDU=
or
;L*D+7 EDU=
or
;L*D+7
;EDU=
The source #ile to assemble is A'32/.A5 and SM20LS and DE2&G are the directi$es.
Assembler directi$es may be di$ided into two groups4
Primary #irecties are speci#ied on the assembler command line or in #irst #ew lines o# the
assembly source #ile. These directi$es control how the assembler beha$es #or the entire
module. "# con#licting primary directi$es are speci#ied on the command line and in the source#ile& the command line directi$e ta-es precedence.
General #irecties may be speci#ied on the command line or anywhere in the source #ile.
These directi$es control the immediate beha$iour o# the assembler and may be changedduring assembly.
Note
yntax is the same #or directi$es speci#ied on the command line and those speci#ied in the
source #ile.
ome directi$es may not be speci#ied on the command line. "# one o# these directi$es isspeci#ied on the command line& the assembler generates a #atal error and aborts.
The #ollowing table is an alphabetical list o# the control directi$es a$ailable in the Ax5 Assembler.
Directie Gro'! Descri!tion
CASE 3rimary
/nables case!sensiti$e symbol names.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 25/65
C0ND Heneral
"ncludes (in the listing #ile) conditional source lines s-ipped by thepreprocessor.
DATE 3rimary
peci#ies the date to use in the listing #ile header.
DE2&G 3rimary
"ncludes debugging in#ormation in the object #ile.
DE.INE 3rimary
*e#ines C preprocessor symbols on the command line.
EJECT Heneral
"nserts a #orm #eed character into the listing #ile.
ELSE Heneral
Assemble bloc- i# the condition o# a pre$ious I. is #alse.
ELSEI. Heneral
Assemble bloc- i# condition is true and a pre$ious I. or ELSEI. is#alse.
ENDI. Heneral
/nds an I. bloc-.
E1101P1INT 3rimar
y
peci#ies the #ile name #or error messages.
GEN Heneral
"ncludes all macro expansions in the listing #ile.
I. Heneral
Assemble bloc- i# condition is true.
INCDI1 3rimary
ets additional include #ile paths.
INCL&DEB Heneral
"ncludes the contents o# another #ile.
LIST Heneral
"ncludes the assembly source text in the listing #ile.
MAC10 3rimary
/nables preprocessor expansion o# standard macros.
M0DC0NT 3rimary
/nables BN!bit contiguous addressing #or *allas emiconductorde$ices.
M0DM6,- 3rimary
/nables instruction set extensions #or the 3hilips 80C5'Earchitecture.
M0D,- 3rimary
/nables code generation and de#ines s #or classic 805 de$ices.
MPL 3rimary
/nables preprocessor expansion o# '32 macros.
N0AMA>E 3rimary
/xcludes build in#ormation #rom the object #ile.
N0CASE 3rimary
*isables case!sensiti$e symbol names. All symbols are con$ertedto uppercase.
N0C0ND 3rimary
/xcludes (#rom the listing #ile) conditional source lines s-ipped bythe preprocessor.
N0DE2&G 3rimary
/xcludes debugging in#ormation #rom the object #ile.
N0E1101P1INT 3rimary
*isables error messages output to the screen.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 26/65
N0GEN Heneral
/xcludes macro expansions #rom the listing #ile.
N0LINES 3rimary
/xcludes line number in#ormation #rom the generated objectmodule.
N0LIST Heneral
/xcludes the assembly source text #rom the listing #ile.
N0MAC10 3rimary
*isables preprocessor expansion o# standard and '32 macros.
N0M0D,- 3rimary
uppresses s de#initions #or classic 805 de$ices
N0MPL 3rimary
*isables preprocessor expansion o# '32 macros.
N002JECT 3rimary
*isables object #ile generation.
N0P1INT 3rimary
*isables listing #ile generation.
N01EGISTE12AN
>
3rimar
y
*isables memory space reser$ation #or register ban-s.
N0SM20LS 3rimary
/xcludes the symbol table #rom the listing #ile.
N0SMLIST Heneral
/xcludes subse:uently de#ined symbols #rom the symbol table.
N061E. 3rimary
/xcludes the cross!re#erence table #rom the listing #ile.
02JECT 3rimary
peci#ies the name #or the object #ile.
PAGELENGTB 3rimary
peci#ies the number o# lines on a page in the listing #ile.
PAGEWIDTB 3rimary
peci#ies the number o# characters on a line in the listing #ile.
P1INT 3rimary
peci#ies the name #or the listing #ile.
1EGISTE12AN> 3rimary
eser$es memory space #or register ban-s.
1EG&SE Heneral
peci#ies registers modi#ied by the speci#ied #unction.
1ESET Heneral
ets symbols& which may be tested by I. or ELSEI.& to #alse.
1EST01E Heneral
estores settings #or the LIST and GEN directi$es.
SA<E Heneral
a$es settings #or the LIST and GEN directi$es.
SET Heneral
ets symbols& which may be tested by I. or ELSEI.& to true or aspeci#ied $alue.
SM20LS 3rimary
"ncludes the symbol table in the listing #ile.
SMLIST Heneral
"ncludes subse:uently de#ined symbols in the symbol table.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 27/65
TITLE 3rimary
peci#ies the page header title in the listing #ile.
61E. 3rimary
"ncludes the cross!re#erence table in the listing #ile.
Note
. These directi$es may not be speci#ied on the command line. They may only be speci#ied in thesource #ile.
B. 3rimary directi$es may not be speci#ied a#ter an INCL&DE directi$e.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 28/65
Control tatements
The Ax5 Assembler pro$ides a number o# control statements that permit you to de#ine symbol
$alues& reser$e and initiali%e storage& and control the placement o# your code.
These statements should not be con#used with processor instructions or with assembler directi$es.
They do not produce executable code and& with the exception o# the *,& **& and * statements& they
ha$e no direct e##ect on the contents o# code memory. These controls change the state o# the
assembler& de#ine user symbols& and add in#ormation to the object #ile.
Control statements may be di$ided into the #ollowing categories4
A##ress Control
Statement Descri!tion
01G ets the location counter to a speci#ies o##set or address.
&SING peci#ies which register ban- to use.
Con#itional Assembly
Statement Descri!tion
I. ,egins an I.:ELSE:ENDI. bloc-.
ELSEI. ,egins an alternate I. bloc-.
ELSE ,egins an ELSE bloc-.
ENDI. Terminates an I. bloc-.
Memory Initialiation
Statement Descri!tion
D2 Allocates memory #or one or more de#ined byte $alues.
DW Allocates memory #or one or more de#ined word $alues.
Memory 1eseration
Statement Descri!tion
D2IT eser$es space #or one or more bits.
DS eser$es space #or one or more bytes.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 29/65
Pro"ram Lin;a"e
Statement Descri!tion
E6T1N *e#ines external symbols.
NAME peci#ies the name o# the current module.
P&2LIC *e#ines symbols which may be used in other modules.
Se"ment Control
Statement Descri!tion
2SEG *e#ines an absolute bit segment.
CSEG *e#ines an absolute code segment.
DSEG *e#ines an absolute data segment.
ISEG *e#ines an absolute idata segment.
1SEG elects a relocatable segment.
SEGMENT *e#ines a relocatable segment.
6SEG *e#ines an absolute xdata segment.
Symbol Deinition
Statement Descri!tion
2IT *e#ines an address in bit space.
C0DE *e#ines an address in code space.
DATA *e#ines an address in data space.
E/& ets a permanent symbol $alue.
IDATA *e#ines an address in idata space.
S2IT *e#ines a bit .
SET ets or resets a symbol $alue.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 30/65
S.1 *e#ines a byte .
S.1-K *e#ines a word .
6DATA *e#ines an address in xdata space.
Miscellaneo's
Statement Descri!tion
E1101 Henerates an error message.
END ignals the end o# the assembly module.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 31/65
01G Assembler Statement
Synta) ORG expression
Descri!tion The 01G statement alters the location counter #or the current segment and sets a
new origin #or subse:uent statements. The expression must be a simplerelocatable expression with no #orward re#erences. nly absolute addresses orsymbol $alues in the current segment may be used. The dollar!sign character (D)&which represents the current $alue o# the location counter& may be used in theexpression.
hen the 01G statement is encountered& the assembler calculates the $alue o# theexpression and changes the location counter.
"# the 01G statement appears in an absolute segment& the location counteris assigned the absolute address $alue speci#ied. The location counter maynot be set to an address below the base address o# the segment.
"# the 01G statement appears in a relocatable segment& the location
counter is assigned the o##set o# the speci#ied expression. or example& i#the relocatable segment starts at address 000h and i# the 01G
expression has a $alue o# B=Nh& the absolute address o# the nextstatement is BB=Nh (000h L B=Nh).
The 01G statement changes the location counter& which may create a gap& butdoes not create a new segment.
Note
"t is possible to use the 01G statement to change the location counter and
o$erwrite (or o$erlay) existing code or data. This is supported because o#legacy programs that used this techni:ue to de#ine multiple $ariables at thesame physical address. <o warning is generated i# the 01G statement isused this way.
See Also SEGMENT
E)am!le += 100#
+= E
+= EO41+= (; S 15) ? 02220#
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 32/65
&SING Assembler Statement
Synta) USING expression
Descri!tion The &SING statement speci#ies the register ban- (0!=) expression to use #or
encoding the A13:A14 registers. The register ban- selected is noted in theobject #ile and the memory area is reser$ed by the lin-er.
ome 805 instructions (li-e P&SB and P0P) allow only absolute addresses to be
used. The assembler replaces absolute registers (A13:A14) with the physicaladdress o# the register in the current register ban-. o& while the instruction P&SB13 is not $alid& P&SB A13 is $alid. 6owe$er& the assembler must -now whichregister ban- is used so that the correct physical address is calculated. This is thepurpose #or the &SING statement.
The &SING statement does not generate any code to switch the current register
ban-. The assembler program must select the correct register ban-. or example&the #ollowing code selects register ban- B4
U3 N sa!e t#e current register banV
*+, N& <(H 37 J) set register banV H
.
.
.
+ N restore sa!ed register banV
The physical address is calculated as #ollows4
@re"ister ban; 5 re"ister
Note
/xercise caution when using the E/& statement to de#ine a symbol #or an
absolute register (A13:A14). hen using E/&& the symbol $alue iscalculated at the time it is de#ined (not when it is used). "# the registerban- is subse:uently changed with the &SING statement& the de#inedsymbol will ha$e the incorrect address and the code generated is li-ely to#ail.
E)am!le U4?= J select register banV J
U3 H pus# H in banV J (address 1#)
U4?= 1 select register banV 1
U3 I pus# I in banV 1 (address 12#)
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 33/65
D2 Assembler Statement
Synta) @ label A DB expression @ & expression ... A
Descri!tion The D2 statement initiali%es memory with one or more byte $alues. label is a
symbol that is assigned the current memory address. expression is a byte $aluethat is stored in memory. /ach expression may be a symbol& a string& or anexpression.
The D2 statement may be speci#ied only within a code or const segment. An erroris generated i# it is used in a di##erent segment.
See Also D2IT& DD& DS& DS2& DSD& DSW& DW
E)am!le *= D Kress e o ContinueK& 0
D D H& J& 5& I& 11& 1J& 1I& 1G& KK
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 34/65
D2IT Assembler Statement
Synta) @ label A DBIT expression
Descri!tion The D2IT statement reser$es the speci#ied number o# bits in a bit or ebit segment.
label is a symbol that is assigned the current memory address. expression is thenumber o# bits to reser$e.
This statement reser$es space in the current memory space and increments thelocation counter by the number o# bits reser$ed.
See Also DS& DS2& DSD& DSW
E)am!le 627= D4 1
D627= D4 1
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 35/65
DS Assembler Statement
Synta) @ label A DS expression
Descri!tio
n The DS statement reser$es the speci#ied number o# bytes in the current memoryspace. label is a symbol that is assigned the current memory address. expression isthe number o# bytes to reser$e.
This statement reser$es space and increments the location counter by the numbero# bytes reser$ed.
Note
See Also D2IT& DS2& DSD& DSW
E)am!le = ((; S 15) ? 02220#) - ; 1M-bte alignment
10
4*E 8
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 36/65
E6T1N Assembler Statement
Synta) EO? class (symbol @ & symbol ... A)
Descri!tion
The E6T1N statement (which may appear anywhere in the assembler source #ile)speci#ies symbol s that the current source #ile uses but which are de#ined in otherobject modules. The module where the symbol s are de#ined must export them usinga P&2LIC statement.
alid classes are4
class Descri!tion
2IT A symbol located in ,"T memory space.
C0DE A symbol located in C*/ space.
DATA A symbol located in *ATA space.
IDATA A symbol located in "*ATA memory.
6DATA A symbol located in E*ATA memory.
N&M2E1 A symbol located in any memory space.
The lin-er resol$es all external symbols and $eri#ies that the classes and typesmatch. ymbols whose class is N&M2E1 match any memory class.
See Also E6TE1N& P&2LIC
E)am!le EO? C+E (main)
EO? ?U*DE (tabsi"e)
EO? (counter)
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 37/65
DW Assembler Statement
Synta) @ label A DW expression @ & expression ... A
Descri!tion The DW statement initiali%es memory with one or more word (B!byte) $alues. label
is a symbol that is assigned the current memory address. expression is a word$alue that is stored in memory. /ach expression may be a symbol& a string& or anexpression.
The DW statement may be speci#ied only within a code or const segment. An erroris generated i# it is used in a di##erent segment.
See Also D2& D2IT& DD& DS& DS2& DSD& DSW
E)am!le D7E N D7E& D7ES10& 3EE
3EE N 0
CD N CE0& CE1& CEH& CEJ
N ;
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 38/65
2SEG Assembler Statement
Synta) BSEG @ address A
Descri!tion The 2SEG statement selects an absolute segment within ,"T space.
"# the optional address is included& the assembler starts the absolute segment #romthat address. The $alid address range is B0h!Bh.
"# the optional address is omitted& the assembler starts the absolute segment #romaddress 0 (i# no prior absolute ,"T segment was de#ined). "# an absolute ,"T segmentwas pre$iously de#ined& the assembler continues #rom the end o# that segment.
Note
The start address must be an absolute expression.
The AE5 Assembler con$erts ,/H statements into the #ollowing4
PD4PmodulenamePn E=*E? +22 address
Where
modulename is the name o# the source #ile.
n is a se:uential number.
address is the address speci#ied in the ,/H statement.
See Also 2IT& CSEG& DSEG& ISEG& 6SEG
E)am!le DE= 10 absolute D4 segment at 0'H0S10 bits R
0'H1.H
EC627= D4 1 absolute bit 9it# t#e name EC627=
4?C627= D4 1 absolute bit 9it# t#e name 4?C627=
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 39/65
CSEG Assembler Statement
Synta) CSEG @ address A
Descri!tion The CSEG statement selects an absolute segment within C*/ space.
"# the optional address is included& the assembler starts the absolute segment #rom thataddress. The $alid address range is 0000h!0h.
"# the optional address is omitted& the assembler starts the absolute segment #romaddress 0 (i# no prior absolute C*/ segment was de#ined). "# an absolute C*/segment was pre$iously de#ined& the assembler continues #rom the end o# thatsegment.
Note
The start address must be an absolute expression.
The AE5 Assembler con$erts C/H statements into the #ollowing4
PC+PmodulenamePn E=*E? +22 address
Where
modulename is the name o# the source #ile.
n is a se:uential number.
address is the address speci#ied in the C/H statement.
See Also 2SEG& C0DE& DSEG& ISEG& 6SEG
E)am!le CE= 000J# absolute code segement at address 0'J
,EC60 7>* 460 jump instruction %or t#e interrupt !ector
location
CE= 0'100 absolute code segment at address
0'100
Cig#t D Y(C) *CompanY coprig#t string at %i'ed
location
CE 10003 absolute code segment at address
0'1000
arit6D table 9it# t#e name arit6D
D 003 %i'ed encoding %or parit
in%ormation
D 013
D 013
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 40/65
D 003
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 41/65
DSEG Assembler Statement
Synta) DSEG @ address A
Descri!tio
n The DSEG statement selects an absolute segment within *ATA space.
"# the optional address is included& the assembler starts the absolute segment #rom thataddress. The $alid address range is 00h!0h (data memory resides #rom 00h!Gh ands reside #rom 80h!0h).
"# the optional address is omitted& the assembler starts the absolute segment #romaddress 0 (i# no prior absolute *ATA segment was de#ined). "# an absolute *ATAsegment was pre$iously de#ined& the assembler continues #rom the end o# thatsegment.
Note
The start address must be an absolute expression.
The AE5 Assembler con$erts */H statements into the #ollowing4
PPmodulenamePn E=*E? +22 address
Where
modulename is the name o# the source #ile.
n is a se:uential number.
address is the address speci#ied in the */H statement.
E)am!le E= 0'T0 absolute segment at T03
*6 H absolute data 9ord !ariable 9it# name
*6
E*6D T absolute data d9ord (JH-bit) !ariable 9it# name
*6D
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 42/65
ISEG Assembler Statement
Synta) ISEG @ address A
Descri!tion
The ISEG statement selects an absolute segment within "*ATA space.
"# the optional address is included& the assembler starts the absolute segment #romthat address. The $alid address range is 00h!0h.
"# the optional address is omitted& the assembler starts the absolute segment #romaddress 0 (i# no prior absolute "*ATA segment was de#ined). "# an absolute "*ATAsegment was pre$iously de#ined& the assembler continues #rom the end o# thatsegment.
Note
The start address must be an absolute expression.
The AE5 Assembler con$erts "/H statements into the #ollowing4
P4PmodulenamePn E=*E? +22 address
Where
modulename is the name o# the source #ile.
n is a se:uential number.
address is the address speci#ied in the "/H statement.
See Also 2SEG& CSEG& DSEG& IDATA& 6SEG
E)am!le 4E= 0'C0 absolute 4 segment at 0C03
*64 H absolute idata 9ord !ariable
9it# name *64
E*64D T absolute idata d9ord (JH-bit)
!ariable 9it# name *64D
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 43/65
/H'/<T Assembler tatement
Synta) segname SEGMENT class relocation alignment
Descri!ti
on
The SEGMENT statement declares a generic segment along with memory class and
segment location options.
Where
segnam
e
speci#ies the symbol name to assign to the segment. This symbol is re#erences
by subse:uent 1SEG statements. "t may also be used in expressions to
represent the base or starting address o# the combined segment.
class is the memory classi#ication #or the segment. The class speci#ies the memory
space where the segment is located.
relocati
on
determines what relocation options are a$ailable to the lin-er #or this segment.
alignme
nt
determines what address alignment options are a$ailable to the lin-er #or this
segment.
The name o# each segment in a source module must be uni:ue. The lin-er combines
segments that ha$e the same type.
Class
The segment class speci#ies the memory space #or the segment and is used by the lin-er
to access all segments that belong to that class. The #ollowing table lists the basicclasses.
class Descri!tion
2IT The ,"T address space (#rom B0h!Bh).
C0DE The C*/ address space (#rom 0000h!0h).
DATA The *ATA address space (#rom 00h!Gh).
IDATA The "*ATA address space (#rom 00h!0h).
6DATA The E*ATA address space (#rom 0000h!0h).
ollowing are a #ew examples o# segments de#ined using the basic classes.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 44/65
seg1 E=*E? O
segJ E=*E?
1elocation
The relocation type speci#ies how the lin-er may relocate the segment. The #ollowing
table lists the $alid -inds o# relocation.
relocation Descri!tion
2ITADD1ESS
A2LE
speci#ies that the segment is located in bit!addressable memory.
This relocation type is allowed only #or segments in the *ATA class
whose length does not exceed F bytes.
IN2L0C> speci#ies that the segment must be located in a single B0N8!byte
bloc-. This relocation type may be speci#ied only #or segments in the
C*/ class. This is typically used #or segments with routines that
use ACALL and AJMP instructions.
INPAGE speci#ies that the segment must be located in a single B5F!byte
page.
0<E1LAA2L
E
speci#ies that the segment may be o$erlaid with and share the
memory o# other segments. egments declared with the
0<E1LAA2LE relocation type may be o$erlaid with each other.
0<E1LAA2LE segments must be declared using the naming
con$entions o# the C5.
Ali"nment
The alignment is optional and speci#ies how the lin-er allocates the segment. The
#ollowing table lists the $alid alignment types.
alignm
ent Descri!tion
2IT speci#ies bit alignment #or the segment. This is the de#ault #or all segments
with the class 2IT.
2TE speci#ies byte alignment #or the segment. This is the de#ault #or all
segments& except #or segments with the class 2IT.
PAGE speci#ies B5F!byte page alignment #or the segment. The segment start
must be on a B5F!byte page boundary.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 45/65
See Also 2SEG& CSEG& DSEG& ISEG& 1SEG& 6SEG
E)am!le a segment 9it# t#e name P4P4 and t#e memor class 4.
P4P4 E=*E? 4
a segment 9it# t#e name POPDC in t#e memor class O. #e
alignment =E %orces to segment to start on a H5M bte page
boundar.
POPD E=*E? O =E
1SEG Assembler Statement
Synta) RSEG segment
Descri!tion The 1SEG statement selects a relocatable segment that was pre$iously declared using
the SEGMENT statement.
See Also SEGMENT
E)am!le *L+= E=*E? C+E eclare t#e segment
E= *L+= elect t#e segment
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 46/65
/.;. Bit &ddressing
#he period (. has special meaning to the *ross &ssembler when
used in a symbol. "t is used to explicitly specify a bit in a
bit<addressable symbol. )or example, it you wanted to specify
the most signi=cant bit in the &ccumulator, you could write
&**.;, where &** was previously de=ned as the &ccumulator
address. #he same bit can also be selected using the physical
address of the byte it5s in. )or example, the &ccumulator5s
physical address is //1. #he most signi=cant bit of the
&ccumulator can be selected by specifying //1.;. "f the symbol
+ was de=ned to be e$ual to the value ;, you could also specify
the same bit by either &**.+ or //1.+.
/.>. &!*"" Literals
7rintable characters from the &!*"" character set can be used
directly as an immediate operand, or they can used to de=ne
symbols or store &!*"" bytes in 7rogram 3emory. !uch use of the
&!*"" character set is called &!*"" literals. &!*"" literals are
identi=ed by the apostrophe (5 delimiter. #he apostrophe
itself can be used as an &!*"" literal. "n this case, use two
apostrophes in a row. Below are examples of using &!*""
literals.
38 &,:5m5 ?Load & with -9D6 (&!*"" m
@A#E E@A 5555 ?@A#E de=ned as /;6 (&!*"" single $uote
DB 5>-25 ?!tore in 7rogram 3emory
/.. *omments
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 47/65
*omments are user de=ned character strings that are not
processed by the *ross &ssembler. & comment begins with a
semicolon ( ? and ends at the carriage returnCline feed pair
that terminates the line. & comment can appear anywhere in a
line, but it has to be the last =eld. #he following are
examples of comment lines%
? Begin initialiation routine here
#"#LE(>-2 7rogram 8ers. .- ?7lace version number here
#E+ E@A - ?*onstant
? *omment can begin anywhere in a line
38 &,!erial'7ort'BuFer ? 4et character
/.-. #he Location *ounter
#he *ross &ssembler Geeps a location counter for each of the =ve
segments (code, internal data, external data, indirect internal
data and bit data. Each location counter is initialied to ero
and can be modi=ed using &ssembler Directives described in
*hapter 2.
#he dollar sign ( can be used to specify the current value of
the location counter of the active segment. #he following are
examples of how this can be used%
H+B )L&4, ?Hump on self until Iag is reset
*7J46#% DB 5*opyright, >05
*7J46#'LE+4#6
E@A <*7J46#< ?*alculate length of copyright message
/./. +umbers and perators
#he *ross &ssembler accepts numbers in any one of four radices%
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 48/65
binary, octal, decimal and hexadecimal. #o specify a number in a
speci=c radix, the number must use the correct digits for the
particular radix and immediately following the number with its
radix designator. Decimal is the default radix and the use of
its designator is optional. &n hexadecimal number that would
begin with a letter digit must be preceded by a - (ero to
distinguish it from a symbol. #he internal representation of
numbers is 9<bits, which limits the maximum number possible.
#able /<1 summaries the radices available.
3&K"3A3 LE4&L
&D"K DE!"4+&# LE4&L D"4"#! +A3BE
<<<<<<<<<<< <<<<<<<<<< <<<<<<<<<<<< <<<<<<<<<<<<<<<<<
Binary B -, B
ctal ,@ -,,/,0,1,2, ;;;;;
9,; ;;;;;@
Decimal D,(default -,,/,0,1,2, 92202D
9,;,>, 92202
6exadecimal 6 -,,/,0,1,2, -))))6
9,;,>,,&,B,
*,D,E,)
#able /<1% *ross &ssembler adices
+o spaces or tabs are allowed between the number and the radix
designator. #he letter digits and radix designators can be in
upper or lower case. #he following examples list the decimal
number /2; in each of the available radices%
-----B (Binary
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 49/65
292o or 292@ (ctal
/2; or /2;D (Decimal
-B>D6, -b>dh (6exadecimal
When using radices with explicit bit symbols, the radix
designator follows the byte portion of the address as shown in
the following examples%
-E-6.; Bit seven of hexadecimal address -E-
/--@.+ Bit + of octal address /--
#he *ross &ssembler also allows assembly time evaluation of
arithmetic expressions up to thirty<two levels of embedded
parentheses. &ll calculations use integer numbers and are done
in sixteen bit precision.
7E&# !J3BL 7E&#"+
<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<
&ddition
Anary positive
< !ubtraction
Anary negation (/5s complement
M 3ultiplication
C "nteger division (no remainder
3D 3odulus (remainder of integer division
!6 !hift right
!6L !hift left
+# Logical negation (5s complement
&+D Logical and
"nclusive or
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 50/65
K Exclusive or
LW Low order ><bits
6"46 6igh order ><bits
E@, N elational e$ual
+E, OP elational not e$ual
4#, P elational greater than
4E, PN elational greater than or e$ual
L#, O elational less than
LE, ON elational less than or e$ual
( 7arenthetical statement
#able /<2% &ssembly #ime perations
#he relational operators test the speci=ed values and return
either a #rue or )alse. )alse is represented by a ero value,
#rue is represented by a non ero value (the #rue condition
actually returns a 9<bit value with every bit set? i.e.,
-))))6. #he relational operators are used primarily with the
*onditional &ssembly capability of the *ross &ssembler.
#able /<2 lists the operations available while #able /<9 lists
the operations precedence in descending order. perations with
higher precedence are done =rst. perations with e$ual
precedence are evaluated from left to right.
7E&#"+ 7E*EDE+*E
<<<<<<<<< <<<<<<<<<<
(, 6"46E!#
6"46,LW
M,C,3D,!6,!6L
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 51/65
,<
E@,L#,4#,LE,4E,+E,N,O,P,ON,PN,OP
+#
&+D
,K LWE!#
#able /<9% perators 7recedence
#he following are examples of all the available operations and
their result%
6"46(-&&DD6 will return a result of -&&6
LW(-&&DD6 will return a result of -DD6
;M1 will return a result of />
;C1 will return a result of
; 3D 1 will return a result of 0
---B !6 / will return a result of ---B
--B !6L / will return a result of ----B
-2 will return a result of 2
;/ will return a result of ;/
/2<; will return a result of >
< will return a result of B
+# will return a result of -B
; E@ 1, ; N 1 will return a result of -
; L# 1, ; O 1 will return a result of -
; 4# 1, ; P 1 will return a result of -))))6
; LE 1, ; ON 1 will return a result of -
; 4E 1, ; PN 1 will return a result of -))))6
; +E 1, ; OP 1 will return a result of -))))6
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 52/65
-B &+D --B will return a result of --B
-B --B will return a result of -B
-B K --B will return a result of ---B
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 53/65
Classic 53,-6ome 7 Architecture $er$iew 7 'emory Classes and 2ayout 7 Classic 805
The #ollowing table shows the memory classes used #or programming the classic 805
architecture. These memory classes are a$ailable when you are using the A5 macro
assembler and the ,25 lin-erQlocater.
MemoryClass A##ress 1an"e Descri!tion
*ATA *400 K *4G *irect addressable on chip A'.
,"T *4B0 K *4B bit addressable A'; accessed bit instructions.
"*ATA "400 K "4 "ndirect addressable on chip A'; can be
accessed with R0 or R.
E*ATA E40000 K E4 FN M, A' (readQwrite access). Accessed with'E instruction.
C*/ C40000 K C4 FN M, ' (only read access possible). 9sed #orexecutable code or constants.
,A<M 0J ,A<M =
,040000 K ,04,=40000 K
,=4
Code ,an-s #or expanding the program code spaceto =B x FNM, '.
Note
The memory pre#ix *4 "4 E4 C4 ,04 .. ,=4 cannot be used at Ax5 assembler or
,25 lin-erQlocater le$el. The memory pre#ixes are only listed #or better understanding.
e$eral *ebugging tools& #or example the Sision *ebugger& are using memory pre#ixesto identi#y the memory class o# the address.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 54/65
Classic 53,- Memory Layo't6ome 7 Architecture $er$iew 7 'emory Classes and 2ayout 7 Classic 805 'emory 2ayout
The classic 805 memory layout& shown in the #ollowing #igure& is #amiliar to 805 users the
world o$er.
The classic 805 architecture includes the #ollowing memory classes.
2IT% DATA% an# IDATA
The 2IT& DATA& and IDATA memory classes comprise the on!chip memory o# the 805architecture and are shown in the #ollowing #igure.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 55/65
C0DE an# C0NST
The C0DE and C0NST memory classes are typically stored in ' that may be either o##!chip or on!chip. The C0DE memory class is used #or the actual program code while the
C0NST memory class is used #or constant $ariables declared in co#e space.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 56/65
"n addition& up to =B code ban-s may be used #or code ban-ing applications. hile these are
technically located in code space& they are assigned their own address space.
6DATA an# PDATA
The 6DATA memory class is typically stored in A' that may be o##!chip or on!chip (on
newer de$ices). "t contains external program data (named because it was o##!chip on theoriginal 805 de$ices) including $ariables declared with the )#ata and !#ata memory
types.
The PDATA memory class is a B5F!byte page within the 6DATAmemory class.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 57/65
E)ten#e# 53,- <ariants6ome 7 Architecture $er$iew 7 'emory Classes and 2ayout 7 /xtended 805 ariants
e$eral new $ariants o# the 805 extend the code andQor xdata space o# the classic 805
with address extension registers.
The #ollowing table shows the memory classes used #or programming the extended 805de$ices. These memory classes are a$ailable #or classic 805 de$ices when you are using
memory ban-ing with the 2E5 lin-erQlocater. "n addition to the code ban-ing -nown #romthe ,25 lin-erQlocater& the 2E5 lin-erQlocator supports also data ban-ing #or xdata and
code areas with standard 805 de$ices.
MemoryClass A##ress 1an"e Descri!tion
*ATA *400 K *4G *irect addressable on chip A'.
,"T *4B0 K *4B bit addressable A'; accessed bit instructions.
"*ATA "400 K "4 "ndirect addressable on chip A'; can be
accessed with R0 or R.E*ATA E40000 K E4 FN M, A' (readQwrite access). Accessed with
'E instruction.
6*ATA E40000 K E4 F ', A' (readQwrite access). Accessed with
'E instruction and extended *3T.
C*/ C40000 K C4 FN M, ' (only read access possible). 9sed #orexecutable code or constants.
/C*/ C40000 K C4 F ', ' (only read access possible). 9sed #orconstants. "n some modes o# the *allas =?0
architecture also program execution is possible. .
,A<M 0
J ,A<M =
,040000 K ,04
,=40000 K,=4
Code ,an-s #or expanding the program code space
to =B x FNM, '.
Note
The memory pre#ixes *4 "4 E4 C4 ,04 .. ,=4 cannot be used at Ax5 assembler
le$el. The memory pre#ix is only listed #or better understanding. The 2x5 lin-erQlocaterand se$eral *ebugging tools& #or example the SisionB *ebugger& are using memory
pre#ixes to identi#y the memory class o# the address.
"# you are using the *allas =?0 contiguous mode the address space #or C*/ can be
C40000 ! C40x.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 58/65
E)ten#e# 53,- Memory Layo't6ome 7 Architecture $er$iew 7 'emory Classes and 2ayout 7 /xtended 805 'emory 2ayout
The extended 805 805 architecture includes the #ollowing memory classes.
2IT% DATA% an# IDATA
The 2IT& DATA& and IDATA memory classes comprise the on!chip memory o# the 805architecture and are shown in the #ollowing #igure.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 59/65
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 60/65
C0DE% EC0DE% an# Memory 2an;s
The C0DE and EC0DE memory classes are typically stored in ' that may be either o##!chip or on!chip. The C0DE memory class may be used #or program code and re#ers to the
#irst FNM (or ,an- 0) o# this read!only memory area.
The EC0DE memory class is used #or constant $ariables declared in co#e space abo$e the
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 61/65
#irst FNM o# '.
"n se$eral $ariants the *3T register is expanded to a BN!bit register with an DP6 . orexample& the *allasQ'axim =?0 pro$ides new operating modes where this addressing is
enabled. +ou may e$en use the 6C<T and 6*ATA memory classes with classic 805de$ices by using the memory ban-ing a$ailable in 2E5.
2an; 3 through 2an; K allow your program to expand up to N 'bytes when using
memory ban-ing.
6DATA an# BDATA
The 6DATA memory class re#ers to the #irst FNM o# A' which may be o##!chip or on!chip.
The BDATA memory class is used when A' memory re:uirements exceed FNM bytes. Thismemory class allows you to de#ine up to F 'bytes
o# $ariable data.
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 62/65
2( 1esere# Symbols6ome 7 Appendix 7 ,. eser$ed ymbols
The Ax5 assembler uses prede#ined or reser$ed symbols that may not be rede#ined in your
program. eser$ed symbol names include instruction mnemonics& directi$es& operators& and
register names. The #ollowing lists the reser$ed symbol names that are #ound in all Ax5$ariants4
A
A,
ACA22
A**
A**C
A'3
A<*
A<2
A0
A
AB
A=
AN
A5
AF
AG
,"T
,"TA**/A,2/
,2CM
,/H
C
CA22
C</
C2
C'3
C*/
C32
C/H
*A
*ATA
*,
*,"T
*3T
*
*/H
*
/2/
/2/"
/<*
/<*"
/<*'
/<*3
/O
/O9
/E"T'
/ET<
H/
HT
6"H6
"*ATA "
"<,2CM
"<C
"<3AH/
"</H
"3
"3C
"/H
,
,C
C
/
H
2/
'3
</
<>
H
H/
2
2/
>
2CA22
2/
2'3
2CA2
2
2T
'AC
'*
'
'C
'E '92
<A'/
</
<3
<T
<92
<9',/
H
2
/2A+A,2/
3AH/
3C
33
39,2"C
B
=
N
5
F
G
/3T
/T
/T"$
2
2C
C
/H
/H
/H'/<T
/T /T,
62
6
'3
9,
9,,
A3
9<"T
9"<H
EC6
EC6*
E*ATA
E
E2
E/H
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 63/65
*/C
*"
*<>
<,
<C
396
0
The A5 assembler de#ines the #ollowing additional reser$ed symbols which are special
#unction registers () o# the classic 805 'C9. These de#initions may be disabledusing the N0M0D,- control statement. The prede#ined symbols are reser$ed symbols
and may not be rede#ined in your program.
AC
ACC$
,
C+
*36
*32
/A /
/T0
/T
/E0
/E
0
"/
"/0
"/
"<T0
"<T
"T0
"T
3
30 3
3B
3=
3
3
3T0
3T
3E0
3E
,8
*
/<
"
0
E* ,9
C<
'0
'
'B
3
T
T,8
TC<
T0
T
T60
T6
T"
T20
T2 T'*
T
T0
T
TE*
The AE5 assembler de#ines the #ollowing additional reser$ed symbols which comprise the
additional instructions and registers o# the 3hilips 80C5'E architecture.
AT
,+T/
,+T/0
,+T/
,+T/B
,+T/=
C<T
**
*,
**
*
**
/CA22
/C*/
/*ATA
/'3
/'
/3T
//T
//<
/ET/<
A
6C<T
6*ATA
2A,/2
2"T
',+T/
</A
30
3
3C
*
*0
*B
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 64/65
A,- ADD1ESSING 2ITS AND 2TES
"n#ormation in this support solution applies to4
A5 ersion 5.50
/&ESTI0N
6ow do " address a bit!addressable byte as both bits and a byte in assembly@
ANSWE1
6ere is the code that shows the code #or addressing bit addressable internal memory as bitsand bytes
NAME TEST
?PR?main?TEST SEGMENT CODE
?BA?TEST SEGMENT DATA BITADDRESSABLE
EXTRN CODE (?C_STARTUP)
PUBLIC bit0
PUBLIC byte
PUBLIC main
RSEG ?BA?TEST
byte: DS 1
bit0 EQU (byte+0).0
RSEG ?PR?main?TEST
USING 0
main:
SETB bit0
?C0001:
SJMP ?C0001
RET
END
M01E IN.01MATI0N
To add other bits just duplicate the /O9 to represent the remaining locations.
SEE ALS0
7/23/2019 What is an Assembler3
http://slidepdf.com/reader/full/what-is-an-assembler3 65/65
A54 ,"T!A**/A,2/ *ATA A"A,2/
A54 / AG ("<A2"* ,+T/ ,A/ "< ,"T A**/ /E3/"<)