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

Evaluate the current using the loop-current method, Consider the circuit in...

Consider the circuit in Figure (a), which include a controlled source, and find the current in the 5-V source and the voltage across the 5- resistor by using (a) the loop-current

Give an example of one address microprocessor, 8085 is a one address microp...

8085 is a one address microprocessor. In 8085 interrupts are classified by hardware and software interupts.

Digital signal processing, what can I do to sharpen the roll off and flatte...

what can I do to sharpen the roll off and flatten the passband of a finite impulse response filter

Discuss the control words of ic8259, Discuss the control words (ICWS) of IC...

Discuss the control words (ICWS) of IC8259. The Intel 8259 is a single chip programmable interrupt controller. It is compatible with 8086, 8088 and 8085 microprocessor. It is a

Explain p - type semiconductor, Explain p - Type semiconductor. p - ...

Explain p - Type semiconductor. p - Type semiconductor:- (i) If small amount of trivalent impurity is added with to a pure semiconductor giving a large no. of holes in t

Two quadrant type a chopper or class c chopper or reversible, Two Quadrant ...

Two Quadrant Type A Chopper or Class C Chopper or Reversible Chopper The  quadrant type A Chopper  is also  known as reversible chopper   because  the polarity of the load cur

Estimate the required bandwidth using Carson''s rule, A 10-kHz tone is used...

A 10-kHz tone is used to frequency modulate a carrier; the peak deviation is 75 kHz. Use Carson''s rule to estimate the bandwidth.

Impact of diversity, Both GSM and DECT use GMSK, but with different Gaussia...

Both GSM and DECT use GMSK, but with different Gaussian filters (BGT = 0.3 in GSM, BGT = 0.5 in DECT). What are the advantages of having a larger bandwidth time product? Why is the

Find the efficiency of the transformer, Q. A three-phase, 600-kVA, 2300:230...

Q. A three-phase, 600-kVA, 2300:230-V,Y-Y trans-former bank has an iron loss of 4400Wand a full-load copper loss of 7600 W. Find the efficiency of the transformer for 70%full load

Digital electronics, Design a logic circuit when to provide an output when ...

Design a logic circuit when to provide an output when any two or three of four switches are closed.

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