Fixed multdiv demo and removed redundant demo

This commit is contained in:
Mattias Hansson 2026-05-17 15:26:46 +02:00
parent 182c81b26a
commit 8775ebaf43
4 changed files with 6 additions and 173 deletions

View file

@ -4,9 +4,15 @@
// human-readable decimal output via decoutlib // human-readable decimal output via decoutlib
//----------------------------------------------------------- //-----------------------------------------------------------
#PRAGMA _P_REMOVE_UNUSED 1
#INCLUDE <c64start.c65> #INCLUDE <c64start.c65>
#INCLUDE <c64defs.c65> #INCLUDE <c64defs.c65>
#PRAGMA _P_REMOVE_UNUSED 0
#INCLUDE <multdivlib.c65> #INCLUDE <multdivlib.c65>
#PRAGMA _P_REMOVE_UNUSED 1
#INCLUDE <cbmiolib.c65> #INCLUDE <cbmiolib.c65>
#INCLUDE <decoutlib.c65> #INCLUDE <decoutlib.c65>

View file

@ -1,3 +0,0 @@
#!/bin/sh
PROGNAME="multdivlib_demo"
c65gm ${PROGNAME}.c65

View file

@ -1,168 +0,0 @@
//-----------------------------------------------------------
// MultDiv Library Demo
// Demonstrates multiplication and division routines
//-----------------------------------------------------------
#INCLUDE <c64start.c65>
#INCLUDE <c64defs.c65>
#INCLUDE <multdivlib.c65>
#INCLUDE <cbmiolib.c65>
#PRAGMA _P_USE_CBM_STRINGS 1
GOTO start
WORD high
BYTE i
//-----------------------------------------------------------
// Wait for key
//-----------------------------------------------------------
FUNC wait_key
BYTE key
WHILE 1
key = PEEK $c5
IF key = 64
BREAK
ENDIF
WEND
WHILE 1
key = PEEK $c5
IF key != 64
BREAK
ENDIF
WEND
POKE $c6 WITH 0
FEND
//-----------------------------------------------------------
// Main demo
//-----------------------------------------------------------
FUNC main
lib_cbmio_cls()
lib_cbmio_printlf("multdivlib demo")
lib_cbmio_printlf("===============")
lib_cbmio_lf()
WORD a
WORD b
//-----------------------------------------
// Test 1: mult - 123 * 456 (16-bit result)
// io:lib_multdiv_acc is input/output
// result in lib_multdiv_acc, high in lib_multdiv_ext
//-----------------------------------------
lib_cbmio_printlf("lib_multdiv_mult: 123 * 456 =")
a = 123
b = 456
lib_multdiv_mult(a, b)
lib_cbmio_print(" result: ")
lib_cbmio_hexoutw(lib_multdiv_acc)
lib_cbmio_lf()
lib_cbmio_lf()
lib_cbmio_print("press any key...")
wait_key()
lib_cbmio_lf()
lib_cbmio_lf()
//-----------------------------------------
// Test 2: mult32 - 65000 * 100 (32-bit result)
// out:high gets the high word
//-----------------------------------------
lib_cbmio_printlf("mult32: 65000 * 100 =")
a = 65000
b = 100
lib_multdiv_mult32(a, b, high)
lib_cbmio_print(" low: $")
lib_cbmio_hexoutw(lib_multdiv_acc)
lib_cbmio_print(" high: $")
lib_cbmio_hexoutw(high)
lib_cbmio_lf()
lib_cbmio_lf()
lib_cbmio_print("press any key...")
wait_key()
lib_cbmio_lf()
lib_cbmio_lf()
//-----------------------------------------
// Test 3: div - 1337 / 7
// quotient in lib_multdiv_acc, remainder in lib_multdiv_ext
//-----------------------------------------
lib_cbmio_printlf("lib_multdiv_div: 1337 / 7 =")
a = 1337
b = 7
lib_multdiv_div(a, b)
lib_cbmio_print(" quotient: ")
lib_cbmio_hexoutw(lib_multdiv_acc)
lib_cbmio_lf()
lib_cbmio_print(" remainder: ")
lib_cbmio_hexoutw(lib_multdiv_ext)
lib_cbmio_lf()
lib_cbmio_lf()
//-----------------------------------------
// Test 4: divmod - 1000 / 13
// out:high gets the remainder
//-----------------------------------------
lib_cbmio_printlf("divmod: 1000 / 13 =")
a = 1000
b = 13
lib_multdiv_divmod(a, b, high)
lib_cbmio_print(" quotient: ")
lib_cbmio_hexoutw(lib_multdiv_acc)
lib_cbmio_lf()
lib_cbmio_print(" remainder: $")
lib_cbmio_hexoutw(high)
lib_cbmio_lf()
lib_cbmio_lf()
lib_cbmio_print("press any key...")
wait_key()
lib_cbmio_lf()
lib_cbmio_lf()
//-----------------------------------------
// Test 5: Loop 0-9 multiplied by 10
//-----------------------------------------
lib_cbmio_printlf("loop: 0*10 through 9*10:")
lib_cbmio_lf()
i = 0
WHILE i < 10
a = i
b = 10
lib_multdiv_mult(a, b)
lib_cbmio_print(" ")
lib_cbmio_hexoutb(i)
lib_cbmio_print(" * 10 = ")
lib_cbmio_hexoutw(lib_multdiv_acc)
lib_cbmio_lf()
i++
WEND
lib_cbmio_lf()
lib_cbmio_printlf("done!")
FEND
LABEL start
main()
SUBEND

View file

@ -1,2 +0,0 @@
#!/bin/sh
x64 -autostartprgmode 1 multdivlib_demo.prg