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
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:
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.
Get Answers For Free
Most questions answered within 1 hours.