From 53bf775c68a92b61e64228256cfe10ff7282a63c Mon Sep 17 00:00:00 2001 From: Jimmy Dansbo Date: Tue, 18 Nov 2025 07:26:23 +0100 Subject: [PATCH 1/3] Added documentation for new MOD command in BASIC --- X16 Reference - 04 - BASIC.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 0d54b08..5963940 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -84,6 +84,7 @@ for GitHub's Markdown flavor. Do not remove! | `LOG` | function | Returns the natural logarithm of a number | C64 | | [`MENU`](#menu) | command | Invokes the Commander X16 utility menu | X16 | | `MID$` | function | Returns a substring from the middle of a string | C64 | +| [`MOD`](#mod) | function | Returns the truncated remainder of a division | X16 | | [`MON`](#mon) | command | Enters the machine language monitor | X16 | | [`MOUSE`](#mouse) | command | Hides or shows mouse pointer | X16 | | [`MOVSPR`](#movspr) | command | Set the X/Y position of a sprite | X16 | @@ -950,6 +951,30 @@ The values are 1-based. If no column is given, only the line is changed. MENU ``` +### MOD + +**TYPE: Function** +**FORMAT: MOD(<dividend>, <divisor>)** + +**Action:** Returns the truncated remainder of dividend divided by divisor + +The `MOD` function supports 16bit signed numbers (-32768 - 37767) + +**EXAMPLE of MOD Function:** +```BASIC +PRINT MOD(-17, 5) +-2 + +PRINT MOD(17, 5) + 2 + +PRINT MOD(42, 0) +?DIVISION BY ZERO ERROR + +PRINT MOD(65000, 101) +?ILLEGAL QUANTITY ERROR +``` + ### MON **TYPE: Command** From 42f620c0b8d12688969ddb65f1acfbef0c634c15 Mon Sep 17 00:00:00 2001 From: Jimmy Dansbo Date: Tue, 18 Nov 2025 07:29:26 +0100 Subject: [PATCH 2/3] Fixing typo and trying to clarify description --- X16 Reference - 04 - BASIC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 5963940..0145aed 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -956,9 +956,9 @@ MENU **TYPE: Function** **FORMAT: MOD(<dividend>, <divisor>)** -**Action:** Returns the truncated remainder of dividend divided by divisor +**Action:** Returns the truncated remainder of <dividend> divided by <divisor> -The `MOD` function supports 16bit signed numbers (-32768 - 37767) +The `MOD` function supports 16bit signed numbers (-32768 to 32767) **EXAMPLE of MOD Function:** ```BASIC From cade89cea569772bc683011668426e3881d8abd3 Mon Sep 17 00:00:00 2001 From: Jimmy Dansbo Date: Tue, 18 Nov 2025 07:33:42 +0100 Subject: [PATCH 3/3] Added comments in example --- X16 Reference - 04 - BASIC.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 0145aed..89f810e 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -962,16 +962,16 @@ The `MOD` function supports 16bit signed numbers (-32768 to 32767) **EXAMPLE of MOD Function:** ```BASIC -PRINT MOD(-17, 5) +PRINT MOD(-17, 5) :REM RESULT WILL HAVE THE SAME SIGN AS DIVIDEND -2 PRINT MOD(17, 5) 2 -PRINT MOD(42, 0) +PRINT MOD(42, 0) :REM DIVISOR IS 0, RETURN ERROR ?DIVISION BY ZERO ERROR -PRINT MOD(65000, 101) +PRINT MOD(65000, 101) :REM DIVIDEND IS TOO LARGE FOR A SIGNED 16BIT VALUE ?ILLEGAL QUANTITY ERROR ```