Question

In: Computer Science

Please show full work and give explanation to be upvoted. 11. How does a program determine...

Please show full work and give explanation to be upvoted.

11. How does a program determine whether or not to jump based off of a comparison?(In assembly language)

12. Left shift 15 by 3

Solutions

Expert Solution

11.

Conditional execution in assembly language is defined by a few branching and looping instructions. These instructions can change the progression of control in a program.

  • Conditional jump
  • Unconditional jump
Syntax :      CMP destination, source

The CMP instruction compares two operands. It is generally used in conditional execution. This instruction basically subtracts one operand from the other for comparing whether the operands are equal or not. It does not disturb the destination or source operands. It is used along with the conditional jump instruction for decision making. CMP is often used for comparing whether a counter value has reached the number of times a loop needs to be run. Consider the following typical condition

Unconditional Jump - The JMP instruction provides a label name where the flow of control is transferred immediately.

Syntax :    JMP label

Example:

MOV  AX, 00    ; Initializing AX to 0
MOV  BX, 00    ; Initializing BX to 0
MOV  CX, 01    ; Initializing CX to 1
L20:
ADD  AX, 01    ; Increment AX
ADD  BX, AX    ; Add AX to BX
SHL  CX, 1     ; shift left CX, this in turn doubles the CX value
JMP  L20       ; repeats the statements
Conditional Jump -  If some specified condition is satisfied in conditional jump, the control flow is transferred to a target instruction. 

Example:

INC     EDX
CMP     EDX, 10 ; Compares whether the counter has reached 10
JLE     LP1     ; If it is less than or equal to 10, then jump to LP1

LP1: ....

Assembly code:

include 'emu8086.inc'
.model small
.stack 100h

.data


.code

        main proc
                
                mov dl,5
                mov bl,7
                
                cmp dl,bl
                
                je show
                        print 'Both are not same'
                        mov ah,04h
                        int 21h
                        
                        show:
                        print 'Both are same'
                        mov ah,04h
                        int 21h
                
                
        main endp

end main

output:

12.

In a left shift the binary value shifts to left by 1 place. Actually each shift is a 2 multiple of the value. So the 15 (00001111) multipled by 8 (2*2*2) , will calculate 120 (01111000) as the value whose binary form is the left shift of 15 by 3.

Syntax Binary form Value

x=15; 00001111 15

x= x>>3; 01111000 15 *(2*2*2) = 120

left shift of 15 (00001111) by 3 is 01111000 .


Related Solutions

Please give full explanation. Assume that the program counter (PC) is set to 0x00000000. Describe how...
Please give full explanation. Assume that the program counter (PC) is set to 0x00000000. Describe how each of the instructions below could be used to set the next value of PC to 0x0FFFFFFC. j, beq, jr, jal, bne
Please show all work, calculation, or explanation to receive full credit and circle the correct answer....
Please show all work, calculation, or explanation to receive full credit and circle the correct answer. Use the following Information to Answer Problems 1 and 2 Bradford Services Inc. (BSI) is considering a project that has a cost of $10 million and an expected life of 3 years. There is a 30 percent probability of good conditions, in which case the project will provide a cash flow of $9 million at the end of each year for 3 years. There...
Show all work please, do not just give a number! Determine the number of ATP derived...
Show all work please, do not just give a number! Determine the number of ATP derived from each component and name the additional enzymes necessary to recognize the double bonds and account for the cost in ATP or NADH. a) palmitic acid (even number of carbons) b) oleic acid (even number of carbons, one double bond) c) linoleic acid (even number of carbons, two double bonds)
How would a financial manager determine optimal capital structure? Please give a detailed explanation. How this...
How would a financial manager determine optimal capital structure? Please give a detailed explanation. How this would fit in with the company's capital expenditures, growth plans and operating results? Please provide examples. Please keep in mind that inadequate answers that already exist on the web.
*** Please be concise and give full explanation *** What kinds of evidence do scientists use...
*** Please be concise and give full explanation *** What kinds of evidence do scientists use to categorize and classify living things?
Show full work: Please make sure to start the comparison with -infinity and NO NOT COUNT...
Show full work: Please make sure to start the comparison with -infinity and NO NOT COUNT SWAPS! Sort the list A[ ]={ 20, 13,4, 34, 5, 15, 90, 100, 75, 102, 112, 1} using Insertion Sort and determine the total number of comparisons made (do not count swaps)
Please show full work if possible, would like to be able to understand the problem and...
Please show full work if possible, would like to be able to understand the problem and solution. Leo company is considering a new venture in office equipment. It expects the cost of acquisition of land and building to be $100,000. Leo company expects cash flows to be $40,000 the first year and $45,000 for the next 4 years. It will discontinue the furniture operation upon the completions of the 5th year. Assume no salvage value. The company’s WACC is 10%....
Please show full work if possible, would like to be able to understand the problem and...
Please show full work if possible, would like to be able to understand the problem and solution. Lion Inc. recently hire you as a consultant to estimate the company’s WACC. You have obtained the following information. (1) The firm’s noncallable bonds mature in 20 years, have an 8% annual coupon, a par value of $1,000, and a market price of $1,050. (2) The company’s tax rate is 40%. (3) The risk-free rate is 4.50% and the market risk premium is...
Please be sure to show all work to receive full credit. No credit will be given...
Please be sure to show all work to receive full credit. No credit will be given for an answer that is correct but has no work where it is necessary, or if the work showed does not logically equate to the given answer. No credit will be given for an incorrect answer with no work. Please try to answer all at one time.. please 1. The World Health Organization estimates that 5% of all adults in sub-Saharan Africa are living...
Please give a detailed explanation, not just the response. If possible, a way to work out...
Please give a detailed explanation, not just the response. If possible, a way to work out the problem in Excel is helpful! Thanks in advance! According to the Carnegie unit system, the recommended number of hours students should study per unit is 2. Are statistics students' study hours less than the recommended number of hours per unit? The data show the results of a survey of 16 statistics students who were asked how many hours per unit they studied. Assume...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT