agilan ganesan bk13110013 tutorial 2
DESCRIPTION
tutorial 2TRANSCRIPT
1. For each of the following Logical addresses of 80386 microprocessor, calculate the Physical address of the memory:
i. 1000:1234H=11234H
ii. 23FB:FAB3H=33A63H
iii. 1234:FFB3H=222F3H
iv. 1000:12FAH=112FAH
v. F000:1245H=F1245H
vi. F300:3467H=F6467H
vii. 10FF:1144H=12134H
viii. 3FFF:1234H=41224H
2. Briefly, defined the following terms:
i. Assembler
Assembler is a program that translate assembly language statement into machine code instruction that can be executed by the microprocessor. The input of the assembler is source code and will produce an object file. If the assembler detect any error during the assembly process only a list file containing the assembly instruction, the error code and an error message for each error encountered will be produce.
ii. Assembler Directives
Assembler Directives are pseudo-operation that control the assembly process but they do not generates any instruction in the assembled program. They merely instruct the assembly programs and as such they are specific to each particular assembler. Some common uses of assembler directives are:-
a. To declare variablesb. To define segmentc. To define procedures
iii. Linker
Linker is a program that links several object files into an executable file that can be executed. The output of the linker is an executable file if no error encountered during the linking process is halted had an error message.
iv. Source Code
The code written by the programmers is called source code.
v. Object Code
The code produced when the programmer then uses a compiler to compile the source code.
vi. Text editor
A text editor is a program that allows to create a file containing the source code. Some of the operations that can perform with a text:
a. Type the assembly program.b. Correct any typing error in the program.c. Insert new statement or delete unwanted ones.d. Save the program on magnetic medium for later uses.e. Rearrange the order of the statements by moving them from one place to another in the
program.f. Copy the part of the program.
Object code
Library files
LinkerExecutable
Code
3. Describe the structure of an assembly language program and its statement.
The structure of an assembly language contains
i. Statements or instruction that the programmer want them executed by the microprocessor. Each statement may have up to 4 fields.
ii. Directives to the assembler (translator program) that informs the assembler how to assemble (translate) the program.
iii. Remarks that explains the working of the program to other programmers these remarks are optional and will be ignored by the assembler.
An assembly statement may have up to 4 fields
i. The first field (new) is the label field. It is used for flow control of the program. A colon (:) terminate the label field. The field is not required unless the programmer want to refers to that line somewhere in the program.
ii. The next field is the operation code (ADD) which must be valid operation code for the given microprocessor. The operation codes are given by the microprocessor manufacturer and are called instruction set. The operation code tells the microprocessor what action to perform. This field is required unless that line of program is a remark line.
iii. The third field is the operand field (AX,5h). This contains the data on which the operation will be performed. The type and the number of the operand depend on the operation code as some may required no operand, one or two operand. If more than one operand is required they must separated by commas.
iv. The last field is the remark field (; add percentage). This may contains anything as it is intended for the programmer and not for the computer. The objective of the remark field are to aid the readability of the program, help the programmer understands the program and they improve maintainability. The comment fields stats with a semicolon (;). This field is not compulsory but recommended.
4. With the help of an appropriate diagram and example, explain in detailed the following addressing modes of 80386 microprocessor:
i. Register addressing
Operand is held in register named address field Limited number of register No memory access Very fast execution Very limited address space
Instruction
Registers
The diagram of register addressing.
Opcode Register Address R
Operand
ii. Register Indirect Addressing
C.f. indirect addressing EA = (R) Operand is in memory cell pointed to by contents of register R Large address space (2n) One fewer memory access than indirect addressing
Instruction
Memory
Registers
Register Indirect Addressing Diagram
Opcode Register Address R
OperandPointer to operand
iii. Base plus index addressing
Transfers a byte or word between a register and the memory location address by a base register BP or BX plus an index register DI or SI.
iv. Base relative plus index addressing
Transfers a byte or word between a register and the memory location address by a base and an index plus a displacement.
5. Briefly, describe the operation of each of the following instructions :
a. Push ax
The push instruction places 2 or 4 bytes of data on the stack depending on the size of the register being pushed.
Before PUSH AX instruction executed After PUSH AX instruction executed
b. POP AX
Pop instruction remove 2 or 4 bytes of data from the stack depending on the size of the register being poped.
Before POP AX executed After POP AX executed
c. XCHG AX, BX
This command called exchanging data. The XCHG command exchanges the contents of a register with that of another register or memory location.
XCHG AX,BX ; the content of AX is copied into BX and the content of BX is copied into AX
d. ADD AX, [BX]
The carry is added to the content of memory address DS:BX which is added to that of DS:AX and the result is stored in DS:AX.
e. X-OR AX,0Fh
The X-OR instruction performs the logical X-OR operation on the bits of two data items.
AX = AX X-OR 0FH
f. BSF AX,[BX+DI]
BSF is Bit Scan Forward
[BX + DI] is scanned for 1 bit. The position where 1 bit found stored in AX.
g. LOADSW
The word stored at DS:SI is copied into AX and the value of SI is changed by 2.
h. STOSD
The double word in EAX is copied to memory addressed by ES:DI. The value of the DI is changed by 4.
i. MOVSB
The byte stored at the memory address DS:SI is copied into the memory address ES:DI. The value of both SI and DI is changed by 1.
j. REP MOVSB
Repeats the move string byte (MOVSB) command as long as CX not equal 0.
k. INC CX
The INC instruction is a special form of addition that add a 1 from the value of a memory or a register content.
The general syntax is :
INC destination- the destination can be a memory address on a register.
INC CX ; CX=CX + 1
l. SUB AX, [BX]
The borrow (carry flag) is subtracted from the content of memory address DS:BX which is subtracted from that of DS:AX and the result is stored in DS:AX.
m. DEC LIST
The DEC instruction is special form of subtraction that subtract a 1 from the value of a memory or register content
DEC destination
DEC LIST ; LIST= LIST – 1
n. ADC list, [BX]
The carry is added to the content of memory address DS:BX which is added to that DS:list and the result is stored in DS:list
o. MUL BX
DX-AX=AX x BX
The content AX is multiplied by the content in the register pair DX-AX
8. What decimal value is represented by the following 32-bit floating point number given in hexadecimal form?
i. C17B0000
Step 1
C 1 7 B 0 0 0 01100 0001 0111 1011 0000 0000 0000 0000
110000
01011110110000000000
000000S E M
Step 2
n = E -127
= 10000010 -127
=130-127
=3
Step 3
=-1.1111011 x 10^3
=-1111.1011
Step 4
Express in decimal
=-15.6875
ii.