Write a function in assembly language. Input a sequence of positive numbers endi
ID: 3938966 • Letter: W
Question
Write a function in assembly language. Input a sequence of positive numbers ending with 0. Find the minimum and maximum. For example, input 4, 6, 2, 99, 21, 10, 0. min = 2 and max = 99. The main procedure reads the sequence of the numbers and output the results. The procedure min max finds the minimum and maximum and return the results to the main procedure. Reverse a string from user input. The main procedure reads the string from the user and pass it to the reverse procedure. The reverse procedure returns the reversed string back to main to be displayed. Example, input hello, output olleh.Explanation / Answer
(1).assemby langauge for input a sequence of numbers and then find min and max value.
/////////SOLUTION::
.data ///the upcoming section is considered as data
X .word 4,6,2,99,21,10,0
N .word 7
minmumValue .asciiz " Min Value: "
maximumValue .asciiz " Max Value: "
.text //// upcoming section is considered as assembly instruction
main:
la $a2, X
la $a3, N
jal MaximumMinimum
MaximumMinimum:
lw $t1, 0($a2)
swap:
move $t1, $s1
move $s1, $s2
move $s1, $t1
(2)reverse a string from user input.
////SOLUTION:::
MOV AX, DATA /// register AX initialized with DATA MOV DS, AX /// move contents of AX into DS(data segment) MOV ES, AX /// move contents of AX into ES(extra segment) MVI CL, 03 /// CL is initialized to 03 LEA SI, A ///load the effective address of A into stack indexpointer MVI AX, 04 /// move immediate data 04 into AX ADD DI, AX /// add contents of AX with DI Loop: MOV AL, [SI] /// move the contents of [SI] into AL XCHG AL, [DI] ///this instruction exchange the data MOV [SI], AL /// move contents of AL into [SI] INC SI /// increment SI DEC DI //// decrement DI LOOP1 Loop /// goto loop END ///end of the program
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.