Comp 3350: HW # 7:  Theme: Conditionals, Booleans, Loops Solved

35.00 $

Category:

Description

5/5 - (1 vote)

 

  1. Draft a program that scans an array to determine the first positive EVEN number in the array. If a positive value is found, the program should print “positive even number found” and the value.  If no positive EVEN value is found in the array, the program should print “no positive even number found.” Submit list file and show the runs for the following data items:
    1. all negative even values
    2. all positive odd values
    3. mixed negative and positive values which are odd and even (two different examples with odd and even numbers at different indices)

 

a.

 

b.

 

c.Mix1

 

 

c.Mix2

 

  1. Write a program which encodes any string using the XOR instruction. Test it using your <first name last name> in the data segment to produce cipher text and then decode using the program to get plain text.  Use the last three digits of your student id as the key.  Print plane text from the data segment, print the cipher text, and then print the plain text upon execution.  What are the strengths and weaknesses of this encryption method?  Can you think of another way doing such encryption?  What are the strengths and weaknesses of your method?  

 

 

 

Strengths: Hard to find out original text at one glance

Weaknesses: The length of cipher text is the same with original text, the original text can be guessed in long run. Using only one key will also increase the risk.

 

Other method: One time pad encryption

Strengths: Every key is one-time used, more secure.

Weakness: Cannot be decode if losing the key pad.

  1. Implement the following two pseudo-codes in assembly language (assume signed numbers). Declare Apple and Pear as word sized variables. Test the program for input data sets listed below and print values assigned to Apple and Pear. Submit list file and show output for all input data sets.

 

  1. if ( (cx = bx) AND (cx >= val1) )

Apple = 1;

Else

Apple = 0;

 

  1. if ( (bx = cx)  OR  (cx >= val1) )

Pear = 1;

Else

Pear = 0;

 

 

            Input test data

 

CX BX Val1
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

000

001

010

011

100

101

110

111

  1. Draw the stack (pencil-paper or wordàpdf) at different points of the main and subroutine to show your understanding of the call and return functions.

 

Main PROC

4040040          call FloatAdd 4040046           mov eax, ebx

 

FloatAdd  PROC

4041020          Push ecx

4041024          Push ebx

4041028          mov eax, edx

404A030         Pop ebx

404A032         Pop ecx

404A034         ret

FloatAdd ENDP

 

 

 

 

 

 

 

 

 

Before call to FloatAdd  
OFFSET  
  ESP
00000FF0        00000000  

 

EIP = 04040040  
After call to FloatAdd  
OFFSET  
  ESP
00000FF0        00000000
EIP = 04041020  

 

After Push ecx

OFFSET

00001000

00000FFC       04040046

00000FF8        (ecx)                ESP

00000FF4        00000000

00000FF0        00000000

 

After Push ebx

OFFSET

00001000

00000FFC       04040046

00000FF8        (ecx)

00000FF4        (ebx)               ESP

00000FF0        00000000

 

After Pop ebx

OFFSET

00001000

00000FFC       04040046

00000FF8        (ecx)                ESP

00000FF4        00000000

00000FF0        00000000

 

After Pop ecx

OFFSET

00001000                                ESP

00000FFC       04040046

00000FF8        00000000

00000FF4 00000000
00000FF0 00000000
After Re turn  
OFFSET  
  ESP
00000FF0        00000000
EIP = 04040046  

 

 

 

 

  • 07-jptjff.zip