시스템프로그래밍

Assembler4

아무 말하는 감자 2022. 10. 13. 14:46

Machine-Independent Assembler Features
•There are some common assembler features that are notclosely related to machine architecture
_The presence or absence of such features is much more closely related to issues such as programmer convenience and software environment than it is to machine architecture

Control Section
•It is a part of program that maintains its identity after assembly; each such control section can be loaded and relocated independently of the others
–Different control sections are most often used for subroutines or other logical subdivisions of a program
–The programmer can assemble, load, and manipulate each of these control sections separately

 

•The resulting flexibilityis a major benefit of using control sections

Object program을 independent하게 나눔! -> 메모리의 연속된 공간이 필요하지 X, 파편화된 메모리 사용할 수 있도록!

Program Linking

-> Control section 끼리 연결시켜줌
•When control sections form logically related parts of a program, it is necessary to provide some means for linking them together.
–Instructions in one control section(CS) might need to refer to instructions or data located in another section.

 

•However, the assembler is unable to process these references because CSs are independently loaded and relocated.
–Such references between CSs are called “external references”. (다른 CS에 있는 data에 접근하는 경우)

 

•The assembler has no idea where any other CS will be located at execution time, so it just generates information for each external reference that will allow the loader to perform the required linking.

-> 메모리의 정확한 위치를 아는 건 loader 뿐임! Assembler가 어떤 것이 external reference인지, 어떻게 고쳐야 하는지를 알려줘야 함!

 

Fig. 2.15 & 16
•Here, we describe how external references are handled by our assembler.
•Figures 2.15 and 16 show an example program using 3 control sections: one for the main program and one for each subroutine
–CSECT: assembly directive to signal the start of a new CS
EXTDEF: assembly directive to name symbols defined in a CS, used by other section
   Such symbols are called external symbols
   Control section names are automatically considered to be external symbols
EXTREF: assembly directive to name symbols used in a CS, defined elsewhere
•The assembler establishes a separate LOC for each CS, just as it does for program blocks.

 

start with default Control Section
CSECT라는 directive로 CS인 것을 define

 

LENGTH,BUFFER라는 external symbol를 사용

How to handle External References?
•The assembler has no idea where the CS containing an external reference (e.g., RDREC) will be loaded, so it cannot assemble the address for the reference.


•Instead, the assembler insertsan address of 0 and passes information to the loader, so the proper address can be inserted at load time.
–[e.g.] CLOOP +JSUB RDREC 4B100000  //RDREC은 또 다른 CS, 0으로 채워줌!
–[e.g.] +STCH BUFFER,X 57900000


•An extended format instruction (i.e., format 4) must be used to provide room for the actual address to be inserted.
–Relative addressing (i.e., format 3) is not possible

-> 충분한 address field를 위해 format 4 사용!

 

New Record Types
•The assembler must include information in the object program that will cause the loader to insert the proper values where they are required.


Define record: CS에서 정의한 symbol (다른 CS가 사용할 수 있도록 export!)
–For external symbols defined in the control section by EXTDEF
–Indicates the relative address of each external symbol within this control section

 

Refer record: (다른 CS에 정의된 symbol을 사용하려고 할 때)
–For external symbols used in the control section by EXTREF
–No address information is available

 

Record Types
•Define record (EXTDEF)
–Col. 1   D
–Col. 2-7  Name of external symbol defined in this control section
–Col. 8-13  Relative address within this control section (hexadecimal)
–Col.14-73  Repeat information in Col. 2-13 for other external symbols


• Refer record (EXTREF)
–Col. 1 R
–Col. 2-7Name of external symbol referred to in this control section
–Col. 8-73Names of other external reference symbols

 

Modification record (revised)
–Col. 1 M
–Col. 2-7 Starting address of the field to be modified (hexadecimal)
–Col. 8-9 Length of the field to be modified, in half-bytes (hexadecimal)
–Col. 10Modification flag (+ or -)
–Col.11-16External symbol whose value is to be added to or subtracted from the indicated field

 

개수만큼 존재?

Control Section and Program Linking
•Loader
–For every external symbol
Find the relative address from the define record
Add the starting address of the control section where the symbol is defined
Modify the field
–More details will be covered later!

'시스템프로그래밍' 카테고리의 다른 글

Linkers and Loaders  (0) 2022.10.27
Assemblers (4)_1  (0) 2022.10.17
Assembler3_1  (0) 2022.10.13
Assemblers (3)  (0) 2022.10.06
Assemblers (2)_1  (0) 2022.09.29