[ Pobierz całość w formacie PDF ]
.Thestream of text from TASM that you would ordinarily see is quite literally steered in itsentirety to another place, the file ERRORS.TXT.Once the assembly process is done, the DOS prompt will appear again.You can thenprint the ERRORS.TXT file on your printer and have a handy summary of all that theassembler discovered was wrong with your source code file.Assembler WarningsAs taciturn a creature as an assembler may appear to be, it genuinely tries to help youany way it can.One way it tries to help is by displaying warning messages during theassembly process.These warning messages are a monu-mental puzzle to beginningassembly language programmers: are they errors or aren't they? Can I ignore them orshould I fool with the source code until thev go away?There is no clean answer.Sorry about that.Warnings are the assembler acting as experienced consultant, and hinting that somethingin your source code is a little dicey.Now, in the nature of assembly language, you mayfully intend that the source code be dicey.In an 86-family CPU, dicey code may be thefile:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble.htm (23 of 39) [9/30/02 08:29:47 PM] file:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble.htmonly way to do something fast enough or just to do it at all.The critical factor is that youhad better know what you're doing.The most common generator of warning messages is doing something that goes againstthe assembler's default conditions and assumptions.If you're a beginner doing ordinary,100%-by-the-book sorts of things, you should crack your assembler reference manualand figure out why the assembler is tut-tutting you.Ignoring a warning may causepeculiar bugs to occur later on during program testing.Or, ignoring a warning messagemay have no undesir-able consequences at all.I feel, however, that it's always better toknow what's going on.Follow this rule:Ignore a warning message only if you know exactly what it means.In other words, until you understand why you're getting a warning message, treat it asthough it were an error message.Only when you fully understand why it's there and whatit means should you try to make the decision whether or not to ignore the message.In summary, the first part of the assembly language development process (as shown inFigure 3.5) is a loop.You must edit your source code file, assemble it, and return to theeditor to fix errors until the assembler spots no further errors.You cannot continue untilthe assembler gives your source code file a clean bill of health.When no further errors are found, the assembler will write an.OBJ file to disk, and youwill be ready to go on to the next step.LinkingTheoretically, an assembler could generate an.EXE (executable) program file directlyfrom your source code.ASM file.Some obscure assemblers have been able to do this,but it's not a common assembler feature.What actually happens is that the assembler writes an intermediate object code file withan.OBJ extension to disk.You can't run this.OBJ file, even though it contains all themachine instructions that your assembly language source code file specified.The.OBJfile needs to be processed by another translator program, the linker.The linker performs a number of operations on the ,OBJ file, most of which would bemeaningless to you at this point.The most obvious task the linker does is to weaveseveral.OBJ files into a single.EXE program file.Creating an assembly languageprogram from multiple.ASM files is called modular assembly.Why create multiple.OBJ files when writing a single executable program? One of twomajor reasons is size.A middling assembly-language application might be 50,000 lineslong.Cutting that single monolithic.ASM file up into multiple 8,000 line.ASM filesfile:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble.htm (24 of 39) [9/30/02 08:29:47 PM] file:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble.htmwould make the individual.ASM files smaller and much easier to understand.The other reason is to avoid assembling completed portions of the program every timeany part of the program is assembled.One thing you'll be doing is writing assemblylanguage procedures, small detours from the main run of steps and tests that can be takenfrom anywhere within the assembly language program.Once you write and perfect aprocedure, you can tuck it away in an.ASM file with other completed procedures,assemble it, and then simply link the resulting.OBJ file into the "working".ASM file.The alternative is to waste time by reassembling perfected source code over and overagain every time you assemble the main portion of the program.Notice that in the upper-right corner of Figure 3.5 is a row of.OBJ files.These.OBJfiles were assembled earlier from correct.ASM files, yielding binary disk filescontaining ready-to-go machine instructions.When the linker links the.OBJ fileproduced from your in-progress.ASM file, it adds in the previously assembled.OBJfiles, which are called modules.The single.EXE file that the linker writes to diskcontains the machine instructions from all of the.OBJ files handed to the linker whenthen linker is invoked.Once the in-progress.ASM file is completed and made correct, its.OBJ module can beput up on the rack with the others, and added to the next in-progress.ASM source codefile.Little by little you construct your application program out of the modules you buildone at a time.A very important bonus is that some of the procedures in an.OBJ module may be usedin a future assembly language program that hasn't even been begun yet.Creating suchlibraries of toolkit procedures can be an extraordinar-ily effective way to save time byreusing code over and over again, without even passing it through the assembler again!Something to keep in mind is that the linker must be used even when you have only one.OBJ file.Connecting multiple modules is only one of many essential things the linkerdoes.To produce an.EXE file, you must invoke the linker, even if your program is alittle thing contained in only one.ASM and hence one.OBJ file.Invoking the linker is again done from the DOS command line.Each assembler typicallyhas its own linker.MASM's linker is called LINK, and TASM's is called TLINK.Likethe assembler, the linker understands a suite of commands and directives that I can'tdescribe exhaustively here.Read your assembler manuals carefully.For single-module programs, however, there's nothing complex to be do Linking ourhypothetical FOO.OBJ object file into an.EXE file using TLINK ' done by enteringC:\ASM>TLINK FOO at the DOS prompt.If you're using MASM, using LINK is done much the same way.Again, as with MASM,file:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble.htm (25 of 39) [9/30/02 08:29:47 PM] file:///E|/TEMP/Chapter%203%20The%20Right%20To%20Assemble [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • funlifepok.htw.pl
  •