Friday, May 24, 2019

Assembly Language

ASSEMBLY LANGUAGE An convocation speech is a low-altitude programming dustup for a electronic computer, microcontroller, or other programmable device, in which each statement corresponds to a single machine code instruction. Each fable wording is particular to a spark officular computer architecture, in contrast to well-nigh high- direct programming addresss, which atomic number 18 generally portable across multiple systems. conclave vocabulary is converted into feasible machine code by a utility program referred to as an lying program the conversion process is referred to as lying, or assembling the code.Assembly language procedures a mnemonic to represent each low-level machine summons or opcode. Some opcodes require one or to a greater extent operands as part of the instruction, and most assembly programs post carry away labels and symbols as operands to represent addresses and never-endings, instead of hard cryptanalytics them into the program. Macro asse mblers include a macroinstruction facility so that assembly language textual matter faeces be pre- offered to a name, and that name give the axe be expendd to insert the text into other code. M some(prenominal) assemblers spree additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.HISTORY OF ASSEMBLY LANGUAGE Assembly languages date to the introduction of the stored-program computer. The EDSAC computer (1949) had an assembler called initial orders featuring one-letter mnemonics. Nathaniel Rochester wrote an assembler for an IBM 701 (1954). SOAP (Symbolic Optimal Assembly Program) (1955) was an assembly language for the IBM 650 computer write by Stan Poley. Assembly languages eliminated much of the error-prone and time-consuming first-generation programming needed with the early computers, freeing programmers from tedium such as remembering numeric codes and calculating addresses.They were once widely used for all sorts of programming. However, by the 1980s (1990s on microcomputers), their use had roundly been supplanted by high-level languages, in the search for improved programming productivity. Today assembly language is still used for direct hardwargon manipulation, devil to specialized processor book of instructions, or to address critical behaveance issues. Typical uses are device drivers, low-level embedded systems, and real-time systems. Historically, a larger-than-life offspring of programs have been written completely in assembly language. Operating systems were ntirely written in assembly language until the introduction of the Burroughs MCP (1961), which was written in ESPOL, an Algol dialect. Many commercialised applications were written in assembly language as well, including a large amount of the IBM mainframe software written by large corporations. COBOL, FORTRAN and some PL/I eventually displaced much of this work, although a number of large organizations hold assembly-lang uage application infrastructures well into the 90s. Most early microcomputers relied on hand-coded assembly language, including most operating systems and large applications.This was because these systems had severe re germ constraints, imposed idiosyncratic memory and display architectures, and provided limited, buggy system services. Perhaps more(prenominal) important was the lack of first-class high-level language compilers suitable for microcomputer use. A psychological factor may have also played a role the first generation of microcomputer programmers retained a hobbyist, wires and pliers attitude. In a more commercial context, the biggest reasons for using assembly language were minimal bloat (size), minimal overhead, greater speed, and reliability.Typical examples of large assembly language programs from this time are IBM PC DOS operating systems and early applications such as the spreadsheet program Lotus 1-2-3. Even into the 1990s, most console flick games were written i n assembly, including most games for the Mega Drive/Genesis and the Super Nintendo Entertainment System. According to some industry insiders, the assembly language was the best computer language to use to get the best performance out of the Sega Saturn, a console that was notoriously challenging to develop and program games for.The popular arcade game NBA get up (1993) is another example. Assembly language has long been the primary development language for some(prenominal) popular home computers of the 1980s and 1990s (such as the Sinclair ZX Spectrum, Commodore 64, Commodore Amiga, and Atari ST). This was in large part because BASIC dialects on these systems offered insufficient execution speed, as well as insufficient facilities to take full advantage of the available hardware on these systems.Some systems, most notably the Amiga, even have IDEs with highly advanced debugging and macro facilities, such as the freeware ASM-One assembler, comparable to that of Microsoft Visual Stu dio facilities (ASM-One predates Microsoft Visual Studio). The Assembler for the VIC-20 was written by Don French and published by French Silk. At 1,639 bytes in length, its author believes it is the smallest symbolic assembler ever written. The assembler supported the habitual symbolic addressing and the definition of character strings or hex strings.It also allowed address expressions which could be combined with addition, subtraction, multiplication, division, logical AND, logical OR, and exponentiation operators. COMPILER A compiler is a computer program (or set of programs) that transforms antecedent code written in a programming language (the radical language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform seed code is to create an executable program.The name compiler is primarily used for programs that translate source code from a high-level programming language to a lo wer level language (e. g. , assembly language or machine code). If the compiled program gutter run on a computer whose CPU or operating system is different from the one on which the compiler runs, the compiler is known as a cross-compiler. A program that translates from a low level language to a higher level one is a decompiler. A program that translates between high-level languages is usually called a language translator, source to source translator, or language converter.A language rewriter is usually a program that translates the form of expressions without a change of language. A compiler is likely to perform many or all of the following operations lexical analysis, preprocessing, parsing, semantic analysis (Syntax-directed translation), code generation, and code optimization. Program faults caused by incorrect compiler behavior can be very severe to track down and work around therefore, compiler implementors invest significant effort to ensure the correctness of their software .The term compiler-compiler is sometimes used to refer to a parser generator, a tool often used to help create the lexer and parser. INTERPRETER In computer science, an interpreter normally heart and soul a computer program that executes, i. e. performs, instructions written in a programming language. An interpreter may be a program that either 1. executes the source code directly 2. translates source code into some efficient intermediate representation (code) and immediately executes this 3. xplicitly executes stored precompiled code made by a compiler which is part of the interpreter system While interpreting and compiling are the two main means by which programming languages are implemented, these are not full mutually exclusive categories, one of the reasons being that most interpreting systems also perform some translation work, just like compilers. The terms interpreted language or compiled language merely mean that the canonical implementation of that language is an interpre ter or a compiler a high level language is prefatorialally an abstraction which is (ideally) independent of particular implementations.ASSEMBLER Assembler (meaning one that assembles) may refer to It is a computer program that translate between lower-level representations of computer programs it converts basic computer instructions into a pattern of bits which can be easily understood by a computer and the processor can use it to perform its basic operations Assembly Language Syntax Programs written in assembly language consist of a sequence of source statements. Each source statement consists of a sequence of ASCII characters ending with a carriage return.Each source statement may include up to four fields a label, an operation (instruction mnemonic or assembler directive), an operand, and a signalise. The following are examples of an assembly directive and a regular machine instruction. PORTA equ $0000 Assembly time constant INP ldaa PORTA Read entropy from fixed address I/O da ta port An assembly language statement contains the following fields. Label reach can be used to define a symbol Operation Field defines the operation code or pseudo-op Operand Field specifies either the address or the data.Comment Field allows the programmer to document the software. Sometimes not all four fields are present in an assembly language statement. A aura may contain just a comment. The first token in these lines must begin with a star (*) or a semicolon (). For example, This line is a comment * this is a comment too * This line is a comment Instructions with inherent mode addressing do not have an operand field. For example, label clra comment deca comment cli comment inca comment DATA TYPES IN ASSEMBLY LANGUAGEThere is a large degree of diversity in the way the authors of assemblers categorize statements and in the nomenclature that they use. In particular, some describe anything other than a machine mnemonic or extended mnemonic as a pseudo-operation (pseudo-op). A normal assembly language consists of 3 types of instruction statements that are used to define program operations Opcode mnemonics Data sections Assembly directives Opcode mnemonics and extended mnemonics Instructions (statements) in assembly language are generally very simple, unlike those in high-level language.Generally, a mnemonic is a symbolic name for a single executable machine language instruction (an opcode), and there is at least one opcode mnemonic defined for each machine language instruction. Each instruction typically consists of an operation or opcode plus zero or more operands. Most instructions refer to a single value, or a pair of values. Operands can be immediate (value coded in the instruction itself), registers specified in the instruction or implied, or the addresses of data located elsewhere in storage.This is determined by the underlying processor architecture the assembler merely reflects how this architecture works. Extended mnemonics are often used to sp ecify a combination of an opcode with a special(prenominal) operand, e. g. , the System/360 assemblers use B as an extended mnemonic for BC with a mask of 15 and NOP for BC with a mask of 0. Extended mnemonics are often used to support specialized uses of instructions, often for purposes not obvious from the instruction name. For example, many CPUs do not have an explicit NOP instruction, but do have instructions that can be used for the purpose.In 8086 CPUs the instruction xchg ax, ax is used for nop, with nop being a pseudo-opcode to encode the instruction xchg ax, ax. Some disassemblers recognize this and pull up stakes decode the xchg ax, ax instruction as nop. Similarly, IBM assemblers for System/360 and System/370 use the extended mnemonics NOP and NOPR for BC and BCR with zero masks. For the SPARC architecture, these are known as synthetic instructions Some assemblers also support simple built-in macro-instructions that fork over two or more machine instructions.For instan ce, with some Z80 assemblers the instruction ld hl, bc is recognized to generate ld l, c followed by ld h, b. These are sometimes known as pseudo-opcodes. Data sections There are instructions used to define data elements to hold data and variables. They define the type of data, the length and the alignment of data. These instructions can also define whether the data is available to outside programs (programs assembled separately) or only to the program in which the data section is defined. Some assemblers classify these as pseudo-ops. Assembly directivesAssembly directives, also called pseudo opcodes, pseudo-operations or pseudo-ops, are instructions that are kill by an assembler at assembly time, not by a CPU at run time. They can make the assembly of the program dependent on line of reasonings stimulation by a programmer, so that one program can be assembled different ways, perhaps for different applications. They also can be used to dodge presentation of a program to make it e asier to read and maintain. (For example, directives would be used to reserve storage areas and optionally their initial contents. The names of directives often start with a dot to distinguish them from machine instructions. Symbolic assemblers let programmers associate unconditional names (labels or symbols) with memory locations. Usually, every constant and variable is given a name so instructions can reference those locations by name, thus promoting self-documenting code. In executable code, the name of each subroutine is associated with its entry point, so any calls to a subroutine can use its name. Inside subroutines, GOTO destinations are given labels. Some assemblers support local symbols which are lexically distinct from normal symbols (e. . , the use of 10$ as a GOTO destination). Some assemblers provide flexible symbol management, letting programmers manage different namespaces, automatically calculate offsets within data structures, and assign labels that refer to litera l values or the result of simple computations performed by the assembler. Labels can also be used to initialize constants and variables with relocatable addresses. Assembly languages, like most other computer languages, allow comments to be added to assembly source code that are ignored by the assembler.Good use of comments is even more important with assembly code than with higher-level languages, as the meaning and purpose of a sequence of instructions is harder to decipher from the code itself. Wise use of these facilities can greatly simplify the problems of coding and maintaining low-level code. Raw assembly source code as generated by compilers or disassemblerscode without any comments, meaningful symbols, or data definitionsis quite difficult to read when changes must be made. MacrosMany assemblers support predefined macros, and others support programmer-defined (and repeatedly re-definable) macros involving sequences of text lines in which variables and constants are embedde d. This sequence of text lines may include opcodes or directives. once a macro has been defined its name may be used in place of a mnemonic. When the assembler processes such a statement, it replaces the statement with the text lines associated with that macro, then processes them as if they existed in the source code file (including, in some assemblers, expansion of any macros existing in the replacement text). pure tone that this definition of macro is slightly different from the use of the term in other contexts, like the C programming language. C macros created through the define directive typically are just one line or a few lines at most. Assembler macro instructions can be lengthy programs by themselves, executed by interpretation by the assembler during assembly. Since macros can have short names but expand to several or indeed many lines of code, they can be used to make assembly language programs appear to be far shorter, requiring fewer lines of source code, as with high er level languages.They can also be used to add higher levels of structure to assembly programs, optionally introduce embedded debugging code via parameters and other similar features. Macro assemblers often allow macros to take parameters. Some assemblers include quite sophisticated macro languages, incorporating such high-level language elements as optional parameters, symbolic variables, conditionals, string manipulation, and arithmetic operations, all practicable during the execution of a given macro, and allowing macros to save context or exchange information.Thus a macro might generate a large number of assembly language instructions or data definitions, based on the macro arguments. This could be used to generate record-style data structures or unrolled loops, for example, or could generate entire algorithms based on complex parameters. An organization using assembly language that has been heavily extended using such a macro suite can be considered to be working in a higher- level language, since such programmers are not working with a computers lowest-level conceptual elements.Macros were used to customize large master software systems for specific customers in the mainframe era and were also used by customer personnel to satisfy their employers needs by making specific versions of manufacturer operating systems. This was done, for example, by systems programmers working with IBMs Conversational Monitor System / Virtual Machine (VM/CMS) and with IBMs real time transaction processing add-ons, Customer nurture Control System CICS, and ACP/TPF, the airline/financial system that began in the 1970s and still runs many large computer reservations systems (CRS) and credit card systems today.It was also manageable to use solely the macro processing abilities of an assembler to generate code written in completely different languages, for example, to generate a version of a program in COBOL using a pure macro assembler program containing lines of COBOL code i nside assembly time operators instructing the assembler to generate arbitrary code. This was because, as was realized in the 1960s, the concept of macro processing is independent of the concept of assembly, the former being in modern terms more word processing, text processing, than generating object code.The concept of macro processing appeared, and appears, in the C programming language, which supports preprocessor instructions to set variables, and make conditional tests on their values. Note that unlike certain previous macro processors inside assemblers, the C preprocessor was not Turing-complete because it lacked the ability to either loop or go to, the latter allowing programs to loop.Despite the power of macro processing, it fell into disuse in many high level languages (major exceptions being C/C++ and PL/I) while remaining a perennial for assemblers. Macro parameter substitution is strictly by name at macro processing time, the value of a parameter is textually substituted for its name. The most famous class of bugs resulting was the use of a parameter that itself was an expression and not a simple name when the macro writer expected a name.In the macro foo macro a load a*b the intention was that the caller would provide the name of a variable, and the global variable or constant b would be used to multiply a. If foo is called with the parameter a-c, the macro expansion of load a-c*b occurs. To avoid any possible ambiguity, users of macro processors can parenthesize formal parameters inside macro definitions, or callers can parenthesize the input parameters.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.