Computer Systems Fundamentals

Course Resources

Administrivia: Course Outline | COMP1521 Handbook
Administrivia: Course Timetable | Help Sessions
Meet the Team: Our Team
Platforms: Lecture Recordings | Online Tut-Labs and Help Sessions (via BbCollaborate) | Course Forum
Style Guides: COMP1521 C Style Guide | Assembly Style Guide
MIPS Resources: MIPS Documentation | Text Editors for Assembly
mipsy: mipsy-web | mipsy source code | Debugging with mipsy (video)
Revision: Linux Cheatsheet | C Reference
Assessment: Autotests, Submissions, Marks | Give online: submission | Give online: sturec

Course Content Week-by-Week

Tutorial
Laboratory
Monday Week 1 Lecture Topics

Course Content Topic-by-Topic

Course Intro
Mips Basics

Print hello world in MIPS.
	.text
main:

	li	$v0, 4			# syscall 4: print_string
	la	$a0, hello_world_msg	#
	syscall				# printf("Hello world\n");


	li	$v0, 0
	jr	$ra			# return 0;

	.data

hello_world_msg:
	.asciiz	"Hello world\n"

Download hello_world.s


Perform some basic arithmetic.

#include <stdio.h>

int main(void) {
    int x = 17;
    int y = 25;

    printf("%d\n", 2 * (x + y));

    return 0;
}

Download math.c


Perform some basic arithmetic.

#include <stdio.h>

int main(void) {
    int x = 17;
    int y = 25;

    int z = x + y;
    z = 2 * z;

    printf("%d", z);
    putchar('\n');

    return 0;
}

Download math.simple.c


Do some basic arithmetic in MIPS.
main:
	# Locals:
	# - $t0: int x
	# - $t1: int y
	# - $t2: int z

	li	$t0, 17		# int x = 17;
	li	$t1, 25		# int y = 25;

	add	$t2, $t0, $t1	# int z = x + y;
	mul	$t2, $t2, 2	# z = z * 2;

	li	$v0, 1		# syscall 1: print_int
	move	$a0, $t2	#
	syscall			# printf("%d", z);

	li	$v0, 11		# syscall 11: print_char
	li	$a0, '\n'	#
	syscall			# putchar('\n');

	li	$v0, 0
	jr	$ra		# return 0;

Download math.s


Do some basic arithmetic in MIPS, but with one less register.

main:
	# Locals:
	# - $t0: int x
	# - $t1: int y

	li	$t0, 17		# int x = 17;
	li	$t1, 25		# int y = 25;

	li	$v0, 1		# syscall 1: print_int
	add	$a0, $t0, $t1	# (x + y)
	mul	$a0, $a0, 2	# * 2
	syscall			# printf("%d", 2 * (x + y));

	li	$v0, 11		# syscall 11: print_char
	li	$a0, '\n'	#
	syscall			# putchar('\n');

	li	$v0, 0
	jr	$ra		# return 0;

Download math.fewer_registers.s