Skip to content

Commit bcf46dc

Browse files
Add API section to standard library
1 parent 01380c9 commit bcf46dc

File tree

7 files changed

+54
-2
lines changed

7 files changed

+54
-2
lines changed

lib/csprng.asmln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#ChaCha20-based cryptographically secure pseudorandom number generator
2+
#
3+
# API:
4+
# CS_PRNG_SEED(INT:seed) -> INT
5+
# CS_PRNG_NEXT() -> INT
6+
# CS_PRNG_RANGE(INT:max) -> INT
7+
# CS_PRNG_RANGE_MIN_MAX(INT:min, INT:max) -> INT
28

39
INT: MASK32 = SUB( POW(10,100000), 1 ) # 2^32-1
410

lib/decimal.asmln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Decimal <-> binary helpers
2+
#
3+
# API:
4+
# DEC_CHAR_TO_INT(STR:ch) -> INT
5+
# INT_TO_DEC_CHAR(INT:d) -> STR
6+
# DEC_TO_INT(STR:s) -> INT
7+
# INT_TO_DEC(INT:n) -> STR
28

39
INT: DEC_BASE = 1010 # 10
410

lib/path.asmln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# Path utilities for ASM-Lang
2+
#
3+
# API:
4+
# NORMALIZE_PATH(STR: path) -> STR
5+
# BASEPATH(STR: path) -> STR
6+
# BASENAME(STR: path) -> STR
7+
# SPLITEXT(STR: path) -> TNS
8+
# EXTNAME(STR: path) -> STR
9+
# DELEXT(STR: path) -> STR
10+
# STR: interpreter
11+
# STR: interpreter_dir
12+
# STR: script
13+
# STR: script_dir
214

315
FUNC NORMALIZE_PATH(STR: path):STR{
416
RETURN(REPLACE(path,"\","/"))

lib/prime.asmln

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# Primality test for n
1+
# Primality and factorization functions
2+
#
3+
# API:
4+
# IS_PRIME(INT:n) -> INT
5+
# NEXT_PRIME(INT:start) -> INT
6+
# PREV_PRIME(INT:start) -> INT
7+
# IS_MERSENNE_PRIME(INT:p) -> INT
8+
# FACTOR(INT:n) -> TNS
9+
210
FUNC IS_PRIME(INT:n):INT{
311
IF(LTE(n,1)){
412
RETURN(0)

lib/prng.asmln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# LCG-based pseudorandom number generator
2+
#
3+
# API:
4+
# PRNG_SEED(INT:seed) -> INT
5+
# PRNG_NEXT() -> INT
6+
# PRNG_RANGE(INT:max) -> INT
7+
# PRNG_RANGE_MIN_MAX(INT:min, INT:max) -> INT
8+
29
INT: MASK32 = SUB( POW(10,100000), 1 ) # 2^32 - 1
310

411
# LCG constants: state = (A * state + C) mod 2^32

lib/waveforms.asmln

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
# Waveform Generators
1+
# Waveform utilities
2+
#
3+
# API:
4+
# AUDIO_CLAMP(INT:v) -> INT
5+
# SQUARE(INT:freq, INT:ms, INT:amp, INT:sr) -> TNS
6+
# SAWTOOTH(INT:freq, INT:ms, INT:amp, INT:sr) -> TNS
7+
# TRIANGLE(INT:freq, INT:ms, INT:amp, INT:sr)
8+
# SINE(INT:freq, INT:ms, INT:amp, INT:sr) -> TNS
9+
# PULSE(INT:freq, INT:ms, INT:amp, INT:sr, INT:duty) -> TNS
10+
# ENVELOPE_ADSR(TNS:shape, INT:attack, INT:decay, INT:sustain, INT:release) -> TNS
11+
# LOWPASS(TNS:inp, INT:cutoff, INT:sr) -> TNS
12+
# HIGHPASS(TNS:inp, INT:cutoff, INT:sr) -> TNS
213

314
# Constants / helpers local to this module.
415
# MS_DEN is the number of milliseconds per second (1000).

test.asmln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ FUNC RUN_TESTS():INT{
124124
ASSERT(EQ(high[1], 0))
125125
ASSERT(EQ(high[11], 0))
126126

127+
PRINT("Waveform library tests passed.")
128+
127129
# If we reach here all tests passed; print success code and return
128130
PRINT("All tests passed.")
129131
RETURN(0)

0 commit comments

Comments
 (0)