Question

A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval...

A) Is the code below secure? Explain your rationale.

ExitProcess PROTO

.data

firstval qword 20002000h

secondval qword 11111111h

thirdval qword 22222222h

sum qword 0

.code

main proc

     mov rax,firstval                   

     add rax,secondval       

     add    rax,thirdval

     mov    sum,rax

     mov    ecx,0

     invoke ExitProcess

main endp

end main

b) Transmitted messages often include a parity bit, whose value is combined with a data byte to produce an even number of 1 bits. Suppose a message byte in the AL register contains 01110101. Show how you could use the parity flag combined with an arithmetic instruction to determine if this message byte has even or odd parity.

C) Identify in the code where the unsecured assembly statement(s) is(are) located.

ExitProcess proto

.data

array dword 10h,20h,30h,40h

arraySize = 4

.code

main proc

     mov rdi,3

     mov rsi,2

     mov eax,array[rdi*4]      ; save last value

     mov ecx,3

L1:

     mov edx,array[rsi*4]

     move edx,array[rsi*5]

     mov array[rdi*4],edx

     dec rsi

     dec rdi

     loop L1

     mov array[rdi*4],eax      ; store saved value in first position

     mov array[rdi*10],eax

     mov   ecx,0                ; assign a process return code

     call ExitProcess     ; terminate the program

main endp

end

D) Show how you would order individual bytes in memory (lowest to highest) for the following double-word variable so it will be in a secure code state:

val1     DWORD 87654321h

Homework Answers

Answer #1

B) In order to determine the parity bit of the given message byte, we have to add a "Zero" to that message byte. We can add this zero using the arithmetic ADD instruction in assembly language.

Do note:

  • Parity Flag (PF) is set if there are even number of 1's in the messsage byte.
  • Parity Flag (PF) is not set i.e., PF = 0 if there are odd number of 1's in the messsage byte.

Below is the code snippet that uses Parity Flag combined with an arithmetic instruction to determine if the message byte has even or odd parity.

.code
mov al, 01110101      ; Message byte in AL
add al, 0             ; Arithmetic ADD Instruction, PF = 0 (odd)

In this way we can demonstrate the use of parity flag. Do rate the answer if it helpful. Thank You.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
6. (True/False): The RET instruction pops the top of the stack into the instruction pointer. 8....
6. (True/False): The RET instruction pops the top of the stack into the instruction pointer. 8. (True/False): In protected mode, each procedure call uses a minimum of 4 bytes of stack space. 1. Which instruction pushes all of the 32-bit general-purpose registers on the stack? 20. What values will be written to the array when the following code executes? .data array DWORD 4 DUP(0) .code main PROC mov eax,10 mov esi,0 call proc_1 add esi,4 add eax,10 mov array[esi],eax INVOKE...
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged             Mov al, bl       And 00111111, bl       Write a sequence of two instructions that copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Upper 4 bits of AL and BL will be cleared             Shr al, 4       Mov bl,...