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

Assembly Language: This program will cover use of mov (various kinds), direct ad

ID: 3601033 • Letter: A

Question

Assembly Language:

This program will cover use of mov (various kinds), direct addressing, negate, and flags. What you need to do: a) declare a variable number1 and set to decimal 5 move this number into the ebx register and then negate it. zero out the ecx register move 5 to the lower 8 bits of ecx. negate the lower 8 bits of ecx. move by sign extending the lower 8 bits of cl into ecx. using the techniques described in program 04, write out the string: The contents of ebx is: and move ebx into eax and then write out the signed integer using call WriteInt. write out the string: The contents of ecx is: and move ecx into eax and then write out the signed integer using call WriteInt. You should see that they are equivalent. b) create an unsigned array of 16 bit integers and initialize it to 5,6,7,8 create a signed array of 16 bit integers and initialize it to -1,-2,-3,-4 Then move with zero extend the 4 unsigned integers into eax,ebx,ecx,edx using direct addressing call the Irvine procedure DumpRegs to see the contents of the registers. Then move with sign extend the 4 signed integers into eax,ebx,ecx,edx using direct addressing. call the Irvine procedure DumpRegs to see the contents of the registers. c) move into ax the value 7FF0h add to the lower 8 bits of ax the quantity 10h. call DumpRegs. In a comment indicate why you are seeing the values shown for CF and OF. add 1 to the upper 8 bits of ax. Call DumpRegs. In a comment indicate why you are seeing the values shown for CF and OF. add 2 to ax. Call DumpRegs. In a comment indicate why you are seeing the values shown for CF and OF. Your output should look as follows (where some of the uninteresting output has been omitted): The contents of ebx is: -5 The contents of ecx is: -5 EAX=00000005 EBX=00000006 ECX=00000007 EDX=00000008 . . . EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD EDX=FFFFFFFC . . . . . . . CF=1 SF=0 ZF=1 OF=0 AF=0 PF=1 . . . . . . . CF=0 SF=1 ZF=0 OF=1 AF=1 PF=0 . . . . . . CF=0 SF=1 ZF=0 OF=0 AF=0 PF=0

Explanation / Answer

mport numpy as np
import scipy.linalg as linalg
#import matplotlib.pyplot as plt

#------------------------------------------
def vandermonde_matrix(n, datafile="vector_data.txt"):

#read in the data points from datafile you can use np.genfromtxt()
z = np.genfromtxt(datafile)
m = len(z);

#
## generate the matrix using only one loop
#
#first, initialize the matrix using np.ones()
V =

# then loop to generate V

return V

#------------------------------------------
def vandermonde_LS_solve(V, b):
""" solve the least square problem V*x =b using two methods, lstsq() and normal equation.
return the two solutions as a tuple (xls, xneqn),
where xls is the solution x obtained from lstsq(),
and xneqn is the solution x obtained from solving normal equation
"""
#
#call linalg.lstsq(), note if you call as xls=linalg.lstsq( some vatiables ), then you can
#not return xls directly (since it is a tuple that contains more items than the required solution)
#


#
#call linalg.solve() to solve the normal equation
#

return xls, xneqn