Loops and subroutines, Electrical Engineering

Assignment Help:

1.....If viewing this through the Assignment tool, click the title above to go to the Submissions area.

Introduction

The purpose of this experiment is to examine the operation of loops and their close equivalent, subroutines.

Procedure

1. How many times does each loop execute?

2. Assemble and link to create LOOPS.EXE. Run the program.

3. Comment out the PUSH AX and POP AX instructions. Re-assemble, link, and run. Comment on any changes. Explain how the changes, if any, occurred.

4. Put the PUSH AX and POP AX instructions back in.

5. Take instructions from inside the loop and place them in a subroutine (or procedure). Thus, the loop will call the subroutine once each pass. Only instructions that directly control the looping should stay.

6. Assemble, link, and run the program. You should get the same results. Email the final ASM file.

7. Assemble and link to create LOOPS2.EXE. Run the program. Explain why the loop pass counter value shown is correct.

8. This file contains errors! Edit the file to correct the errors, then assemble, link, and run. Warning! The program may assemble and link correctly and still have errors that may crash your DOS window. The correct result in AL is 7.

9. Submit your findings.

Downloaded copy of Program LOOPS.ASM: Count the number of passes through a loop.

;

        .MODEL SMALL

        .DATA

LOOPS   DW    ?

MSG     DB    'The number of loop passes is '

TENTHOS DB    ?

THOUS   DB    ?

HUNS    DB    ?

TENS    DB    ?

ONES    DB    ?

        DB    0DH,0AH,'$'

 

        .CODE

        .STARTUP

        MOV   AX,0      ;clear loop pass counter

;

;place user loop code here.

;Make sure INC  AX is inside the innermost loop.

;

        MOV   BX,0FF98H

BAK:    PUSH  AX

        MOV   CX,1234H

        MOV   DX,5678H

        XOR   CX,DX

        MOV   AX,9ABCH

        XOR   CX,AX

        POP   AX

        INC   AX                ;increment loop pass counter

        DEC   BX

        JNZ   BAK

;

;end of user loop code

;

        MOV   LOOPS,AX          ;display the loop pass counter

        CALL  BTOD

        LEA   DX,MSG 

        MOV   AH,9

        INT   21H

        .EXIT

 

BTOD    PROC  FAR

        MOV   AX,LOOPS    ;load binary input value

        SUB   DX,DX

        MOV   BX,10000

        DIV   BX                ;get 10,000s digit

        ADD   AL,30H

        MOV   TENTHOS,AL

        XCHG  AX,DX

        SUB   DX,DX

        MOV   BX,1000           ;get 1,000s digit

        DIV   BX

        ADD   AL,30H

        MOV   THOUS,AL

        XCHG  DX,AX

        MOV   BL,100

        DIV   BL          ;get hundreds digit

        ADD   AL,30H      ;convert into ASCII digit

        MOV   HUNS,AL     ;and save

        XCHG  AL,AH       ;get remainder

        SUB   AH,AH       ;prepare for division by 10

        MOV   BL,10

        DIV   BL          ;get tens digit

        ADD   AL,30H      ;convert into ASCII digit

        MOV   TENS,AL     ;and save

        ADD   AH,30H      ;convert ones digit into ASCII

        MOV   ONES,AH     ;and save

        RET

BTOD    ENDP

        END


Related Discussions:- Loops and subroutines

Determine efficiency on diffrent load cycle, Q. A 75-kVA transformer has an...

Q. A 75-kVA transformer has an iron loss of 1 kW and a full-load copper loss of 1 kW. If the transformer operates on the following load cycle, determine the all-day efficiency:

Calculate reactive power to be delivered by the capacitor, A single-phase s...

A single-phase source delivers 100 kW to a load operating at 0.8 lagging power factor. In order to improve the system's efficiency, power factor improvement (correction) is achieve

Find the quantum levels, A uniform quantizer is said to have 16 levels, and...

A uniform quantizer is said to have 16 levels, and hence is called a midriser. The saturation levels are to correspond to extreme values of the message of 1 V ≤  f(t) ≤ 17 V. Find

Find the ratio of the forward to the reverse current, Assume that an abrupt...

Assume that an abrupt Si p-n junction with area 10-4 cm2 has NA=10 17 /cm 3 and ND=10 17 /cm 3 is working at room temperature. It is given that μ n = 700 cm 2 /v-s, μ P =250 cm

Jump instruction - branch operations , Jump Instruction There are two ...

Jump Instruction There are two types of jump  instruction unconditional jump conditional jumps

Determine the input resistance between terminals of circuit, Q. Consider Fi...

Q. Consider Figure of the weighted differencing amplifier. Let R 3 = R 1 and R 4 = R 2 . Determine the input resistance between terminals a and b of the circuit.

Explain a common emitter configuration without a feedback, Q. Explain a com...

Q. Explain a common emitter configuration without a feedback. A simple common emitter transistor amplifier--having no negative feedback--is not an ideal amplifier. This is beca

What do you mean by noise, Q. What do you mean by Noise? In any communi...

Q. What do you mean by Noise? In any communication system there are usually two dominant factors that limit the performance of the system: 1. Additive noise, generated by el

Transfer function, derive transfer function of S= 2.25+j4.5

derive transfer function of S= 2.25+j4.5

Simulate a diode application circuit using multisim ewb, a. Simulate a diod...

a. Simulate a diode application circuit using Multisim EWB.  Compare calculated and simulated results Each student must choose one of the following circuits from question 1 (Ref

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd