Here are some examples of MAL programs.
-
sums.s -
Computes and displays the sum of integers from 1 up to n, where n is
entered by the user.
Illustrates declaration of string constants in a .data section,
a simple loop, and input, output, and program termination using the
syscall instruction.
-
search.s -
Tests the function search(), which searches for an entry in an
array.
Illustrates the simple subprogram linkage protocol, a static array
declaration in a .data section, and random access into an array.
-
search_1.s -
Tests the function search(), which searches for an entry in an
array.
Illustrates the simple subprogram linkage protocol, dynamic array
creation, and random access into an array.
-
fact.s -
Computes and displays the factorial of n, where n is entered by the
user.
The program prompts for new values of n until the user enters a
negative number.
Illustrates recursion using a stack-based subprogram linkage protocol.
A zipped folder containing these examples can be downloaded
here.