This page is located in a preparation section till 18.02.2019.

The Forth Homework - Code Analysis

The task assignment is provided to the students in the paper form.

The task assignment is available in PDF format as well on

Each student receives number from the seminar tutor.

Information sources for homework 4. solution

Example of little more complex program analysis than are programs in students assignments is available in archive.

Each task includes same algorithm compiled for i386 Linux system and MIPS Linux system.

i386 assembler syntax uses AT&T and GNU assembler/disassembler variant.

GNU Assembler Syntax

Description of the small subset of used system calls which are used in the code fragments can be found in the materials to the lecture

Parameters Passing to Subroutines and Operating System Implemented Virtual Instructions (System Calls)

This lecture includes enough information for i386 system calls. The MIPS architecture uses same system calls set but system calls numeric codes are different. The assignment can be found directly in GLIBC or Linux kernel sources cross-reference

or directly in the Linux kernel sources GIT repository


System calls use for the call return value which is 32 or 64-bit usually the same register(s) as are used for regular function calls return value. The additional information which has to be passed to the caller is information about call failure/error. Linux kernel uses special range of the return values. The system call failure is indicated by return value in the range of “small negative number”. The impact of this selection is that system calls cannot return negative values or pointer values near the top of the address range (addresses are taken as unsigned) as a valid results. The C library then check if syscall result is in this reserved range and setups thread specific global variable errno in such case and usually return minus one (for some syscalls NULL) as indication of syscall failure to the calling program according to the POSIX specification. List of the error codes is included in GLIBC documentation and can be found in Linux kernel sources include files as well

The actual return value of the syscall in the case of error is negated value of the listed error code (this is -ENOSYS for nonexistent system call for example). LIBC errno then hold positive value of the error code.

An complete description of the callin convention for MIPS architecture (variant used for GNU/Linux system) can be found in the document MIPSpro N32 ABI Handbook

courses/b35apo/en/homeworks/04/start.txt · Last modified: 2019/02/11 00:03 (external edit)