×
Study like there’s no tomorrow because if you keep putting off your studies for tomorrow, you’ll probably be too late.
--Your friends at LectureNotes
Close

Note for Adhoc and Sensor Network - ASN by Vijeta kumari

  • Adhoc and Sensor Network - ASN
  • Other
  • 99 Views
  • 3 Offline Downloads
  • Uploaded 8 months ago
Vijeta Kumari
Vijeta Kumari
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

the correct position in the ordered table; this process is terminated when the original unordered table is empty. Thus, if Sl S2 . . . Si Si+l . . . Sk represents the ordered table (ascending sequence) at the k4kf stage and the next element ’ ” ‘i+l’ U of the unordered array is such that Si then U is inserted between Si and Si+l q Si+# . . . Sk then have to be moved to make room for U l This block movement can be very inefficient unless the machine has a block transfer command. On the other hand, a binary search can be used to rank U and in the case of assembler symbol table construction, the table can be ordered continuously as it c's built up. These features make the method useful for large symbol tables. 11-3.3.3 Other Common Methods There are many other sorting methods in common use as well as variations of the above two methods. Other methods include the radix sort, various merge sorts, odd-even transposition, and selection sort. 2 Sorting of a symbol table in a 2-pass assembler would occur at the . end of pass 1 or beginning of pass 2. 11-3.4 Scrambling Methods Scrambling or "hash addressing" is a fast method for converting symbols to addresses. Addresses are obtained by performing some simple arithmetic or logical operation on the symbol. For example, one method is to square the numeric representation of the symbol and select the central bits or numbers of the result as its table address; if a particular symbol, say XI, is represented numerically as 3275 and we wish

Text from page-2

a 3-digit address, the computation would proceed as follows: 327 52 = 10725625 .. address of XI = 725 Care must be exercised to either prevent or account for non-unique map@ngs of identifiers and to use table storage efficiently; this work often negates the advantage of the fast address calculation. 11-k. One-Pass Assembly One-pass assembly can be accomplished despite the problem raised at the end of section II-l. The "forward reference" problem is solved by maintaining a list of undefined symbols with pointers to the locations where they are to be "fixed-up" upon definition. A flow of this scheme Encounter a Symbol (Except in Location Field) Enter Symbol in UST along with Pointer to fix-up location UST: 18 Undefined Symbol Table

Text from page-3

During assembly, a symbol table (ST) and UST are constructed: Partially ST On finding a symbol in the location field, the assembler flow is: Enter Symbol in Symbol Tablei When the same undefined symbol is encountered more than once, a -chaining method provides a convenient means for recording their appearances and for later fix-ups. Multiple appearances/of undefined symbols can then be recorded as below: 19

Text from page-4

(UST, ST) Partially Assembled Program IAddress Symbol d/u U Address: Symbol Location or Fix-up Location d/u : defined/undefined flag The address part of the entry for the undefined symbol L#P points to the last location seen by the assembler where L$$P appeared; pointers -to 2 and' 1 produce a chain through the earlier fix-up locations for loop. s2 (undefined) occ1urs at point 4 indicates the end of the chain. If L@P again and is still undefined, the pointers change as indi- cated by the dotted lines and the pointer from the address part of L@P to 3 is ,deleted. When L@P is defined, its addresses are inserted in the places occupied by the chain pointers. One-pass assembly has the advantage that the source program is *, es- read only once; this advantage is gained at the expense of more complex routines for handling symbolsc The assembled program and various tables 20

Lecture Notes