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...
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
7. (True/False): Nested procedure calls are not permitted by the Microsoft assembler unless the NESTED operator...
7. (True/False): Nested procedure calls are not permitted by the Microsoft assembler unless the NESTED operator is used in the procedure definition. 15. What will be the final value in EAX after these instructions execute? push 5 push 6 pop eax pop eax 3. Which instruction pops the stack into the EFLAGS register? 17. Which statement is true about what will happen when the example code runs? 1: main PROC 2: mov eax,30 3: push eax 4: push 40 5:...
13. (True/False): The register list in the USES directive must use commas to separate the register...
13. (True/False): The register list in the USES directive must use commas to separate the register names. 11. (True/False): The USES operator lets you name all registers that are modified within a procedure. 2. Which instruction pushes the 32-bit EFLAGS register on the stack? 18. Which statement is true about what will happen when the example code runs? 1: main PROC 2: mov eax,40 3: push offset Here 4: jmp Ex4Sub 5: Here: 6: mov eax,30 7: INVOKE ExitProcess,0 8:...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT