This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This file contains an unoptimized, recursive GCD implementation. */ | |
/* The code assumes %rdi and %rsi will be unsigned... if signed, then cqto will be needed to sign-extend %rax to %rdx:%rax. */ | |
/* What are some ways to optimize it? */ | |
.data | |
fmtstr: | |
.ascii "%d\n" | |
.text | |
.globl gcd |
The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.
Timers will never expire before the requested time, but may expire some (short) time afterwards, which
depends on the system timer resolution and on the system load; see
time(7)
.
Upon expiration, a signal will be generated and the timer reset.
To invoke a system call:
- Set
%rax
to the system call number (see Full Table below); - Set
%rdi
,%rsi
,%rdx
,%r8
,%r10
,%r9
(in order) according to theglibc
prototype given in the manual; then - Perform
syscall
instruction.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main: main.o asm.o | |
gcc -o main main.o asm.o | |
main.o: main.s | |
as --gstabs+ -o main.o main.s | |
main.s: main.c main.h | |
gcc -std=c17 -Wall --pedantic-errors -g -O0 -S -o main.s main.c | |
asm.o: asm.s main.h |