Che materia stai cercando?

Calcolatori Elettronici I – Commandline Assembler Appunti scolastici Premium

Appunti di Calcolatori Elettronici ICommandline Assembler. Nello specifico gli argomenti trattati sono i seguenti: Source Code Format, Source Line Format, Assembly Details, Assembler Directives, ORG - Set Origin, Symbol Definition Directives, ecc.

Esame di Calcolatori elettronici I docente Prof. R. Canonico

Anteprima

ESTRATTO DOCUMENTO

68kasm

2.3.1.5 ASCII Constants

An ASCII constant consists of one to four ASCII characters

enclosed in single quote marks. If it is desired to put a single

quote mark inside an ASCII constant, then two consecutive single

quotes may be used to represent one such character.

If the ASCII constant consists of one character, then it

will be placed in the bottom byte of the 32 bit value; two

characters will be placed in the bottom word, with the first

character in the higher-order position. If four characters are

used, then all four bytes will contain characters, with the first

in the highest-order location. However, if three characters are

used, then they will be placed in the three highest-order bytes

of the 32-bit value, with 0 in the low byte (this is to accom

modate the high-byte-first addressing used on the 68000).

Note that ASCII constants in expressions are different from

strings in DC directives, as the latter may be of any length.

2.3.2 Operators in Expressions

The operators allowed in expressions are shown in the fol

lowing table, in order of decreasing precedence. Within each

group, the operators are evaluated in left-to-right order (except

for group 2, which is evaluated right-to-left).

Operators in Expressions

1. () Parenthesized subexpressions

