You, as an individual, are expected to do your own work. This means you cannot seek, receive or otherwise acquire any assistance except clarifications from the professor during an examination. Any communication involving the contents of the subject matter or the examination is considered cheating. Do not initiate or accept such communication, or the result of your examination is automatically voided.
Each correct answer is worth one point, each wrong answer is worth zero point, and each unanswered question is also worth zero point. This means you should guess and leave no question unanswered.
Make sure you write down you name on the upper right corner first, otherwise I cannot give points to anonymous students!
The baseline is 10, there are 12 questions.
.lcomm ch 1
.global _start
.text
_start:
movl $1,%edx
movl $ch,%ecx
pushl %edx
pushl %ecx
movl $0,%ebx
movl $3,%eax
int $0x80
cmpl $0,%eax
jz done
cmpb $'\n',ch
jz _start
popl %ecx
popl %edx
movl $1,%ebx
movl $4,%eax
int $0x80
jmp _start
done:
movl $1,%eax
movl $0,%ebx
int $0x80
What is the output of this program, assuming the input file looks like the following? (Assume the input file is redirected to the program.) There are no empty lines, and no trailing spaces on each line.
12 34 5 6 7
12 34
1234567
12 34 5 6 7
12
12 34567
ax at the nop
instruction?
.global _start
.text
_start:
movw $46,%ax
pushw %ax
pushw %ax
call sub1
popw %ax
popw %ax
nop
movl $1,%eax
movl $0,%ebx
int $0x80
sub1:
movw 4(%esp),%ax
addw 6(%esp),%ax
ret
nop
nop, but the value of ax cannot be
determined
subl $8,(%esp)
subl 8,%esp
addl $8,%esp
popa
popf
call?
Assume the code in ... is correct and does not cause any problem
by itself.
sub1:
pushl %eax
# ...
popl %ebx
popl %eax
ret
call instruction
call instruction, depending on
the values on the stack that is not controled by the subroutine
popl %ebx instruction
popl %eax instruction
called?
sub1:
cmpb $0,%al
jz done
subb $1,%al
call sub1
done:
ret
al
ax at the nop instruction?
.global _start
.text
_start:
movw $0,%ax
call sub1
call sub2
call sub3
nop
movl $1,%eax
movl $0,%ebx
int $0x80
sub1: addw $1,%ax
sub2: addw $2,%ax
sub3: addw $3,%ax
ret
pushl %eax
popl %ebx
eax and ebx
eax to ebx
ebx to eax
subl $4,%esp
movl $523245,(%esp)
pushl 523245
ax after the following code executes?
movw $23, %ax
movw $67, %bx
movw $12, %dx
mulw %bx
ax cannot be determined just by the
code shown
getStdin:
movl $3,%eax
movl $0,%ebx
movl $1,%ecx
pushl %ebx
movl %esp,%ecx
movl $1,%edx
int $0x80
popl %ebx
ret
Describe the result after the following code executes:
call getStdin
ret
int $0x80
bl
eax
esp?
push %ebp
ret
call sub1
subl $4,%esp
movl var1,(%esp)
int instruction.
.text
.global _start
call sub1
call sub2
call sub3
movl $1,%eax
movl $0,%ebx
int $0x80
sub1:
call sub2
ret
sub2:
call sub3
ret
sub3:
ret