Question

PLEASE COMMENT CODE AND TEST THAT IT WORKS: Write a assembly program to find the largest...

PLEASE COMMENT CODE AND TEST THAT IT WORKS:

Write a assembly program to find the largest item in an array and store it in a AX.

Hint: Use both Jump and loop instruction to write the program.

logic:

Assume that the first item of the array is the minimum and store it in AX

Write a loop. Inside the loop, compare the each array item with the AX

If the array item is less than the AX, update AX with that variable

USE THIS CODE TO START:

.386

.model flat,stdcall

.stack4096

ExitProcess proto,dwExitCode:dword

.data

Array WORD 10, 2, 23, 45, 21, 11

MINIMUM WORD ?

.code

"insert code here"

invoke ExitProcess,0

main endp

end main

Homework Answers

Answer #1

// The code given below provides the min and max, both elements in the array...

// Assembly language program to read an array of numbers and find the minimal and maximal elements.

DATA SEGMENT

ARR DB 10, 2, 23, 45, 21, 11

LEN DW $-ARR

MIN DB?

MAX DB?

DATA ENDS

CODE SEGMENT

ASSUME DS:DATA CS:CODE

START:

MOV AX,DATA

MOV DS,AX

LEA SI,ARR

MOV AL,ARR[SI]

MOV MIN,AL

MOV MAX,AL

MOV CX,LEN

REPEAT:

MOV AL,ARR[SI]

CMP MIN,AL

JL CHECKMAX

MOV MIN,AL

CHECKMAX:

CMP MAX,AL

JG DONE

MOV MAX,AL

DONE:

INC SI

LOOP REPEAT

MOV AH,4CH


INT 21H

CODE ENDS

END START

Know the answer?
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
Similar Questions
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
Write an assembly program to compute the following expressions Create a list named ‘z’ of size...
Write an assembly program to compute the following expressions Create a list named ‘z’ of size 3 using DUP operator. Leave the list ‘z’ uninitialized. You can denote the items in the list as [z0, z1, z2]. z0 =x+13 z1 = y-x z2= r+z1-13 Where x, y, r are 16-bit integer memory variables. x = 7, y = 20, r = 4 Use the debugger to verify your answer. Please answer using this format for code: .386 .model flat, stdcall...
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval...
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval qword 11111111h thirdval qword 22222222h sum qword 0 .code main proc      mov rax,firstval                         add rax,secondval             add    rax,thirdval      mov    sum,rax      mov    ecx,0      invoke ExitProcess main endp end main b) Transmitted messages often include a parity bit, whose value is combined with a data byte to produce an even number of 1 bits. Suppose a message byte in the AL...
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of...
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of an 8-bit integer the user shoud insert the number then by the algo well find the square root
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. Draw Text Colors Write a program that displays the same string in four different colors, using a loop. Call the Set-TextColor procedure from the book’s link library. Any colors may be chosen, but you may find it easiest to change...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...
In Assembly x86 please Write an assembly program(call it lab6_file1.asm)that contains 10 double words in memory...
In Assembly x86 please Write an assembly program(call it lab6_file1.asm)that contains 10 double words in memory in the .data section where the first five initialized to 0 and the last five are initialized to 1. In addition, reserve ten uninitialized double words in .bss section. Using a loop, write an assembly program that copies the ten initialized values into the ten reserved double words, starting at the last position, moving to the first(reverse order the data in your uninitialized array)....
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the program title and programmer’s name. Then get the user’s name, and greet the user. • Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46]. • Get and validate the user input (n). • Calculate and display all of the Fibonacci numbers up to and including the nth...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT