Table of Contents

1. Introduction to the labs, computer number formats, numeral systems, entrance test

Exercise outline

  1. requirements and evaluations
  2. laboratory and computer system introduction
  3. basic data types (integer number) storage in computer memory, program in C

What should I repeat before the first exercise

  1. binary representation and hexadecimal numbers
  2. C language syntax
  3. terms little and big endian
  4. the second complement code

What shall we do on the first exercise

Aim of this exercise is to get familiar with classroom, to repeat some basic terms and number representation in computer systems.

The exercise will be based on following C code. It prints number representation in computer memory. We shall modify the code during the class.

#include <stdio.h>

#define PRINT_MEM(a) print_mem((unsigned char*)&(a), sizeof(a))

void print_mem(unsigned char *ptr, int size) {
  int i;
  printf("address = 0x%08lx\n", (long unsigned int)ptr);

  for (i = 0; i < size; i++) {
    printf("0x%02x ", *(ptr+i));
  }

  printf("\n");
}

int main() {
  unsigned int unsig = 5;
  int sig = -5;

  printf("value = %d\n", unsig);
  PRINT_MEM(unsig);

  printf("\nvalue = %d\n", sig);
  PRINT_MEM(sig);

  return 0;
}

To compile the program: gcc -Wall -ansi -pedantic ./program.c

Tasks

  1. Compile and execute program above
  2. Explain output of the program
  3. Alter the code to print representation of other data types (float, char, double, long, etc…)
  4. Alter the code to print numbers and their representation between -16…15.
  5. Modify the program to add and subtract integer numbers and print arguments and results (in “normal” form and computer representation).
  6. Try to add and subtract negative and positive numbers. Try to cause integer overflow and underflow.

Homeworks

Computer network in lab KN:E-307

In this semester we have started a new OS installation that allows students to work with their home directories. After the computer is turned on a boot loader menu pops up and you can choose of:

Logins and passwords

The computer access and logins are authenticated against Kerberos server of Department of Computer Sciences.

A password for access to GNU-Linux workstations at Department of Computer Sciences can be set on a page http://www.felk.cvut.cz/?setLang=en , from a section IT services at Charles Square

Set up the password for laboratories KN:E-307, KN:E-310, KN:E-311, KN:E-331, T2:H1-130, T2:H1-131.

Remote access to your data

The data in your home dictories are also available in rooms KN:E-2 and KN:E-s109 and are also accessible on server postel.felk.cvut.cz via SSH protocol. In Linux OS you can mount your home directories even from your home computer using sshfs utility (for example sshfs jmeno@postel.felk.cvut.cz /mnt/tmp).

Troubleshooting, data recovery

In the case of problem with computers or network, please, contact Ing. Petr Benda (petr.benda@fel.cvut.cz) responsible for K13136 computers infrastructure.