1. In the following code, the value in AL is intended to be a signed byte. Expla
ID: 3754129 • Letter: 1
Question
1. In the following code, the value in AL is intended to be a signed byte. Explain how the Overflow flag helps, or does not help you, to determine whether the final value in AL falls within a valid signed range. mov al.-1 add al, 130 2. Trace the following program: 1: main PROC 2: mov eax,5 3: add eax,6 4: sub eax, 6 5: mov ebx, eax what is the value in eax- and in eb 3. At which level/s can an assembly language program manipulate input/output? 4. How do you reserve space for the stack in a program?Explanation / Answer
ANSWER:
The value in AL is intended to be a signed byte.
1.Overflow flag(OF) works on signed numbers.
When result of addition or subtraction is in range -128 to 127 then OF = 0 else OF = 1.
mov al , -1
add al , 130
These instructions results in al = 129 which is big enough to fit in 8-bit for signed numbers ,hence overflow flag is set to 1.
In other words, 129 is greater than 127 hence is out of range to fit in 8-bits for signed numbers.
If overflow flag is set to 1 then fina value of AL doesnot falls within a valid signed range. If OF =0 then it falls within the range.3.
2.main PROC
mov eax,5
add eax,6
sub eax, 6
mov ebx, eax
The value in eax = 5 and in ebx= 5
Solution:
The value of eax as well as ebx will be 5. According to the program, the main program PROC is called. The value 5 is moved into the register eax. This value 5 is added to 6 according to the instruction add eax, 6 making the value to be 11 in eax. Now, subtract the value 6 from eax such that the value becomes 11-6 = 5. Now, move the value of ebx into eax to get the value 5 into ebx.
Hence, eax = 5, ebx = 54.
3.The levels at which an assembly language can manipulate the input/output are as follows:
Application program
Operating System
BIOS
Hardware7.
4.The space for the stack in a program is reserved through .STACK directive. This directive is used to identify the variables/procedures of the program code that is kept on the stack. This directive is followed by the integer that specifies the number of bytes reserved for the space.