CSC231 Sample Midterm Questions
--D. Thiebaut (talk) 08:01, 21 October 2015 (EDT)
Below are typical questions you might expect during the in-class CSC231 Midterm Exam
- Question 1
- Assume that eax, ebx, ecx, and edx all 4 contain the value 0 before the program below start. Indicate the value of each 32-bit register after each instruction has been executed.
;; eax = ebx = ecx = edx = 0x00000000 mov al, 3 ; eax = 0x00000003 mov bx, 0x1122 ; ebx = __________ mov ecx,3 ; ecx = __________ mov ah, 5 ; eax = __________ mov ecx, 10 ; ecx = __________ for: inc edx loop for ; edx = __________ ; ecx = __________
- Question 2
- Same as Question 1
;; eax = ebx = ecx = edx = 0x00000000 or ax, 0xffff ; eax = __________ or bl, 0xff ; ebx = __________ or cx, 0xff ; ecx = __________ or edx,0xffff0000 ; edx = __________ and ax, 0xff00 ; eax = __________ and bx, 0x0f ; ebx = __________
- Question 3
- Write a short program that displays all the numbers from 25 down to 1. We assume that _printDec and _println are available.
- Question 4
- Write a short program that displays all the numbers from 5 to 20.
- Question 5
- What is a segmentation fault?
- Question 6
- What is printed by the following code? Do not worry about it lacking an exit section.
section .data msg db 10,10,10,"hello ",10 msg2 db "world",10,"!" msg3 db 0x0a section .text mov ebx,msg add byte [ebx+9],'-'-10 mov byte [msg3-2],' ' mov eax, 4 mov ebx, 1 mov ecx,msg mov edx,msg3-msg int 0x80
- Question 7
- What is a big-endian processor?
- Question 8
- Write a program that uses only one string of characters "********" and that prints this pattern:
******** ****** **** **
- Question 9
- The RAM containing the data section of the program below is shown here, as a collection of successive bytes. The top byte has the lowest address of the group. In other words, addresses increase as we go down the array of bytes.
- Show the contents of the RAM once the array has been initialized with the variables a, b, msg and c.
section .data a dd 10 b dd 0x1234 msg db 1,2,3,4,5,6,7 c dw 0xaa
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
| |
+--------------+
Question 10
- Convert the following hexadecimal numbers in binary
- 1
- 10
- 16
- Convert the following decimal numbers to binary
- 1
- 10
- 16
- Convert the following binary numbers to hexadecimal
- 1001
- 11001101
- 111000111000
- 'A' has ASCII code 0x41.
- What is the code for 'B'?
- What is 'A' + 0x20?