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

DC machine, a dc generator has 300 turns in each field coil. the flux per p...

a dc generator has 300 turns in each field coil. the flux per pol is 0.1 wb. find the average value of EMF inducet in field winding in the flux decays to zero in 0.3 second?

Ampere''s theorem, The    French    scientist,    Ampere,    (1775- 1836), ...

The    French    scientist,    Ampere,    (1775- 1836), conducted a series of experiments on the force between current carrying conductors. He found that: force per metre of wire (

Why depletion mosfet is known as normally-on mosfet, Q. Why depletion MOSFE...

Q. Why depletion MOSFET is known as "normally-on MOSFET" ? Draw the symbol of n-type and p-type depletion MOSFET. In depletion type MOSFET the drain current flows even when VGS

Find the expressions for the inductor current, Consider the RL circuit of F...

Consider the RL circuit of Figure with R = 2, L = 5H, and v(t) = V = 20 V (a dc voltage source). Find the expressions for the inductor current i L (t) and the inductor voltage v L

Find the diameter of the antennas, Two stations, located on mountain tops 4...

Two stations, located on mountain tops 40 km apart, communicate with each other using two identical paraboloidal antennas with pencil beam- width of 1°, aperture ef?ciency of 0.8,

Common-emitter configuration, Common-emitter configuration: The commo...

Common-emitter configuration: The common-emitter that is abbreviated as CE transistor configuration is displayed in figure.  The transistor terminal common to both the input

Explain the working of asynchronous (ripple) counters, Explain the Working ...

Explain the Working of Asynchronous (Ripple) Counters? An external clock is connected to the clock input of the first flip-flop (FF0) only. Thus FF0 changes state at the falli

What do you mean by nibble, Q. What do you mean by Nibble? The nibble i...

Q. What do you mean by Nibble? The nibble is a collection of bits on a 4-bit boundary. It would not be a particularly interesting data structure except for two items BCD (binar

Determine the voltage transfer function, Q. Determine the voltage transfer ...

Q. Determine the voltage transfer function of the low pass filter circuit shown in Figure, and find the expression for ω 0 .

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