Uploaded by us_store1

lab3

advertisement
Kuwait
University
Student Name:
COMPUTER SCIENCE DEPARTMENT
Student ID:
CS 221 – Computer Systems
Fall 2022/2023
Topic: Bit, Bytes and Binary
Lab #3
Objectives:
Students will learn the following concepts:



Bit Manipulation
Numbering system conversion
Arithmetic Operations
Setting up your work space
*Note: We need to use Command-Line Interface - CLI on VM most of the time.
"To switch to the complete terminal mode in Ubuntu 18.04 and above, simply use the
command Ctrl + Alt + F3. To switch back to the GUI (Graphical User Interface) mode, use the
command Ctrl + Alt + F2.




While in CLI use vi for code editing.
Use Git to push your code on your GitHub repository.
Include the link to your GitHub repository in your Classroom
submission.
Include in a separate word file all handmade solutions code and screen
captures of your runs to be submitted via Classroom.
*There are many helpful resources on YouTube to help you learn Git and VIM if you are not
familiar with these two tools
Pre –Lab:
Perform the following number conversions:
A. 0x39A7F8 to binary
B. Binary 1100100101111011 to hexadecimal
C. 0xD5E4C to Octal
Compiled By Mohammad Suoud
P ag e |1
Kuwait
University
Student Name:
COMPUTER SCIENCE DEPARTMENT
Student ID:
In –Lab:
Q1) Fill in the empty cells by making the right number system conversation (show
your work):
Base10
Base2
Base 8
Base 16
65
10001111
773
AB
Compiled By Mohammad Suoud
P ag e |2
Kuwait
University
Student Name:
COMPUTER SCIENCE DEPARTMENT
Student ID:
Q2) Perform the following decimal addition and subtraction conversions (show your
work)
F0000
- A123
___________
ABCD
+ ABCD
______________
-53 in two’s complement format
Compiled By Mohammad Suoud
P ag e |3
Kuwait
University
Student Name:
COMPUTER SCIENCE DEPARTMENT
Student ID:
Q3) Assume that the size in bytes of the types char, short, int, and float are 1, 2, 4 and 4, respectively.
What is the output of the following Program?
#include <iostream>
int main()
{
unsigned char ch;
Short i;
Short j=8;
int k = 64;
ch = -j >> 2;
i = ch;
j = j + ~5 +1;
K = (k<<3)& i;
cout << endl << i << endl << j<< endl << k << endl;
}
Compiled By Mohammad Suoud
P ag e |4
Kuwait
University
Student Name:
COMPUTER SCIENCE DEPARTMENT
Student ID:
Post –Lab:
Q1) Convert the following:
45(6) ---> base (3)
89(9) ---> base (2)
Q2) without converting the numbers to decimal or binary, try to solve the following
arithmetic problems, giving the answers in hexadecimal. Hint: Just modify the methods you
use for performing decimal addition and subtraction to use base 16.
Q3) Type the flowing command:
linux>
uname –a
What does this command tell us?
------------------------------------------------------------------------------------------------------------
linux>
man man
What does this command do?
------------------------------------------------------------------------------------------------------------
Compiled By Mohammad Suoud
P ag e |5
Download