Comp Organization GeeksForGeeks 6-15 Flashcards
Assembly level language
It is a low-level language that allows users to write a program using alphanumeric mnemonic codes, instead of numeric code for a set of instructions examples of large assembly language programs from this time are IBM PC DOS.
Needs assembler for conversion. Convert an assembly level language to machine level language. Machine dependent. In this mnemonics, codes are used. Supports low-level operation and easy tto access hardware component. Compact code.
High Level language
It is a machine-independent language. It enables a user to write a program in a language that resembles English words and familiar mathematical symbols, COBOL was the first high-level language. Examples of high-level language are python,c#, etc.
Needs compiler/interpreter for conversion. convert a high-level language to Assembly level language to machine level language. Machine-independent, english statement is used. Does not support low-level language. Difficult to access hardware components and NO compactness
Addressing modes
The term addressing modes refers to the way in which the operand of an instruction is specified. The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually executed.
Addressing modes for 8086 instructions are divided into two categories:
1) Addressing modes for data
2) Addressing modes for branch
The 8086 memory addressing modes provide flexible access to memory, allowing you to easily access variables, arrays, records, pointers, and other complex data types. The key to good assembly language programming is the proper use of memory addressing modes.
An assembly language program instruction consists of two parts
Opcode and Operand
The memory address of an operand consists of two components:
IMPORTANT TERMS
Starting address of memory segment.
Effective address or Offset: An offset is determined by adding any combination of three address elements: displacement, base and index.
Displacement: It is an 8 bit or 16 bit immediate value given in the instruction.
Base: Contents of base register, BX or BP.
Index: Content of index register SI or DI.
Implied mode
In implied addressing the operand is specified in the instruction itself. In this mode the data is 8 bits or 16 bits long and data is the part of instruction.Zero address instruction are designed with implied addressing mode.
instruction
data
Example: CLC (used to reset Carry flag to 0)
Immediate addressing mode (symbol #)
In this mode data is present in address field of instruction .Designed like one address instruction format.
Note:Limitation in the immediate mode is that the range of constants are restricted by size of address field.
Opcode Address
|
data is directly
stored here
Example: MOV AL, 35H (move the data 35H into AL register)
Register mode
In register addressing the operand is placed in one of 8 bit or 16 bit general purpose registers. The data is in the register that is specified by the instruction.
Here one register reference is required to access the data.
instruction -> register
register data
Example: MOV AX,CX (move the contents of CX register to AX register)
Register Indirect mode
In this addressing the operand’s offset is placed in any one of the registers BX,BP,SI,DI as specified in the instruction. The effective address of the data is in the base register or an index register that is specified by the instruction.
Here two register reference is required to access the data.
instruction (Register) ->
Register (Effective Address) ->
Memory (Data)
The 8086 CPUs let you access memory indirectly through a register using the register indirect addressing modes.
MOV AX, BX
Auto Indexed (increment mode)
Effective address of the operand is the contents of a register specified in the instruction. After accessing the operand, the contents of this register are automatically incremented to point to the next consecutive memory location.(R1)+.
Here one register reference,one memory reference and one ALU operation is required to access the data.
Example:
Add R1, (R2)+ // OR
R1 = R1 +M[R2]
R2 = R2 + d
Useful for stepping through arrays in a loop. R2 – start of array d – size of an element
Auto indexed (decrement mode)
Effective address of the operand is the contents of a register specified in the instruction. Before accessing the operand, the contents of this register are automatically decremented to point to the previous consecutive memory location. –(R1)
Here one register reference,one memory reference and one ALU operation is required to access the data.
Example:
Add R1,-(R2) //OR
R2 = R2-d
R1 = R1 + M[R2]
Auto decrement mode is same as auto increment mode. Both can also be used to implement a stack as push and pop . Auto increment and Auto decrement modes are useful for implementing “Last-In-First-Out” data structures.
Direct addressing/ Absolute addressing Mode (symbol [])
The operand’s offset is given in the instruction as an 8 bit or 16 bit displacement element. In this addressing mode the 16 bit effective address of the data is the part of the instruction.
Here only one memory reference operation is required to access the data.
Instruction (Effective address) ->
Memory (Data)
Example:ADD AL,[0301] //add the contents of offset address 0301 to AL
Indirect addressing mode (symbol @ or () )
In this mode address field of instruction contains the address of effective address.Here two references are required.
1st reference to get effective address.
2nd reference to access the data.
Based on the availability of Effective address, Indirect mode is of two kind:
Register Indirect:In this mode effective address is in the register, and corresponding register name will be maintained in the address field of an instruction.
Here one register reference,one memory reference is required to access the data.
Memory Indirect:In this mode effective address is in the memory, and corresponding memory address will be maintained in the address field of an instruction.
Here two memory reference is required to access the data.
Indexed addressing mode
The operand’s offset is the sum of the content of an index register SI or DI and an 8 bit or 16 bit displacement.
Example:MOV AX, [SI +05]
Based Indexed Addressing
The operand’s offset is sum of the content of a base register BX or BP and an index register SI or DI.
Example: ADD AX, [BX+SI]
Based on Transfer of control, addressing modes are:
PC relative addressing mode:
PC relative addressing mode is used to implement intra segment transfer of control, In this mode effective address is obtained by adding displacement to PC.
EA= PC + Address field value
PC= PC + Relative value.
Base register addressing mode
Base register addressing mode is used to implement inter segment transfer of control.In this mode effective address is obtained by adding base register value to address field value.
EA= Base register + Address field value.
PC= Base register + Relative value.
Note:
PC relative and based register both addressing modes are suitable for program relocation at runtime.
Based register addressing mode is best suitable to write position independent codes.
Advantages of addressing modes
To give programmers to facilities such as Pointers, counters for loop controls, indexing of data and program relocation.
To reduce the number bits in the addressing field of the Instruction.
Addressing modes
operations field specifies the operations which need to be performed. The operation must be executed on some data which is already stored in computer registers or in the memory. The way of choosing operands during program execution is dependent on addressing modes of instruction. “The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. “Basically how we are interpreting the operand which is given in the instruction is known as addressing mode.
Addressing mode very much depends on the type of CPU organization. There are three types of CPU organization:
Single Accumulator organization
General register organization
Stack organization
Addressing modes is used for one or both of the purposes. These can also be said as the advantages of using addressing mode:
To give programming versatility to the user by providing such facilities as pointers to memory, counter for loop control, indexing of data, and program relocation.
To reduce the number of bits in the addressing field of the instruction.
There is a number of addressing modes available and it depends on the architecture and CPU organization which of the addressing modes can be applied.
Memory Based Addressing Modes
The operand is present in memory and its address is given in the instruction itself. This addressing mode is taking proper advantage of a memory address, e.g., Direct addressing mode
The memory address specified in the instruction may give the address where the effective address is stored in the memory. In this case, an effective memory address is present in the memory address which is specified in the instruction, e.g., Indirect Addressing Mode
The content of the base register is added to the address part of the instruction to obtain the effective address. A base register is assumed to hold a base address and the address field of the instruction gives displacement relative to the base address, e.g., Base Register Addressing Mode.
The content of the index register is added to the address part that is given in the instruction to obtain the effective address. Index Mode is used to access an array whose elements are in successive memory locations, e.g., Indexed Addressing Mode
The content of the program counter is added to the address part of the instruction in order to obtain the effective address. The address part of the instruction, in this case, is usually a signed number that can be either positive or negative, e.g., Relative addressing mode
Register Based Addressing Modes
An operand will be given in one of the registers and the register’s number will be provided in the instruction. With the register number present in instruction, an operand is fetched, e.g., Register mode
The register contains the address of the operand. The effective address can be derived from the content of the register specified in the instruction. The content of the register might not be the effective address. This mode takes full advantage of registers, e.g., Register indirect mode
If we are having a table of data and our program needs to access all the values one by one we need something which decrements the program counter/or any register which has a base address. Though in this case register is basically decreased, it is register-based addressing mode, e.g., In Auto decrements mode.
If we are having a table of data and our program needs to access all the values one by one we need something which increments the program counter/or any register which has a base address, e.g., Autoincrement mode
Instructions generally used for initializing registers to a constant value are register-based addressing mode, and this technique is a very useful approach, e.g., Immediate mode.
Memory-based addressing modes are mostly relying on Memory address and content present at some memory location.
Register-based addressing modes are mostly relying on registers and content present at some register whether it is data or some memory address.
Fixed Program Computers
Their function is very specific and they couldn’t be reprogrammed, e.g. Calculators.
Stored Program Computers
These can be programmed to carry out many different tasks, applications are stored on them, hence the name.
It is also known as ISA (Instruction set architecture) computer and is having three basic units:
The Central Processing Unit (CPU)
The Main Memory Unit
The Input/Output Device Let’s consider them in detail.