انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية العلوم للبنات
القسم قسم الحاسبات
المرحلة 2
أستاذ المادة صلاح مهدي صالح العبيدي
21/04/2013 20:15:07
19 Advantages of High-Level Languages High-level languages such as C and Java are preferred because they provide a convenient abstraction of the underlying system suitable for problem solving. The advantages of programming in a high-level language rather than in an assembly language include the following: 1. Program development is faster in a high-level language. Many high-level languages provide structures (sequential, selection, iterative) that facilitate program development. Programs written in a high-level language are relatively small and easier to code and debug. 2. Programs written in a high-level language are easier to maintain. Programming for a new application can take several weeks to several months, and the lifecycle of such an application software can be several years. Therefore, it is critical that software development be done with a view toward software maintainability, which involves activities ranging from fixing bugs to generating the next version of the software. Programs written in a high-level language are easier to understand and, when good programming practices are followed, easier to maintain. Assembly language programs tend to be lengthy and take more time to code and debug. As a result, they are also difficult to maintain. 3. Programs written in a high-level language are portable. High-level language programs contain very few machine-specific details, and they can be used with little or no modification on different computer systems. In contrast, assembly language programs are written for a particular system and cannot be used on a different system.
20 Why Program in Assembly Language? Despite these disadvantages, some programming is still done in assembly language. There are two main reasons for this: efficiency and accessibility to system hardware. Efficiency refers to how “good” a program is in achieving a given objective. Here we consider two objectives based on space (space-efficiency) and time (time-efficiency). Space-efficiency refers to the memory requirements of a program (i.e., the size of the code). Program A is said to be more space-efficient if it takes less memory space than program B to perform the same task. Very often, programs written in an assembly language tend to generate more compact executable code than the corresponding high-level language version. Time-efficiency refers to the time taken to execute a program. Clearly, a program that runs faster is said to be better from the time-efficiency point of view. Programs written in an assembly language tend to run faster than those written in a high-level language. As an aside, note that we can also define a third objective: how fast a program can be developed (i.e., the code written and debugged). This objective is related to programmer productivity, and assembly language loses the battle to high-level languages. The superiority of assembly language in generating compact code is becoming increasingly less important for several reasons. First, the savings in space pertain only to the program code and not to its data space. Thus, depending on the application, the savings in space obtained by converting an application program from some high-level language to an assembly language may not be substantial. Second, the cost of memory (i.e., cost per bit) has been decreasing and memory capacity has been increasing. Thus, the size of a program is not a major hurdle anymore. Finally, compilers are becoming “smarter” in generating code that competes well with a handcrafted assembly code. However, there are systems such as mobile devices and embedded controllers in which space-efficiency is still important. One of the main reasons for writing programs in assembly language is to generate code that is time-efficient. The superiority of assembly language programs in producing a code that runs faster is a direct manifestation of specificity. That is, handcrafted assembly language programs tend to contain only the necessary code to perform the given task. Even here, a “smart” compiler can optimize the code that can compete well with its equivalent written in the assembly language. Perhaps the main reason for still programming in an assembly language is to have direct control over the system hardware. For example, writing an interface program, called a device driver, to a new printer on the market almost certainly requires programming in an assembly language. If you are developing system software (e.g., compiler, assembler, linker), you cannot avoid writing programs in assembly language.
21 Assembly Language Programming Programming in assembly can result in machine code that is much smaller and much faster than that generated by a compiler of a high level language. Small and fast code could be critical where resources may be very limited. In such cases, small portions of the program that may be heavily used can be written in assembly language. 21.1 INSTRUCTION MNEMONICS AND SYNTAX Assembly language is the symbolic form of machine language. Assembly programs are written with short abbreviations called mnemonics. A mnemonic is an abbreviation that represents the actual machine instruction. Assembly language programming is the writing of machine instructions in mnemonic form, where each machine instruction (binary or hex value) is replaced by a mnemonic. Clearly the use of mnemonics is more meaningful than that of hex or binary values, which would make programming at this low level easier and more manageable. An assembly program consists of a sequence of assembly statements, where statements are written one per line. Each line of an assembly program is split into the following four fields: label, operation code (opcode), operand, and comments. Labels are used to provide symbolic names for memory addresses. A label is an identifier that can be used on a program line in order to branch to the labeled line. It can also be used to access data using symbolic names. The maximum length of a label differs from one assembly language to another. Some allow up to 32 characters in length, others may be restricted to six characters. Assembly languages for some processors require a colon after each label while others do not. The operation code (opcode) field contains the symbolic abbreviation of a given operation. The operand field consists of additional information or data that the opcode requires. The operand field may be used to specify constant, label, immediate data, register, or an address. The comments field provides a space for documentation to explain what has been done for the purpose of debugging and maintenance.
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم
|