Question

Any help with this computer Organization and Architecture question
It's on assembly language procedure
Please use TASM

3. Write a procedure called divides that takes two parameters in BX and CX. Assume unsigned integers. It should print to the screen EVENLY if CX divides BX evenly. Otherwise, it should print NOT EVENLY. DO NOT USE THE DIV OR IDIV COMMANDS. Use repeated subtraction to determine whether BX is divided evenly (no remainder.) Before printing clear entire screen with red background and blue text. Print in the top left corner of window. For example, if BX is 24 and CX is 8 24-8-8-8-0 you would print Evenly Another example if BX-27 and CX -5 27-5-5-5-5-5-2 you would print Not Evenly Push and pop registers on the stack as appropriate for your procedure. Show what would be in the data segment.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::

new open examples compile emulate calculator convertor options help about save 1.nodel smal 02 03 G4 ms g1 05 06 07 main 08 09 mou ds. ax 10 11 mou cx.5 12 mou bx.271 13 pus h cx 14 push bx 15 16 17 imp divides CALL FUNCTION 18 19 20 mou ax, 4c 00h TERMINATE 21 int 21h .stack 100h .data dbEvenly$ db Not Evenlys msg2 .code proc mou ax. edata CX UALUE BX UALUE PUSH TO STACK return FUNCTION RETURN main endp 23 24 25 FUCNTION STARTS 26 divides: 27 pop bx 28 pop Сх 29 loopHere: 30 sub bx.cx 31 стр 32 je evenly 33 спр bx.cx 34 Jl notEvenly 35 jnp loopHere LOOP CONTINUE 36 37 mov dx. offset nsg1 38 mou ah, 9 39 int 21h 40 jmp return 41 notEvenly: 42 mou dx. offset nsg2 43 mov ah, 9 44 int 21h 45 jnp return 46 end main 47 FUCNTI ON ENDS get argunent value from stack SUBTRACT BC FROM BX CHECK IF RESULT ZERO, . THAN PRINT EUENLY IF N0OT ZERO CHECK IFNUMBER IS LESS THAN BX THAN PRINT NOT EUENLY evenly:

.model small

.stack 100h

.data

msg1 db 'Evenly$'

msg2 db 'Not Evenly$'

.code

main proc

mov ax,@data

mov ds, ax

mov cx,5 ;CX VALUE

mov bx,27 ;BX VALUE

push cx ;PUSH TO STACK

push bx

jmp divides ;CALL FUNCTION

return: ;FUNCTION RETURN

mov ax, 4c00h ;TERMINATE

int 21h

main endp   

;;;;;;FUCNTION STARTS

divides:

pop bx ;;get argument value from stack

pop cx   

loopHere:

sub bx,cx ;SUBTRACT BC FROM BX

cmp bx,0 ;CHECK IF RESULT ZERO,, THAN PRINT EVENLY

je evenly

cmp bx,cx ;IF NOT ZERO CHECK IF NUMBER IS LESS THAN BX, THAN PRINT NOT EVENLY

jl notEvenly

jmp loopHere ;LOOP CONTINUE

evenly:

mov dx, offset msg1   

mov ah, 9

int 21h

jmp return

notEvenly:

mov dx, offset msg2   

mov ah, 9

int 21h

jmp return

end main

;;;;;;FUCNTION ENDS

output:

Add a comment
Know the answer?
Add Answer to:
Any help with this computer Organization and Architecture question It's on assembly language procedure Please use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help on Assembly language 1.Solve the following conditions: A. Suppose AL contains 11001011 and CF...

    Need help on Assembly language 1.Solve the following conditions: A. Suppose AL contains 11001011 and CF = 1.    Give the new contents of AL after each of the following instructions is executed.    Assume the above initial conditions for each part of this question. a. SHL AL,1 b. SHR AL,1 c. ROL AL,2 d. ROR AL,3 e. SAR AL,2 f. RCL AL,1 g. RCR AL,3 B. Suppose EAX contain ABCDH.    Show the contents of BX and CX after...

  • Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine...

    Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....

  • Need some help I am not understanding this programming class at all. We are using Microsoft...

    Need some help I am not understanding this programming class at all. We are using Microsoft visual studio with python in console mode to complete these labs. Double-click to hide white space CIS115 Week 4 Lab Overview Title of Lab: Multiplication Table in Python Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to...

  • == Programming Assignment == For this assignment you will write a program that controls a set...

    == Programming Assignment == For this assignment you will write a program that controls a set of rovers and sends them commands to navigate on the Martian surface where they take samples. Each rover performs several missions and each mission follows the same sequence: deploy, perform one or more moves and scans, then return to base and report the results. While on a mission each rover needs to remember the scan results, in the same order as they were taken,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT