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 the apparent power and the reactive power, Q. A balanced electric...

Q. A balanced electrical industrial plant load of 9.8 MW with 0.8 lagging power factor is supplied by a three-phase 60-Hz system having a maximum rating (load-carrying capacity) of

Gaussian derivatives, Gaussian derivatives Generate Gaussian kernels f...

Gaussian derivatives Generate Gaussian kernels for a given scale "sigma", and display the kernel. The size of the kernel should be floor(3*sigm)+1; (i) Write an m-file "

Find the magnetic-field force exerted on the moving bar, Consider the arran...

Consider the arrangement shown in Figure. A conductor bar of length l is free to move along a pair of conducting rails. The bar is driven by an external force at a constant velocit

Metering techniques, Metering Techniques The techniques of metering co...

Metering Techniques The techniques of metering could be categorized depending upon the voltage at which consumers are fed as: 1. LT (Low Tension) Metering, and 2. HT (Hi

Obstacle avoidance Arduino robot, we work as a group on Automoted guided ve...

we work as a group on Automoted guided vehicles project, with 2 vehicles one is leading and the other is guided and following the first one, i was assigned to write an obstacle avo

Components of plc - stepper motor , Components of PLC There are follow...

Components of PLC There are followings  three main  components of PLC : a.The power supply and rack. b.The central  processing  unit ( CPU) c.The input / output  (I/O

Can you explain octal to binary conversion, Q. Can you explain Octal to Bin...

Q. Can you explain Octal to Binary Conversion? It is also simple to convert from an integer octal number to binary. This is completed by: Convert the decimal number

Explain the phase shifting circuit, Q. Discuss the operation of a transisto...

Q. Discuss the operation of a transistorized phase shift oscillator with the help of a diagram? Explain the phase shifting circuit? An oscillator is a circuit which converts el

Find the new synchronous speed, Q. A wye-connected, three-phase, 50-Hz, six...

Q. A wye-connected, three-phase, 50-Hz, six-pole synchronous alternator develops a voltage of 1000 V rms between the lines when the rotor dc field current is 3A. If this alternator

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