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

NEEDS TO BE WRITTEN IN ASSEMBLY MIPS Train yourself towards next Projects by try

ID: 3783495 • Letter: N

Question

NEEDS TO BE WRITTEN IN ASSEMBLY MIPS

Train yourself towards next Projects by trying to implement the following programs:

1. Get a number X from the user: if X=0 terminate the program;

if X>0 print out “+” and repeat; if X<0 print out “-“ and repeat.

2. Get a number X from the user and a seed S (both positive), then print out X, X+S, X+2S, X+3S,… Outputs must occur on the same line with a space in between, and your program should terminate right before overflow occurs (hint: overflow happens when, starting from a positive number, it gets too big to be represented over 32bits. What is in 2’s Complement the biggest number that can be represented on 32bits? Realize your branching condition around this idea).

3. Get five numbers from the user, one at a time, and print the difference of all the negative numbers in the end. For example, for a sequence in input equal to: -3, 0, -7, -2, 1 the result should be computed as follows: (-3)-(-7)-(-2)=6

Explanation / Answer

DATA SEGMENT A DB 5 DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV AH,00 MOV AL,A L1: DEC A MUL A MOV CL,A CMP CL,01 JNZ L1 MOV AH,4CH INT 21H CODE ENDS END START