2. - Unary minus (two's complement)

~ Bitwise not (one's complement)

3. << Shift left

>> Shift right

4. & Bitwise and

! Bitwise or

5. * Multiplication

/ Integer division

\ Modulus (x\y produces the remainder of x divided by y)

6. + Addition

- Subtraction 6

2.4 Addressing Mode Specifications

The 68000 and 68010 provide 14 general addressing modes.

The formats used to specify these modes in assembly language

programs are listed in the table below. The following symbols

are used to describe the operand formats:

Dn = Data Register

An = Address Register (SP may used instead of A7)

Xn = Data or Address register

.s = Index register size code (either .W or .L, .W will

be assumed if omitted)

<ex8> = Expression that evaluates to an 8-bit value (may be

empty, in which case 0 will be used)

<ex16> = Expression that evaluates to a 16-bit value (may be

empty, in which case 0 will be used)

<ex> = Any expression

PC = Program Counter

Addressing Mode Specifications

Mode Assembler Format

Pagina 4

68kasm

--------------------------------------------- ----------------

Data Register Direct Dn

Address Register Direct An

Address Register Indirect (An)

Address Register Indirect with Predecrement -(An)

Address Register Indirect with Postincrement (An)+

Address Register Indirect with Displacement <ex16>(An)

Address Register Indirect with Index <ex8>(An,Xn.s)

Absolute Short or Long (chosen by assembler) <ex>

Program Counter with Displacement <ex16>(PC)

Program Counter with Index <ex8>(PC,Xn.s)

Immediate #<ex>

In addition to the general addressing modes, the following

register names may be used as operands in certain instructions

(e.g., MOVEC or EORI to CCR):

SR = Status Register

CCR = Condition Code Register

USP = User Stack Pointer

VBR = Vector Base Register (68010)

SFC = Source Function Code Register (68010)

DFC = Destination Function Code Register (68010) 7

3. Assembly Details

3.1 Branch Instructions

The branch instructions (Bcc, BRA, and BSR) are unique in

that they can take a ".S" size code. This suffix directs the

assembler to assemble these as short branch instructions, i.e.,

one-word instructions with a range to -128 to +127 bytes. If the

".S" size code is used, and the destination is actually outside

this range, then the assembler will print an error message. If

the ".L" size code is used, the assembler will use a long branch,

which is a two-word instruction with a range of -32768 to +32767

bytes. If neither size code is specified, then the assembler

will use a short branch if possible (the branch destination must

be known on the first pass to be within the short branch range);

otherwise it will use long branch.

3.2 MOVEM Instruction

The MOVEM instruction, which is used for saving and restor

ing sets of registers, has one the following two forms:

MOVEM <register_list>,<effective_address>

MOVEM <effective_address>,<register_list>

The register list may be an explicit register list of the form

described in Section 4.2.3. On the other hand, if a particular

set of registers is to be saved and restored repeatedly, the REG

directive (Section 4.2.3) can be used to define a register list

symbol that specifies the registers. For example, if the regis

ter list symbol WORKSET is defined as follows:

WORKSET REG A0-A4/D1/D2

then the following instructions will perform the same function:

MOVEM.L WORKSET,-(SP)

MOVEM.L A0-A4/D1/D2,-(SP)

Pagina 5

68kasm

If a register list symbol is used, it must be defined before it

appears in any MOVEM instructions. 8

3.3 Quick Instructions (MOVEQ, ADDQ, SUBQ)

The MOVE, ADD, and SUB instructions have one-word "quick"

variations which can be used certain addressing modes and operand

values. The assembler will use these faster variations automat

ically when possible, or they may be specified explicitly by

writing the mnemonic as MOVEQ, ADDQ, or SUBQ.

The MOVEQ instruction may be used for moving an immediate

value in the range -128 to +127 into a data register. The assembler

will assemble a MOVE.L #<value>,Dn as a MOVEQ if the value is

known on the first pass.

The ADDQ (SUBQ) instruction adds (subtracts) an immediate

value from 1 to 8 to (from) any alterable destination. The

assembler will use the quick form if the value is known on the

first pass to be in the range 1 to 8. 9

4. Assembler Directives

4.1 ORG - Set Origin

The assembler maintains a 32-bit location counter, whose

value is initially zero and which is incremented by some amount

whenever an instruction is assembled or a data storage directive

is carried out. The value of this location counter may be set

with the ORG directive. This is typically done at the start of a

program and at appropriate places within it. The format of the

ORG directive is

<label> ORG <expression>

where <expression> is an expression containing no forward refer

ences, i.e., its value must be known on the first pass at the

point where the ORG directive appears. An error will result if

an attempt is made to set the location counter to an odd value;

in this case the location counter will be set to the specified

value plus one. The <label> is optional and, if present, the

specified symbol will be set to the new value of the location

counter.

4.2 Symbol Definition Directives

4.2.1 EQU - Equate Symbol

The equate directive is used to define symbols whose value

will not change within the program. The format of this directive

is <label> EQU <expression>

where <expression> is an expression containing no forward refer

ences, i.e., its value must be known on the first pass at the

point where the EQU directive appears. The <label> must be speci

fied, since it tells what symbol is being defined. If <label> is

omitted, an error will result. If an attempt is made to redefine

a symbol that was defined with EQU, either as a label or using

any symbol definition directive, an error message will be printed.

4.2.2 SET - Set Symbol Pagina 6

68kasm

The SET directive is similar in function and format to the

equate directive, with one important difference: symbols defined

using SET may be redefined later using another SET directive (but

not using a EQU or REG directive). The format of this directive

is <label> SET <expression> 10

4.2.3 REG - Register Range

Register ranges consist of lists of registers separated by

slashes ("/"). Each register range may be either a single

register ("An" or "Dn") or a range of registers ("An-Am" or

"Dn-Dm"), which denotes all the registers between the two

registers listed (they may be given in either order). For exam

ple, the following register list specifies that D0, D1, D2, D3,

D7, A1, A2, and A3 are to be saved (or restored):

D3-D0/D7/A1-A3

The registers and ranges may be specified in any order. The same

format for register lists may be used with the MOVEM instruction

directly. In order to avoid confusion, it is best to avoid

specifying a range that includes both an address register and a

data register, although the assembler will not treat this as an

error.

4.3 Data Storage Directives

4.3.1 DC - Define Constant

The define constant directive is used to store strings and

lists of constants in memory. The format of a DC directive is

<label> DC.<size> <item>,<item>,...

The label will be defined to equal the address of the start of

the list of data. The size code specifies that a list of bytes

(.B), words (.W), or longwords (.L) is being defined; if omitted,

word size is used.

A list of items follows the directive; each item may be an

expression or a string. If an item is an expression, the expres

sion is evaluated and stored as the size indicated, i.e., a byte,

a word, or a longword. An error is generated if the value will

not fit as either a signed or unsigned value in the specified

size. If an item is a string, delimited by single quotes, then

the string will be stored in successive entities of the size

specified; if words or longwords are being generated, and the

string does not fit into an whole number of words or longwords,

then the string will be padded with zeros at the end to make a

whole number of words or longwords. Strings and expressions may

intermixed in a single DC directive.

If words (DC.W) or longwords (DC.L) are being generated,

then the start of the list of constants will be aligned on a word

boundary by increasing the location counter by one, if necessary.

This is not performed for DC.B directives, so that strings of

bytes may be contiguous in memory. If an instruction follows a

DC.B directive, the assembler will automatically adjust the loca

tion counter (if necessary) to place the instruction on a word

boundary. 11

Pagina 7


PAGINE

11

PESO

37.69 KB

AUTORE

Sara F

PUBBLICATO

+1 anno fa


DETTAGLI
Corso di laurea: Corso di laurea in ingegneria informatica
SSD:
A.A.: 2013-2014

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher Sara F di informazioni apprese con la frequenza delle lezioni di Calcolatori elettronici I e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Napoli Federico II - Unina o del prof Canonico Roberto.

Acquista con carta o conto PayPal

Scarica il file tutte le volte che vuoi

Paga con un conto PayPal per usufruire della garanzia Soddisfatto o rimborsato

Recensioni
Ti è piaciuto questo appunto? Valutalo!

Altri appunti di Calcolatori elettronici i

Quaderno appunti presi a lezione con esercizi esame svolti
Appunto
Calcolatori elettronici I - Esercizi sugli Automi
Esercitazione
Calcolatori Elettronici I - Appunti e esercizi
Appunto
Calcolatori elettronici I - analisi
Appunto