• Aucun résultat trouvé

BSS, BZS

Dans le document PROGRAMMING TRAINING (Page 124-130)

EXT ENT

6.12 BSS, BZS

Blocks of data storage can be all 0 cat e d within the program using either the BSS or the BZS pseudo instructions. The block is given a name and a size according to the following format:

BSS n is name of block s is size

These pseudo ins t r u c t ion s reserve areas. The BZS area is zeroed out at load time while the BSS block is not changed at load time; therefore, anything may be initially set in a BSS block at run time.

Example: NAM

BSS LDA

EXAM

AA(10), BB(20)

The symbol AA will be assigned the address of the first 10 c a ti on of the block of 10 and the symbol BB will be assigned the address of the first location of the block of 20 loca-tions reserved. When this program is loaded, anything can be initially contained in these first 30 locations. Had a BZS been used instead of the BSS, these first 30 locations would have been zeroed at load time.

6-10

( '

' - . r'

6.13

,...'"

~ 6.13 DAT, COM

o

Two other pseudo ops are used to res e r v e areas for use that are outside the bounds of the main program. These areas are reserved by the DAT and COM pseudo ops. Refer to Figure 13. Notice that the common storage area (reserved by the COM pseudo instruc-tion) is the area that is used by the loader. This area cannot be preset with data and is used only at run time when the loader becomes destroyed. The data area (reserved by the DAT pseudo instruction) is assigned an area with the programs themselves; in fact, the data block will precede the pro g ram that declares it. The data area can be preset.

The loader will make common and data area assignments just once and will use its com-mon counter and data counter at this assigned value for the rest of the programs loaded.

It is necessary, then, for the first sub pro g ram s of a run declaring common or data storage to declare the largest amount necessary. The format for the COM and DAT pseudo instructions is the same as for the BSS and BZS and is:

Example:

DAT COM

NAM BSS DAT COM

nl (sl),n2(s2)'·· .nm(Sm) nl (Sl)' n2 (S2)' • • • nm (s m) EXAM

AA(30)

CAT(40) ,RAN(20) CCC (40) ,AB(10)

The BSS will reserve 30 locations within the program while the DAT will reserve a total of 60 core locations, reserved outside of the program area. In fact, this data area will immediately precede the main pro g ram area in core. The common area, 50 words in this example, is reserved at the high end of core where the loader resides at load time.

This common area cannot be preset with data and 'can only be used at run time, when the loader is no longer needed.

6-11

6.13

High Core

013F

0100 ~

OOFF ~

0000 ~

Loader

Loader Symbol Tables

More Programs

1

Program

Data Executive Monitor

Resident Interrupt

Area Communication

Area

... t---50 Words

Common Counter

I

~ Program Counter

~ 60 Words

~Data Counter

Figure 13. Data, Program and Common Counters.

Figure 13 ill us t rat e s the three counters: data, program and common counter. There are three types of reI 0 cat ion po s sib 1 e when loading programs, each type using its appropriate counter. References to addresses will be relocated using the data counter if the address is in the data area, the program counter if the address is in the main program area and the common counter if the address is in the common area.

6-12

,,1' .... - ... ,

c:

c

6.13 number at load time, yielding the actual core location.

Hex word followed by relocation symbol: P for program counter, D for data counter, and C for common counter.

Although there is only one common area and one data area assigned per core load, refer-ences to data in these areas can be made by all programs in core. The relative position with respect to the data or common counter for the data desired must be kn own by each program but the same names need not be used by diffe_rent pro g ram s to reference the

6.13

When the program is loaded, a data area of 250 locations is assigned and the data counter is set at the beginning of this area.

Suppose PROG6, which is the sixth program loaded, is interested only in the data which PROG1 lmows as the 26th to 30th locations in BX.

NAM DAT LDA

PROG6

DUMMY(125), MINE(5) MINE

DUMMY is not used by program 6. It only allows a skip past the AX and first 25 locations of BX corresponding to program 1. Ref ere n c e to MINE in program 6 will yield the same data as reference to BX+25 in program 1.

6.14 ORG, ORG*

Presetting the data area is accomplished by the use of the ORG pseudo OPe Its form is:

ORG a

This pseudo op c han g e s the value of the assembler's counter to agree with a. All in-structions or data following the ORG instruction are assembled into consecutive locations until either an 0 the r ORG instruction is encOlmtered or an ORG* is encountered. When an ORG* is en c 0 u n t ere d, the assembler's program counter is set to the value that it would have been,if the very first ORG ins t r u c t ion had not occurred. The address ex-pression (a) may be either positive program relocatable, positive data reI 0 cat a b I e or absolute. Notice common reI 0 cat a b I e address expressions are not allowed since the common area cannot be preset.

Example: NAM

DAT LDA

ORG

ORG BZS ORG*

LDA

EXAMP

AX(20) ,BX(40)

AX+10

AX 10

6-14

Assume P. C. =P0030

. . . .1

C,

6.14

G

In this example the program counter starts off at 0000 and pro c e e d s in sequence until the first ORG instruction is assembled. Since the address expression refers to the data area, the assembler's pro g ram counter will now be at DOOOA, indicating that the code beneath this first ORG pseudo i:n.struction will be inserted beginning in the 10th data area location. When the second ORG instruction is encountered, the code under it (BZS10) is assembled into the beginning of the data area. When the ORG* instruction is encountered, the program counter is set to P0031; this is the next location following the last location assembled before the first ORG instruction. Any symbols used in the address expression of the ORG pseudo op must have been previously defined in the program.

0

The following example can be used to illustrate presetting values in A and B in the DATA block:

A= OOOOD DAT A(5) ,B(2)

X:: OOOOC COM X

C= 0007D DAT C(50)

OOOOP START 0 0

000lP LDA- $FF

0002P STA+ X

ORG A

OOOOD NUM

~~

A B

ORG*

0004P RAO- $FF

6. 15 IF A, ElF

t

The macro assembler contains a conditional assembly instruction. With the p s e u do op IF A, it is possible to specify portions of a program to be e i the r assembled or excluded during assembly time. Its format is:

s IFA

(This pseudo op can be used within a macro skeleton.) e may be an ex pre s s ion and c specifies one of four conditions:

EQ NE

GT LT

e1=e2 e1~e2 e1>e2 e1<;e2

The termination of the coding en com pas sed within the ran g e of an IF A pseudo op is accomplished with the pseudo op ElF. Since nesting is allowed, a match between an IFA and ElF pseudo op range is made by correspondence between the first two characters of the symbols in the location field of the IF A and the address field of an ElF.

6-15

6.15

Example:

TOTS

NAM EQU

IFA LDA STA ElF

EXAMP

AB(10) ,AC (20) ,AD(30)

AB+AC, EQ, AD TAG

TAG1 TOTS

The LDA TAG and the STA TAG1 instructions will be assembled in this example since equality exists. Changing the EQU card, however, or changing the condition from EQ to NE would have excluded these two lines of code from the assembly.

Problem:

VALUE PROBLEM (COMMON)

Starting in the 11th location of COMMON are 10 words. Bits 13-8 of each of the 10 words are to be compared with bits 5-0 of a location called VALUE which is ext ern a I to this program. Do not destroy the original contents of VALUE. Count how many complete matches are found in the bit strings compared and store the answer in the 7th word of the data block. For example, if bits 5-0 of VALUE con t a in 101100 and bits 13-8 of Xl con tain 101100, one match has been found. Any other bit configuration would be a no-match. Write a complete program to solve this problem.

Dans le document PROGRAMMING TRAINING (Page 124-130)

Documents relatifs