Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Each of the questions on the next two pages asks you to convert a high-level cod

ID: 3674281 • Letter: E

Question

Each of the questions on the next two pages asks you to convert a high-level code sequence to x86 assembly. Please note that each of these code sequences is part of a larger function-do not worry about any of the function call and stack frame details discussed during lectures 14, 16, and 17. (That material will be covered on HW 4.) Implement the following conditional statement. You may assume that "X","Y", and "Z" refer to 16-bit variables stored in memory, which can be directly accessed using those names (for example, MOV AX, X would move the contents of variable "X" to the register AX). Your solution should not modify AX or BX. Implement the following loop. As in question 1, assume "X" is a 16-bit variable in memory that can be accessed by name.

Explanation / Answer

CMP AX,#40

JL   LOCATION1

SUB   X,Y

STORE Z,X

GOTO LOCATION2

LOCATION1:

ADD X,Y

STORE Z,X

CMP Z,#0

JLE LOC3

MUL X,BX,#8

LOC3:DIV X,BX,#4

LOCATION2:EXIT

2. FOR    (I=0;I<X;I++){

AX=AX+X;

BX=BX-X

IF(AX==BX)

BREAK;

}

MOV I,#0

LOOP:CMP I,X

JGE LOCATION1

ADD AX,X

SUB BX,X

CMP AX,BX

JE LOCATION1

ADD I,#1

GOTO LOOP

LOCATION1:END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote