q1a)# w# x# y# z# b# 0# 0# 0# 0# 1#
TRANSCRIPT
Q1 a) W X Y Z B 0 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 b)
x x' x' x
y 0 1 1 0 w
y' 0 1 1 1 w
y' 1 1 1 0 w'
y 0 1 1 1 w'
z' z' z z
c) a = x’ +w’y’z’ + wy’z + w’yz b = w + w’y + xz + x’z’
d) Q2)
Q3) A – data B – bss C – text D – stack E – heap Q4) The loader allocates space for the execution file. It loads the executable file and the shared libraries into the memory. It performs all the required functions. The loader jumps to the _start entry point when the image is ready which calls init(). _start calls the exit() when main() returns. Q5)
Static linker – It occurs when the linker copies all the library subroutines used in the program into the executable image Dynamic linker – It occurs by placing the name of a sharable library in the executable image Q6) 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 0 0 1 0 1 0 = 74 1 1 0 1 = 13 1 1 1 1 0 0 0 0 1 0 = 962 74 * 13 = 962 Q7) 11011 R 0 1011 | 100101001 1011 01111 1011 01000 0000 10000 1011 01011 1011 0000 Q8) S = 0 E= 01111111111 M = 010000…. Therefore binary representation is 0011111110100… Q9) A pipe stall is when a process is held up because it needs an input from another register. It can be avoided by reordering the instructions such that no instruction is followed by another instruction which requires an input from the previous register. Q10) 78 = 01001110
58 = 00111010 -‐58 = 11000110 11000110 01001110 00010100 (overflow 1) 4 + 16 = 20 (Verified) Q11) int isBigEndian(){ int i = 5; char * p = (char*) &i; if(*p!=5) return 1; else return 0; } Q12) Under Von Newman architecture, the CPU cannot read an instruction and perform the transfer of data at the same time. Under Harvard architecture, the CPU can do both at the same time. Q13) CISC – Complex Instruction Set Computer
-‐ has many instructions -‐ instructions take different times to complete
RISC – Reduced Instruction Set Computer -‐ has few instructions, i.e 32 or 64 -‐ instructions have same length, so take same amount of time to complete
Q14) ATMEGA328 Program Memory(KB): 32 RAM (KB): 2 Clock Speed (Hz): 16000000 Number of I/O ports: 6 Number of A/D ports: 14 Q14) .data movq $6, %rdi movq $3, %rdx movq $0, %rax .globl main main:
addq %rdi, %rdx movq %rdx, %rax ret Q15) .data movq $6, %rdi movq $4, %rdx movq $0, %rax .globl main main: imulq %rdi, %rdx movq %rdx, %rax ret Q16) .text .globl addarray .type addarray, @function addarray: movl $0, %eax
movq $0, %rdx L1: cmpq %rdx, %rdi je L2 addq $1, %rdx add (%rsi), %rax add $4, %rsi jmp L1 L2: ret Q17) .data movq $2, %r8 movq $0, %rbx movq $0, %rdx
formatString: .string “%d” formatStringP: .string “%d\n” .text
.globl main main: movq $formatString, %rdi movq %rbx, %rsi movq $0, %rax call scanf movq $formatString, %rdi movq %rdx, %rsi movq $0, %rax call scanf
cmpq %rbx, %rdx jg disp1 cmpq %rbx, %rdx jg disp2 disp1: movq $formatStringP, %rdi movq (%rbx), %rsi movq $0,%rax call printf movq $formatStringP, %rdi movq (%rdx), %rsi movq $0,%rax call printf jmp final disp2: movq $formatStringP, %rdi movq (%rdx), %rsi movq $0,%rax call printf movq $formatStringP, %rdi movq (%rbx), %rsi movq $0,%rax call printf jmp final final: addq %rdx,%rbx idivq %rbx, %r8 movq %r8, %rax
ret