Write an HLA Assembly language program that implements a function which correctl
ID: 3664668 • Letter: W
Question
Write an HLA Assembly language program that implements a function which correctly identifies when three passed parameters are in increasing order and returns a boolean value in AL (1 when the three values are in sorted order; 0 otherwise). This function should have the following signature: procedure isSorted( x: int16; y : int16; z : int16 ); @nodisplay; @noframe; Shown below is a sample program dialogue. Feed Me X: 205 Feed Me Y: 170 Feed Me Z: 91 calling isSorted AL = 0 Feed Me X: 0 Feed Me Y: 1 Feed Me Z: 2 calling isSorted AL = 1 Feed Me X: 121 Feed Me Y: 100 Feed Me Z: 140 calling isSorted AL = 0
Explanation / Answer
program allDifferent; #include( "stdlib.hhf" ); static iDataValue1 - int16 -= 0; iDataValue2 - int16 -= 0; iDataValue3 - int16 -= 0; iDataValue4 - int16 -= 0; procedure allDiff( x- int16; y - int16; z - int16 ); @nodisplay; @noframe; static returnAddress - dword; temp - int16; begin allDiff; pop(returnAddress); pop(z); pop(y); pop(x); pop(temp); push(returnAddress); push(AX); push(BX); mov(x, AX); cmp(y, AX); je xyequal; jmp notequal; xyequal- mov(y, BX); cmp(z, BX); je equal; jmp notequal; equal- mov(0, EAX); jmp ExitSequence; notequal- mov(1, EAX); jmp ExitSequence; ExitSequence- pop(BX); pop(AX); ret(); end allDiff; begin allDifferent; stdout.put( "Gimme a X-" ); stdin.get( iDataValue1 ); stdout.put("Gimme a Y-"); stdin.get(iDataValue2); stdout.put("Gimme a Z-"); stdin.get(iDataValue3); push( iDataValue1 ); push( iDataValue2 ); push( iDataValue3 ); push( iDataValue4 ); call allDiff; cmp(EAX, 1); je ISDIFFERENT; jmp NOTDIFFERENT; ISDIFFERENT- stdout.put("allDifferent retursn true",nl); jmp EndProgram; NOTDIFFERENT- stdout.put("allDifferent retursn false",nl); jmp EndProgram; stdout.newln(); EndProgram- end allDifferent;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.