Professional Documents
Culture Documents
2012
Barreto Valderrama Lizbeth Baltodano Rodrguez Byron Bryan Brenda Josselyn Bardales Lequerica Cam Urquizo Daniel Lzaro Mauricio Carlos Antonio Gutirrez Romero Fabio
English 3
Page 1
1. INTRODUCTION A program written in assembly language consists of a series of (mnemonic) processor instructions and meta-statements (known variously as directives, pseudo-instructions and pseudo-ops), comments and data. Assembly language instructions usually consist of an opcode mnemonic followed by a list of data, arguments or parameters. These are translated by an assembler into machine language instructions that can be loaded into memory and executed. An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices in which each statement corresponds to a single machine language instruction. An assembly language is specific to a certain computer architecture, in contrast to most high-level programming languages, which may be more portable. An assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. The instruction set of a microprocessor is the set of binary inputs that produce actions defined during an instruction cycle. A set of instructions is for the microprocessor as well as a truth table is for a logic gate, a record of displacement or an adder circuit. Of course, the actions taken by a microprocessor with each instruction, are more complex than those performed by the aforementioned devices and gates. How to introduce a program in assembler on a computer? We have to translate it to hex or to binary. It can be done instruction by instruction "By hand" or, as in our case, through a program on a PC called EMU8086 and DEBUG. This is an example of programming in assembler: org 0 .model small .code mov ah,02h mov dl,30h int 21h end Disadvantages of Assembly: The assembly language (assembler) does not solve all programming problems. One is the tremendous difference between the microprocessor instruction set and the tasks the microprocessor to perform. The microprocessor instructions tend to do things as: adding contents of two registers, a shift the contents of one bit accumulator, or place a new value in the program counter (PC). Another drawback is the non-portability. Each microprocessor has its own set of instructions which is reflected in its internal architecture. A program written in assembler for 6809, will not run in 6502, Z80, 8080, or any microprocessor 16 or 32 bits. Even within the same family microcontrollers from Microchip Technology (PICs) are the same instructions. Each model has its own instruction set that differs in some other directions.
English 3
Page 2
Assembler Features Delimiters: The fields are separated only by spaces and / or tabs. Never add other characters (commas, periods, etc). Do not use extra spaces, particularly after commas separating operands. (Eg movlw 5, w) Do not use delimiter characters (spaces and tabs) in names or labels. tags: The label is the first field in a line in assembly language and cannot exist. If a tag is present, the assembler is defined as the equivalent to the direction of Byte 1, corresponding to that instruction. This tag can be reused elsewhere but as an operand of an instruction. Mnemonic (operation code): The main task of the assembler is the translation of opcodes in mnemonic to binary equivalent. The assembler performs this task using a table as if we would do "by hand". The assembler must do more to translate the opcodes. should also determine how many operands the instruction requires and what type. This is a Little complex, some instructions (such as CLRW) have no operands, others (such as addition or jumps) are, while others (or skips bit manipulation) require two. Directives: English 3 Page 3
number systems The number system we use every day is the decimal system, but this system is not suitable for the machines because the encoded information is treated as bits turned on or off, this form of coding leads to the need to know the computation positional to allow us to express a number in any base we need it. It is possible to represent a number in any base using the following formula: Where n is the digit position starting from right to left and numbered from zero. D is the digit on which we operate and B is the number base used. Convert binary numbers to decimal Working in assembly language we find the need to convert binary numbers, which is used by computers, the decimal system used by people. The binary system is based on only two conditions or states, either on (1) or off (0), therefore its base is two. For the conversion we use the positional value formula:
English 3
Page 4
Register of PURPOSE GENERAL. The general purpose registers AX, BX, CX and DX are the workhorses of the system. Are unique in the sense that it can address them as a word or as a part of a byte. The last byte of the left is the "high" and the last byte of the right is the "low". For example, the CX register consists of one part CH (high) and some Cl (low), and you can refer to any party by name. English 3 Page 7
AX register. The AX register, the main tank, is used for operations involving input / output and most arithmetic. For example, the instructions for multiply, divide and translate involve the use of AX. Also, some operations generate more efficient code if they relate to AX instead of the other records. BX register. The BX is known as the base register because it is the only general purpose register which can be index for indexed addressing. It is also common to use the BX for calculations. CX register, register counter, divided into CH and CL. - Used as a counter in loops (LOOP) in string operations (REP) and displacement (CL). DX register. The DX is known as l data record. Any input / output required use, and multiplication and division with large numbers assume the DX and AX working together. You can use the general purpose registers for addition and subtraction of numbers8, 16 or 32
English 3
Page 8
INSTRUCTION POINTER REGISTER The instruction pointer register (IP) of 16 bits contains the offset address of the next instruction is executed. The IP is associated with the CS register to the effect that theIP indicates the current instruction in the code segment that is currently running. POINTERS REGISTER. SP registers (stack pointer) and BP (base pointer) are associated with the SS register and enable the system to access data in the stack segment. SP register. The stack pointer is 16 bits associated with the SS register and provides an offset value that refers to the current word is being processed in the stack. BP register. The 16-bit BP facilitates the reference parameters, which are transmitted via data and address stack. INDEX REGISTER The SI and DI registers are available for indexed addressing and addition and subtraction. SI register. The index register 16-bit source is required by some string operations (character). In this context, the IF is associated with the DS register. The 80386 and later allow the use of an extended 32-bit register, the ESI. DI register. The destination index register is also required by some operations with strings. In this context, the DI is associated with the ES register.
FLAG REGISTER Of the 16 bits of the flags register, nine are common to the 8086 processor family, and serve to indicate the current state of the machine and the processing result. Many instructions that ask arithmetic comparisons and change the status of the flags, some of which instructions can perform tests to determine subsequent action. In summary, the common flag bits are as follows: OF (Overflow, overflow). Indicates overflow of a high order bit (left most) after an arithmetic operation. DF (direction). Designates the address to the left or right to move or compare strings. IF (interrupt). Indicates that an external interrupt, such as keyboard input, either processed or ignored. TF (trap). Allows operation of the processor in a step mode. The program debuggers, such as DEBUG, activate this flag so that you can move forward in executing one instruction at a time, to examine the effect of that instruction on the memory registers. SF (sign). Contains the resulting sign of an arithmetic operation (0 = positive and 1 = negative). ZF (zero). Indicates the result of an arithmetic or comparison (0 = result different from zero and 1 = result equal to zero). AF (auxiliary carry). Contains an external carry a data bit 3 of 8 bits for specialized arithmetic. PF (parity). Even or odd parity indicates an operation on data from low-order 8 bits (rightmost). English 3 Page 9
English 3
Page 10