Posts

Showing posts from May, 2017

ADDITION, SUBTRACTION AND COMPARISON in ASSEMBLY LANGAGE

ADD (Addition) • This is used to add byte/word of data of 2 registers or a register & a memory-location • The only types of addition not allowed are memory-to-memory and segment register (Table 5-1). Register Addition • Whenever arithmetic and logic instructions execute, the contents of the flag-register changes. • Any ADD instruction modifies contents of sign, zero, carry, auxiliary, carry, parity & overflow flags. Example 5-1: Program to compute AX=BX+CX+DX. ADD AX,BX ADD AX,CX ADD AX,DX Immediate Addition • Immediate addition is employed whenever constant-data are added. Example 5-2: Program to add immediate data MOV DL,12H ADD DL,33H Memory-to-Register Addition Example 5-3: to add two consecutive bytes of data (stored at the data segment offset locations NUMB and NUMB+1) to the AL register. Array Addition Example 5-4: Program to add the contents of array element at indices 3, 5 and 7 MOV AL,0 ;clear sum MOV SI,3 ;address element 3 ADD AL,ARRAY[SI] ;add element 3

Data structure mcq

The memory address of the first element of an array is called a. floor address b. foundation address c. first address d. base address The memory address of fifth element of an array can be calculated by the formula a. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array b. LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array c. LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array d. None of above Which of the following data structure can't store the non-homogeneous data elements? a. Arrays b. Records c. Pointers d. None Which of the following data structure store the homogeneous data elements? a. Arrays b. Records c. Pointers d. None Which of the following is not the required condition for binary search algorithm? a. The list must be sorted b. there should be the direct access to the middle element in any sublist c.

Semantics of LTL

A transition system M=(S,→,L) is a set of states S endowed with a transition relation → (a binary relation), such that every s ∈ S has some s’∈ S with s → s’, and a labeling function L: S →P(Atoms). Transition systems are also simply called models. a model has a collection of states S, a relation →,saying how the system can move from state to state, and, associated with each state s, one has the set of atomic propositions L(s)which are true at that particular state. L is that it is just an assignment of truth values to all the propositional atoms. A transition system has more than one state, so this assignment depends on which state s the system is in: L(s) contains all atoms which are true in state s. All the information about a (finite) transition system M always be figured by using directed graphs whose nodes (which we call states) contain all propositional atoms that are true in that state. For example, if our system has only three states s0, s1 and s2; if the only possible transit

Semantics of LTL

Logical Paradigms in Computing Practical patterns of specifications: • It is impossible to get to a state where started holds, but ready does not hold: G¬(started ∧¬ready) • For any state, if a request (of some resource) occurs, then it will eventually be acknowledged: G(requested → F acknowledged). • A certain process is enabled infinitely often on every computation path: GF enabled. • Whatever happens, a certain process will eventually be permanently deadlocked: FG deadlock. • If the process is enabled infinitely often, then it runs infinitely often. GF enabled → GF running. • An upwards travelling lift at the second floor does not change its direction when it has passengers wishing to go to the fifth floor: G(floor2 ∧ directionup ∧ ButtonPressed5 → (directionup U floor5)). Here, our atomic descriptions are boolean expressions built from system variables, e.g., floor2. Important equivalences between LTL formulas: Definition: We say that two LTL formulas φ and ψ are semantically equivalent,

Program control instruction procedure

PROCEDURES A procedure is a group of instructions (subroutine or function) that usually perform a specific task. Advantages: Disadvantages: (a)It is reusable section of the software that It takes the compiler a small amount is stored in memory once, but used as often of time to link the procedure and as necessary. return from it. (b)It saves memory space. (c)Makes easier to develop software. PROCEDURES How procedure links with main program The CALL instruction links to the procedure and the RET (return) instruction return from the procedure. The CALL instruction pushes the address (return address) of the instruction following the CALL on the stack. The RET instruction removes an address from the stack so the program return to the instruction following the CALL. A procedure begins with the PROC directive and ends with the ENDP directive. The PROC directive is followed by the type of procedure: NEAR (intrasegment) or FAR (intersegment). Format of Procedure XXX

Normal form

Logical Paradigms in Computing Normal Forms (Continue…) Conjunctive normal forms and validity An algorithm which always computes the same output CNF for a given input φ. This algorithm, called CNF, should satisfy the following requirements: 1. CNF terminates for all formulas of propositional logic as input. 2. For each such input, CNF outputs an equivalent formula. 3. All output computed by CNF is in CNF. If a call of CNF with a formula φ of propositional logic as input terminates, which is enforced by (1), then (2) ensures that ψ ≡ φ holds for the output ψ. Thus,(3)guarantees that ψ is an equivalent CNF of φ. So φ is valid iff ψ is valid. If formula φ is an input then first we have to translate all implications in φ by replacing all sub formulas of the form ψ → η by ¬ψ ∨ η. This is done by a procedure called IMPL FREE. The application of IMPL FREE might introduce double negations into the output formula. If we want to compute a CNF for ¬φ from a CNF for φ then just translate ¬φ as an

Scaled-Index Addressing

Scaled-index addressing uses two 32-bit registers (a base register and an index register) to access the memory. The second register (index) is multiplied by a scaling factor. The scaling factor can be.A scaling factor of is implied and need not be included in the assembly language instruction (MOV AL,[ EBX+ECX ]). A scaling factor of is used to address word-sized memory arrays,a scaling factor of is used with double word-sized memory arrays,and a scaling factor of is used with quad word-sized memory arrays. An example instruction is MOV AX,[EDI+2*ECX]. This instruction uses a scaling factor of , which multiplies the contents of ECX by 2 before adding it to the EDI register to form the memory address. If ECX contains a 00000000H, word-sized memory element 0 is addressed; ifECX contains a 00000001H, word-sized memory element 1 is accessed, and so forth. This scalesthe index (ECX) by a factor of 2 for a word-sized memory array. The MOV EAX,[ 4*EDI ] is a scaled-index instruction that