Compare commits
24 commits
Author | SHA1 | Date | |
---|---|---|---|
50a602383a | |||
51613ec605 | |||
1ec424f4e2 | |||
0196eac7dc | |||
684a30b299 | |||
ff61cf5601 | |||
637da8d677 | |||
947e10906d | |||
bf945bdc26 | |||
584c3e5ef5 | |||
2c782e0b62 | |||
105215819f | |||
105a361908 | |||
af8c3fd0b7 | |||
87e88b6377 | |||
83ff071c62 | |||
f4ce5ce439 | |||
01da2d884e | |||
6a90b129b7 | |||
bf5cebfdd7 | |||
64db604da9 | |||
f551cdb3c0 | |||
09a290dd78 | |||
7ee938a8ae |
5
.travis.yml
Normal file
5
.travis.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
language: c
|
||||
install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo make build-dep
|
||||
script: make
|
192
Makefile
Normal file
192
Makefile
Normal file
|
@ -0,0 +1,192 @@
|
|||
# Top level Makefile for GBDK that combines the builds for sdcc,
|
||||
# gbdk-lib, and gbdk-support
|
||||
#
|
||||
# 2001 Michael Hope <michaelh@juju.net.nz>
|
||||
# $Id: Makefile,v 1.4 2001/11/04 18:43:51 michaelh Exp $
|
||||
#
|
||||
TOPDIR = $(shell pwd)
|
||||
|
||||
# Package name, used for tarballs and cvs
|
||||
PKG = gbdk
|
||||
# Version, used for tarballs
|
||||
VER ?= $(shell git describe --tags --always | sed "s/^$(PKG)-//")
|
||||
|
||||
# Prefix to add to the standard tools. Usefull for a standard gcc
|
||||
# cross-compile.
|
||||
TOOLSPREFIX =
|
||||
|
||||
TARGETCC = $(TOOLSPREFIX)gcc
|
||||
TARGETRANLIB = $(TOOLSPREFIX)ranlib
|
||||
TARGETAR = $(TOOLSPREFIX)ar
|
||||
TARGETCXX = $(TOOLSPREFIX)g++
|
||||
TARGETSTRIP = $(TOOLSPREFIX)strip
|
||||
# Add extra flags here. g++ 2.95.4 requires -fdollars-in-identifiers
|
||||
TARGETCXXFLAGS =
|
||||
|
||||
# Directory containing the source to sdcc
|
||||
SDCCDIR = $(TOPDIR)/sdcc
|
||||
# Directory containing the source to gbdk-lib
|
||||
GBDKLIBDIR = $(TOPDIR)/gbdk-lib
|
||||
# Directory containing the source to gbdk-support
|
||||
GBDKSUPPORTDIR = $(TOPDIR)/gbdk-support
|
||||
# Directory containing the source to maccer
|
||||
MACCERDIR = $(TOPDIR)/maccer
|
||||
|
||||
# Base setup
|
||||
# Extension to add to executables
|
||||
EXEEXTENSION =
|
||||
# Host operating system identifier. The one below should work for
|
||||
# most systems.
|
||||
HOSTOS := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
# Target operating system identifier. Used in the output zip name.
|
||||
TARGETOS = $(HOSTOS)
|
||||
|
||||
# Directory that gbdk should finally end up in
|
||||
TARGETDIR = /opt/gbdk
|
||||
# Directory that gbdk for this target is built into.
|
||||
BUILDDIR = $(TOPDIR)/build/$(TARGETOS)/gbdk
|
||||
# Intermediates directory
|
||||
INTDIR = $(TOPDIR)/tmp
|
||||
|
||||
NOISELOG = $(TOPDIR)/noise.log
|
||||
|
||||
all: native-build
|
||||
|
||||
clean: sdcc-clean gbdk-support-clean gbdk-lib-clean maccer-clean
|
||||
|
||||
distclean: clean build-dir-clean
|
||||
|
||||
# Cross-compilation targets
|
||||
FIXUPMASKS = *.c *.h .bat *.s ChangeLog README
|
||||
|
||||
build-dep:
|
||||
sudo apt-get install -y build-essential bison flex
|
||||
|
||||
native-build: gbdk-build gbdk-install
|
||||
|
||||
cross-clean: sdcc-clean gbdk-support-clean
|
||||
|
||||
cross-build: gbdk-build gbdk-install cross-cleanup
|
||||
|
||||
cross-cleanup:
|
||||
ifdef MSDOSLINEENDS
|
||||
for i in $(FIXUPMASKS); do \
|
||||
find $(BUILDDIR) -name $$i -exec unix2dos {} \; ; \
|
||||
done
|
||||
endif
|
||||
|
||||
cross-linux-mingw32-build:
|
||||
$(MAKE) TARGETOS=i586-mingw32msvc \
|
||||
TOOLSPREFIX=i586-mingw32msvc- \
|
||||
EXEEXTENSION=.exe \
|
||||
CROSSCOMPILING=1 \
|
||||
MSDOSLINEENDS=1 \
|
||||
TARGETDIR=/sdcc \
|
||||
ARCHIVETYPE=zip \
|
||||
cross-build gbdk-lib-examples-makefile binary
|
||||
|
||||
# Source code drop
|
||||
src: clean
|
||||
rm -rf gbdk
|
||||
mkdir -p gbdk
|
||||
cp -r Makefile sdcc gbdk-lib gbdk-support gbdk
|
||||
rm -rf `find gbdk -name CVS`
|
||||
tar czf gbdk-$(VER).tar.gz gbdk
|
||||
|
||||
# Base rules
|
||||
gbdk-build: sdcc-build gbdk-support-build gbdk-lib-build
|
||||
|
||||
gbdk-install: sdcc-install gbdk-support-install gbdk-lib-install
|
||||
|
||||
# Directories
|
||||
build-bin-dir:
|
||||
mkdir -p $(BUILDDIR)/bin
|
||||
|
||||
build-dir-clean:
|
||||
rm -r $(BUILDDIR)
|
||||
|
||||
# Rules for sdcc
|
||||
SDCCCONFIGUREFLAGS = \
|
||||
--disable-mcs51-port \
|
||||
--disable-avr-port \
|
||||
--disable-ds390-port \
|
||||
--disable-pic-port \
|
||||
--disable-i186-port \
|
||||
--disable-tlcs900h-port \
|
||||
--disable-ucsim \
|
||||
--disable-device-lib-build \
|
||||
--disable-packihx
|
||||
|
||||
SDCCCONFIGUREFLAGS += \
|
||||
--prefix=$(TARGETDIR) \
|
||||
--program-suffix=$(EXEEXTENSION)
|
||||
|
||||
sdcc-build: $(SDCCDIR)/sdccconf.h
|
||||
$(MAKE) -C $(SDCCDIR) SDCC_SUB_VERSION=$(PKG)-$(VER)
|
||||
|
||||
$(SDCCDIR)/sdccconf.h:
|
||||
cd $(SDCCDIR); CC=$(TARGETCC) CXX=$(TARGETCXX) STRIP=$(TARGETSTRIP) RANLIB=$(TARGETRANLIB) CXXFLAGS=$(TARGETCXXFLAGS) ./configure $(SDCCCONFIGUREFLAGS) --host=$(HOSTOS)
|
||||
|
||||
sdcc-install: sdcc-build build-bin-dir
|
||||
rm -rf $(INTDIR)/sdcc
|
||||
$(MAKE) -C $(SDCCDIR) install prefix=$(INTDIR)/sdcc
|
||||
cp $(INTDIR)/sdcc/bin/sdcc* $(INTDIR)/sdcc/bin/sdcpp* $(INTDIR)/sdcc/bin/link-* $(INTDIR)/sdcc/bin/as-* $(BUILDDIR)/bin
|
||||
|
||||
# PENDING: Hack below
|
||||
sdcc-clean:
|
||||
-$(MAKE) -C $(SDCCDIR) distclean
|
||||
touch $(SDCCDIR)/doc/holder.pdf
|
||||
|
||||
# Rules for gbdk-support
|
||||
gbdk-support-build:
|
||||
$(MAKE) -C $(GBDKSUPPORTDIR)/lcc TOOLSPREFIX=$(TOOLSPREFIX) TARGETDIR=$(TARGETDIR)/
|
||||
|
||||
gbdk-support-install: gbdk-support-build build-bin-dir
|
||||
cp $(GBDKSUPPORTDIR)/lcc/lcc $(BUILDDIR)/bin/lcc$(EXEEXTENSION)
|
||||
$(TARGETSTRIP) $(BUILDDIR)/bin/lcc*
|
||||
cp $(GBDKSUPPORTDIR)/README $(GBDKSUPPORTDIR)/ChangeLog $(BUILDDIR)
|
||||
|
||||
gbdk-support-clean:
|
||||
$(MAKE) -C $(GBDKSUPPORTDIR)/lcc clean
|
||||
|
||||
# Rules for gbdk-lib
|
||||
gbdk-lib-build: maccer-build
|
||||
ifndef CROSSCOMPILING
|
||||
PATH=$(PATH):$(INTDIR)/host $(MAKE) -C $(GBDKLIBDIR)/libc PORTS=gbz80 PLATFORMS=gb SDCCLIB=$(SDCCDIR)
|
||||
endif
|
||||
|
||||
gbdk-lib-install: gbdk-lib-build
|
||||
cp -r $(GBDKLIBDIR)/libc $(GBDKLIBDIR)/include $(GBDKLIBDIR)/examples $(GBDKLIBDIR)/tools $(BUILDDIR)
|
||||
rm -rf $(BUILDDIR)/lib
|
||||
cp -r $(GBDKLIBDIR)/build $(BUILDDIR)/lib
|
||||
|
||||
gbdk-lib-clean:
|
||||
$(MAKE) -C $(GBDKLIBDIR) clean
|
||||
|
||||
gbdk-lib-examples-makefile:
|
||||
$(MAKE) -C $(BUILDDIR)/examples/gb make.bat
|
||||
unix2dos $(BUILDDIR)/examples/gb/make.bat
|
||||
|
||||
maccer-build:
|
||||
$(MAKE) -C $(MACCERDIR) install PREFIX=$(INTDIR)/host
|
||||
|
||||
maccer-clean:
|
||||
$(MAKE) -C $(MACCERDIR) clean
|
||||
|
||||
# Final binary
|
||||
binary: binary-tidyup
|
||||
ifeq ($(ARCHIVETYPE),zip)
|
||||
rm -f $(TOPDIR)/gbdk-$(VER)-$(TARGETOS).zip
|
||||
cd $(BUILDDIR)/..; zip -9Xrq $(TOPDIR)/gbdk-$(VER)-$(TARGETOS).zip gbdk
|
||||
else
|
||||
rm -f gbdk-$(VER)-$(TARGETOS).tar.xz
|
||||
tar caf gbdk-$(VER)-$(TARGETOS).tar.xz -C $(BUILDDIR)/.. gbdk
|
||||
endif
|
||||
|
||||
binary-tidyup:
|
||||
rm -rf `find $(BUILDDIR) -name CVS`
|
||||
|
||||
# Install
|
||||
install: native-build
|
||||
mkdir -p $(TARGETDIR)
|
||||
cp -r $(BUILDDIR)/* $(TARGETDIR)
|
|
@ -1,6 +0,0 @@
|
|||
/Makefile/1.1/Mon Feb 21 02:04:36 2000//Tgbdk-295
|
||||
D/examples////
|
||||
D/include////
|
||||
D/libc////
|
||||
D/tools////
|
||||
/Makefile.common/1.11.2.1/Sat Jul 22 17:43:15 2000//Tgbdk-295
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
6
gbdk-lib/ChangeLog
Normal file
6
gbdk-lib/ChangeLog
Normal file
|
@ -0,0 +1,6 @@
|
|||
2001-11-03 Michael Hope <michaelh@juju.net.nz>
|
||||
|
||||
* examples/gb/gb-dtmf/gb-dtmf.c (main): Changed printf to %u as the arg was a int.
|
||||
|
||||
* examples/gb/ram_fn.c (print_counter): Made ANSI compliant.
|
||||
|
|
@ -3,6 +3,10 @@ ifndef ASM
|
|||
ASM = asxxxx
|
||||
endif
|
||||
|
||||
ifndef MODEL
|
||||
MODEL = small
|
||||
endif
|
||||
|
||||
ifndef PORTS
|
||||
PORTS = gbz80 z80
|
||||
endif
|
||||
|
@ -26,12 +30,10 @@ endif
|
|||
|
||||
CLEANSPEC = *.o *.cdb *.sym *.lst *~ *.asm
|
||||
|
||||
# Maccer rule
|
||||
%.s: %.ms
|
||||
maccer -o $@ $<
|
||||
|
||||
CFLAGS = -I$(TOPDIR)/include
|
||||
CFLAGS += -m$(PORT)
|
||||
CFLAGS = -I$(TOPDIR)/include --model-$(MODEL)
|
||||
CFLAGS += -m$(PORT) -DGBDK=1
|
||||
CC = $(SCC)
|
||||
BUILD = $(TOPDIR)/build/$(ASM)/$(THIS)
|
||||
BUILD = $(TOPDIR)/build/$(MODEL)/$(ASM)/$(THIS)
|
||||
LIB = $(BUILD)/$(THIS).lib
|
||||
|
||||
OBJ = $(CSRC:%.c=$(BUILD)/%.o) $(ASSRC:%.s=$(BUILD)/%.o)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
D/gb////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,25 +0,0 @@
|
|||
/Makefile/1.11/Wed Apr 19 02:56:04 2000//Tgbdk-295
|
||||
/Makefile.rgbds/1.2/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/bank_0.c/1.2/Thu Apr 6 04:13:52 2000//Tgbdk-295
|
||||
/bank_1.c/1.3/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/bank_2.c/1.3/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/bank_3.c/1.3/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/banks.c/1.3/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/comm.c/1.3/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/filltest.c/1.2/Wed Jul 12 02:17:55 2000//Tgbdk-295
|
||||
/fonts.c/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
/fprpn.c/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
/galaxy.c/1.5/Thu Jul 20 05:44:54 2000//Tgbdk-295
|
||||
/irq.c/1.2/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/paint.c/1.3/Sun Feb 27 22:54:33 2000//Tgbdk-295
|
||||
/ram_fn.c/1.3/Thu Jul 20 05:44:54 2000//Tgbdk-295
|
||||
/rand.c/1.3/Wed Apr 19 02:56:04 2000//Tgbdk-295
|
||||
/rpn.c/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
/samptest.c/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
/sound.c/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
/space.s/1.1/Wed Feb 23 02:49:17 2000//Tgbdk-295
|
||||
D/colorbar////
|
||||
D/dscan////
|
||||
D/gb-dtmf////
|
||||
D/tests////
|
||||
D/banked////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../bin/lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG
|
||||
CC = ../../bin/lcc -Wa-l -Wl-m -Wl-j
|
||||
|
||||
BINS = galaxy.gb \
|
||||
space.gb \
|
||||
|
@ -19,7 +19,8 @@ OTHER = sound.gb \
|
|||
all: $(BINS)
|
||||
|
||||
make.bat: Makefile
|
||||
make -sn | sed y/\\//\\\\/ | grep -v make > make.bat
|
||||
echo "REM Automatically generated from Makefile" > make.bat
|
||||
make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $<
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
/Makefile/1.1.2.1/Sat Jul 22 17:57:58 2000//Tgbdk-295
|
||||
/bank.h/1.1.2.1/Sat Jul 22 17:57:58 2000//Tgbdk-295
|
||||
/bank2.c/1.1.2.1/Sat Jul 22 17:57:58 2000//Tgbdk-295
|
||||
/bank3.c/1.1.2.1/Sat Jul 22 17:57:58 2000//Tgbdk-295
|
||||
/main.c/1.1.2.1/Sat Jul 22 17:57:58 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/banked
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -2,7 +2,7 @@ SRC = main.c bank2.c bank3.c
|
|||
BIN = banked.gb
|
||||
|
||||
TOPDIR = ../../..
|
||||
GBLIB = $(TOPDIR)/lib/rgbds
|
||||
GBLIB = $(TOPDIR)/lib/medium/rgbds
|
||||
|
||||
LIB = $(GBLIB)/gbz80/gbz80.lib $(GBLIB)/gb/gb.lib
|
||||
CRT0 = $(GBLIB)/gb/crt0.o
|
||||
|
|
|
@ -30,6 +30,8 @@ void main(void)
|
|||
puts("Program Start...");
|
||||
|
||||
ENABLE_RAM_MBC1;
|
||||
SWITCH_4_32_MODE_MBC1;
|
||||
|
||||
var_internal = 1;
|
||||
SWITCH_RAM_MBC1(0);
|
||||
var_0 = 2;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/Makefile/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bar_c.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bar_c.gbr/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bar_c.h/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bar_m.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bar_m.gbm/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bar_m.h/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/colorbar.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/make.bat/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/colorbar
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../../bin/lcc -Wa-l -Wl-m -v
|
||||
CC = ../../../bin/lcc -Wa-l -Wl-m
|
||||
|
||||
CFLAGS = -DGBDK_2_COMPAT
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
/Makefile/1.4/Wed Apr 19 02:56:04 2000//Tgbdk-295
|
||||
/bkg.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bkg.gbr/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bkg.h/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bkg_c.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bkg_c.gbm/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/bkg_m.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/bkg_m.gbm/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/fore.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/fore.gbr/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/fore.h/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/make.bat/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/dscan.c/1.4.2.1/Sat Jul 22 18:35:31 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/dscan
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../../bin/lcc -Wa-l -Wl-m -DUSE_SFR_FOR_REG
|
||||
CC = ../../../bin/lcc -Wa-l -Wl-m
|
||||
|
||||
BINS = dscan.gb
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ void player()
|
|||
/* bombs */
|
||||
void bombs()
|
||||
{
|
||||
volatile UBYTE i;
|
||||
UBYTE i;
|
||||
|
||||
for( i=0; i<MAX_TT; i++ ) {
|
||||
if( tf[i] != 0 ) {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/Makefile/1.3/Thu Mar 9 04:49:04 2000//Tgbdk-295
|
||||
/brk_btn.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/brk_btn.gbr/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/cursor.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/cursor.gbr/1.1/Wed Feb 23 02:50:14 2000//Tgbdk-295
|
||||
/dtmf_lcd.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/dtmf_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
/frm_lcd.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/frm_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
/gb-dtmf.c/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/key_num.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/key_num.gbr/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
/make.bat/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
/prs_btn.c/1.2/Sun Mar 5 22:11:32 2000//Tgbdk-295
|
||||
/prs_btn.gbr/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/gb-dtmf
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -374,7 +374,7 @@ void clr_disp()
|
|||
/*
|
||||
CAUTION: Don't display the NULL code
|
||||
*/
|
||||
void disp(char str[MAX_DTMF])
|
||||
void disp(const char *str)
|
||||
{
|
||||
UBYTE no, left_pos;
|
||||
UBYTE i, start_ch, end_ch;
|
||||
|
@ -607,7 +607,7 @@ void main()
|
|||
/* decremental button */
|
||||
/* appear the delay during press A button */
|
||||
if(i == 5 && (j == 1 || j == 2) && !non_flick){
|
||||
sprintf(str_ms, "%lu MS", on_time);
|
||||
sprintf(str_ms, "%u MS", on_time);
|
||||
disp(str_ms);
|
||||
non_flick = ON;
|
||||
}
|
||||
|
|
|
@ -4,25 +4,30 @@
|
|||
|
||||
UWORD counter;
|
||||
|
||||
void inc()
|
||||
void inc(void)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
||||
void print_counter()
|
||||
void print_counter(void)
|
||||
{
|
||||
printf(" Counter is %u\n", counter);
|
||||
}
|
||||
|
||||
void main()
|
||||
typedef void (*FUNPTR)(void);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
extern UBYTE __inc_end, __inc_start;
|
||||
/* Declare extern functions */
|
||||
void inc_ram() NONBANKED;
|
||||
void inc_hiram() NONBANKED;
|
||||
/* Declare pointer-to-function variables */
|
||||
void (*inc_ram_var)(void) NONBANKED = 0xD000;
|
||||
void (*inc_hiram_var)(void) NONBANKED = 0xFFA0;
|
||||
/* With sdcc 2.3.1, you cannot cast a constant to a function pointer
|
||||
without going through a typedef.
|
||||
*/
|
||||
FUNPTR inc_ram_var = (FUNPTR)0xD000;
|
||||
FUNPTR inc_hiram_var = (FUNPTR)0xFFA0;
|
||||
|
||||
puts("Program Start...");
|
||||
counter = 0;
|
||||
|
|
|
@ -18,16 +18,10 @@
|
|||
UBYTE accu[80];
|
||||
UBYTE accua[80];
|
||||
|
||||
UWORD seed;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
UBYTE r, s, t, u;
|
||||
|
||||
for(r = 0; r != 80; r++) {
|
||||
accu[r] = 0;
|
||||
accua[r] = 0;
|
||||
}
|
||||
UBYTE r, s, t = 0, u = 0;
|
||||
UWORD seed;
|
||||
|
||||
/* We use the DIV register to get a random initial seed */
|
||||
puts("Getting seed");
|
||||
|
|
|
@ -20,7 +20,7 @@ void push(WORD l)
|
|||
puts("Stack full");
|
||||
}
|
||||
|
||||
WORD pop()
|
||||
WORD pop(void)
|
||||
{
|
||||
if(sp > 0)
|
||||
return stack[--sp];
|
||||
|
@ -29,7 +29,7 @@ WORD pop()
|
|||
return 0;
|
||||
}
|
||||
|
||||
WORD top()
|
||||
WORD top(void)
|
||||
{
|
||||
if(sp > 0)
|
||||
return stack[sp-1];
|
||||
|
@ -38,7 +38,7 @@ WORD top()
|
|||
return 0;
|
||||
}
|
||||
|
||||
BYTE read_op()
|
||||
BYTE read_op(void)
|
||||
{
|
||||
if(pos == 0) {
|
||||
gets(s);
|
||||
|
@ -62,7 +62,7 @@ BYTE read_op()
|
|||
return NUMBER;
|
||||
}
|
||||
|
||||
void main()
|
||||
void main(void)
|
||||
{
|
||||
BYTE type;
|
||||
WORD op2;
|
||||
|
@ -71,7 +71,7 @@ void main()
|
|||
sp = 0;
|
||||
pos = 0;
|
||||
|
||||
while((type = read_op(s)) != 0) {
|
||||
while((type = read_op()) != 0) {
|
||||
switch(type) {
|
||||
case NUMBER:
|
||||
push(n);
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
/stress.c/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
/test-memset.c/1.1/Wed Feb 23 02:50:15 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/tests
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,4 +0,0 @@
|
|||
PROJECT_NAME = "gbdk-lib"
|
||||
OUTPUT_DIRECTORY = "../doc/libc"
|
||||
RECURSIVE = yes
|
||||
INPUT = .
|
|
@ -1,14 +0,0 @@
|
|||
/Makefile/1.1/Mon May 8 03:13:10 2000//Tgbdk-295
|
||||
/ctype.h/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/gbdk-lib.h/1.2/Sun May 7 19:32:59 2000//Tgbdk-295
|
||||
/rand.h/1.5/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/stdarg.h/1.1/Mon Feb 21 02:04:36 2000//Tgbdk-295
|
||||
/stdio.h/1.7/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/stdlib.h/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/string.h/1.5/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/time.h/1.5/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/types.h/1.5/Sun May 7 19:32:59 2000//Tgbdk-295
|
||||
D/asm////
|
||||
D/consolez80////
|
||||
D/gb////
|
||||
/libc.dox/1.1.4.1/Sat Jul 22 17:59:31 2000//Tgbdk-295
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,3 +0,0 @@
|
|||
/types.h/1.7/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
D/gbz80////
|
||||
D/z80////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,4 +0,0 @@
|
|||
/provides.h/1.1/Mon Feb 21 02:04:36 2000//Tgbdk-295
|
||||
/stdarg.h/1.4/Wed Apr 5 03:45:18 2000//Tgbdk-295
|
||||
/types.h/1.6/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm/gbz80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,3 +1,4 @@
|
|||
#undef USE_C_MEMCPY
|
||||
#undef USE_C_STRCPY
|
||||
#undef USE_C_STRCMP
|
||||
#define USE_C_MEMCPY 1
|
||||
#define USE_C_STRCPY 1
|
||||
#define USE_C_STRCMP 1
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
the correct order.
|
||||
*/
|
||||
|
||||
typedef char * va_list;
|
||||
#define va_start(list, last) list = (char *)&last + sizeof(last)
|
||||
typedef unsigned char * va_list;
|
||||
#define va_start(list, last) list = (unsigned char *)&last + sizeof(last)
|
||||
#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type)))
|
||||
|
||||
#define va_end(list)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#endif
|
||||
|
||||
#define NONBANKED nonbanked
|
||||
#define BANKED banked
|
||||
|
||||
/** Signed eight bit.
|
||||
*/
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
/provides.h/1.1/Mon Feb 21 02:04:36 2000//Tgbdk-295
|
||||
/stdarg.h/1.2/Wed Feb 23 02:45:18 2000//Tgbdk-295
|
||||
/types.h/1.3/Mon Feb 21 19:12:00 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm/z80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -1,2 +0,0 @@
|
|||
/README/1.1.1.1/Mon Feb 21 00:46:01 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/consolez80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -7,24 +7,24 @@
|
|||
#include <types.h>
|
||||
|
||||
BOOLEAN
|
||||
isalpha(char c) BANKED;
|
||||
isalpha(char c);
|
||||
|
||||
BOOLEAN
|
||||
isupper(char c) BANKED;
|
||||
isupper(char c);
|
||||
|
||||
BOOLEAN
|
||||
islower(char c) BANKED;
|
||||
islower(char c);
|
||||
|
||||
BOOLEAN
|
||||
isdigit(char c) BANKED;
|
||||
isdigit(char c);
|
||||
|
||||
BOOLEAN
|
||||
isspace(char c) BANKED;
|
||||
isspace(char c);
|
||||
|
||||
char
|
||||
toupper(char c) BANKED;
|
||||
toupper(char c);
|
||||
|
||||
char
|
||||
tolower(char c) BANKED;
|
||||
tolower(char c);
|
||||
|
||||
#endif /* _CTYPE_H */
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/cgb.h/1.6/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/console.h/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/drawing.h/1.5/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/font.h/1.5/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/gb.dox/1.1/Fri Apr 28 04:47:42 2000//Tgbdk-295
|
||||
/gb.h/1.9/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/hardware.h/1.4/Fri Apr 28 04:47:42 2000//Tgbdk-295
|
||||
/malloc.h/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/sample.h/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/sgb.h/1.4/Wed Jul 12 02:18:21 2000//Tgbdk-295
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/gb
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -34,7 +34,6 @@
|
|||
#define RGB_ORANGE RGB(30, 20, 0)
|
||||
#define RGB_TEAL RGB(15, 15, 0)
|
||||
|
||||
|
||||
/** Set bkg palette(s).
|
||||
*/
|
||||
void
|
||||
|
@ -54,31 +53,31 @@ set_sprite_palette(UINT8 first_palette,
|
|||
void
|
||||
set_bkg_palette_entry(UINT8 palette,
|
||||
UINT8 entry,
|
||||
UINT16 rgb_data) BANKED;
|
||||
UINT16 rgb_data);
|
||||
|
||||
/** Set a sprite palette entry.
|
||||
*/
|
||||
void
|
||||
set_sprite_palette_entry(UINT8 palette,
|
||||
UINT8 entry,
|
||||
UINT16 rgb_data) BANKED;
|
||||
UINT16 rgb_data);
|
||||
|
||||
/** Set CPU speed to slow operation.
|
||||
Make sure interrupts are disabled before call.
|
||||
|
||||
@see cpu_fast
|
||||
*/
|
||||
void cpu_slow(void) BANKED;
|
||||
void cpu_slow(void);
|
||||
|
||||
/** Set CPU speed to fast operation.
|
||||
Make sure interrupts are disabled before call.
|
||||
|
||||
@see cpu_slow
|
||||
*/
|
||||
void cpu_fast(void) BANKED;
|
||||
void cpu_fast(void);
|
||||
|
||||
/** Set defaults compatible with normal GameBoy.
|
||||
*/
|
||||
void cgb_compatibility(void) BANKED;
|
||||
void cgb_compatibility(void);
|
||||
|
||||
#endif /* _CGB_H */
|
||||
|
|
|
@ -11,23 +11,23 @@
|
|||
*/
|
||||
void
|
||||
gotoxy(UINT8 x,
|
||||
UINT8 y) BANKED;
|
||||
UINT8 y);
|
||||
|
||||
/** Get the current X position of the cursor.
|
||||
*/
|
||||
UINT8
|
||||
posx(void) BANKED;
|
||||
posx(void);
|
||||
|
||||
/** Get the current Y position of the cursor.
|
||||
*/
|
||||
UINT8
|
||||
posy(void) BANKED;
|
||||
posy(void);
|
||||
|
||||
/** Writes out a single character at the current cursor
|
||||
position.
|
||||
Does not update the cursor or interpret the character.
|
||||
*/
|
||||
void
|
||||
setchar(char c) BANKED;
|
||||
setchar(char c);
|
||||
|
||||
#endif /* _CONSOLE_H */
|
||||
|
|
|
@ -52,11 +52,11 @@ void
|
|||
be set to SIGNED or UNSIGNED depending on whether the number is signed
|
||||
or not */
|
||||
void
|
||||
gprintln(INT16 number, INT8 radix, INT8 signed_value) BANKED;
|
||||
gprintln(INT16 number, INT8 radix, INT8 signed_value);
|
||||
|
||||
/** Print the number 'number' as in 'gprintln' */
|
||||
void
|
||||
gprintn(INT8 number, INT8 radix, INT8 signed_value) BANKED;
|
||||
gprintn(INT8 number, INT8 radix, INT8 signed_value);
|
||||
|
||||
/** Print the formatted string 'fmt' with arguments '...' */
|
||||
INT8
|
||||
|
@ -64,11 +64,11 @@ INT8
|
|||
|
||||
/** Old style plot - try plot_point() */
|
||||
void
|
||||
plot(UINT8 x, UINT8 y, UINT8 colour, UINT8 mode) BANKED;
|
||||
plot(UINT8 x, UINT8 y, UINT8 colour, UINT8 mode);
|
||||
|
||||
/** Plot a point in the current drawing mode and colour at (x,y) */
|
||||
void
|
||||
plot_point(UINT8 x, UINT8 y) BANKED;
|
||||
plot_point(UINT8 x, UINT8 y);
|
||||
|
||||
/** I (MLH) have no idea what switch_data does... */
|
||||
void
|
||||
|
@ -80,33 +80,33 @@ void
|
|||
|
||||
/** Draw a line in the current drawing mode and colour from (x1,y1) to (x2,y2) */
|
||||
void
|
||||
line(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2) BANKED;
|
||||
line(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2);
|
||||
|
||||
/** Draw a box (rectangle) with corners (x1,y1) and (x2,y2) using fill mode
|
||||
'style' (one of NOFILL or FILL */
|
||||
void
|
||||
box(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2, UINT8 style) BANKED;
|
||||
box(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2, UINT8 style);
|
||||
|
||||
/** Draw a circle with centre at (x,y) and radius 'radius'. 'style' sets
|
||||
the fill mode */
|
||||
void
|
||||
circle(UINT8 x, UINT8 y, UINT8 radius, UINT8 style) BANKED;
|
||||
circle(UINT8 x, UINT8 y, UINT8 radius, UINT8 style);
|
||||
|
||||
/** Returns the current colour of the pixel at (x,y) */
|
||||
UINT8
|
||||
getpix(UINT8 x, UINT8 y) BANKED;
|
||||
getpix(UINT8 x, UINT8 y);
|
||||
|
||||
/** Prints the character 'chr' in the default font at the current position */
|
||||
void
|
||||
wrtchr(char chr) BANKED;
|
||||
wrtchr(char chr);
|
||||
|
||||
/** Sets the current text position to (x,y). Note that x and y have units
|
||||
of cells (8 pixels) */
|
||||
void
|
||||
gotogxy(UINT8 x, UINT8 y) BANKED;
|
||||
gotogxy(UINT8 x, UINT8 y);
|
||||
|
||||
/** Set the current foreground colour (for pixels), background colour, and
|
||||
draw mode */
|
||||
void color(UINT8 forecolor, UINT8 backcolor, UINT8 mode) BANKED;
|
||||
void color(UINT8 forecolor, UINT8 backcolor, UINT8 mode);
|
||||
|
||||
#endif /* __DRAWING_H */
|
||||
|
|
|
@ -207,11 +207,11 @@ extern UINT16 sys_time;
|
|||
|
||||
/** Send byte in _io_out to the serial port */
|
||||
void
|
||||
send_byte(void) BANKED;
|
||||
send_byte(void);
|
||||
|
||||
/** Receive byte from the serial port in _io_in */
|
||||
void
|
||||
receive_byte(void) BANKED;
|
||||
receive_byte(void);
|
||||
|
||||
/** An OR of IO_* */
|
||||
extern UINT8 _io_status;
|
||||
|
@ -258,6 +258,12 @@ extern UINT8 _io_out;
|
|||
#define DISABLE_RAM_MBC1 \
|
||||
*(unsigned char *)0x0000 = 0x00
|
||||
|
||||
#define SWITCH_16_8_MODE_MBC1 \
|
||||
*(unsigned char *)0x6000 = 0x00
|
||||
|
||||
#define SWITCH_4_32_MODE_MBC1 \
|
||||
*(unsigned char *)0x6000 = 0x01
|
||||
|
||||
/* Note the order used here. Writing the other way around
|
||||
* on a MBC1 always selects bank 0 (d'oh)
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <types.h>
|
||||
|
||||
#if USE_SFR_FOR_REG
|
||||
#error SFR is unteseted and disabled in 2.96
|
||||
|
||||
#define __REG extern volatile sfr UINT8
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
|
||||
/** Return a non-null value if running on Super GameBoy */
|
||||
UINT8
|
||||
sgb_check(void) BANKED;
|
||||
sgb_check(void);
|
||||
|
||||
#endif /* _SGB_H */
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
PROJECT_NAME = "gbdk-lib"
|
||||
OUTPUT_DIRECTORY = "../doc/libc"
|
||||
RECURSIVE = yes
|
||||
INPUT = .
|
|
@ -18,12 +18,12 @@ initrand(UINT16 seed) NONBANKED; /* Non-banked as called from asm in arand.s */
|
|||
/** Returns a random value.
|
||||
*/
|
||||
INT8
|
||||
rand(void) BANKED;
|
||||
rand(void);
|
||||
|
||||
/** Returns a random word.
|
||||
*/
|
||||
UINT16
|
||||
randw(void) BANKED;
|
||||
randw(void);
|
||||
|
||||
/** Random generator using the linear lagged additive method
|
||||
Note that 'initarand()' calls 'initrand()' with the same seed value, and
|
||||
|
@ -32,11 +32,11 @@ randw(void) BANKED;
|
|||
@author Luc Van den Borre
|
||||
*/
|
||||
void
|
||||
initarand(UINT16 seed) BANKED;
|
||||
initarand(UINT16 seed);
|
||||
|
||||
/** Generates a random number using the linear lagged additive method.
|
||||
*/
|
||||
INT8
|
||||
arand(void) BANKED;
|
||||
arand(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <types.h>
|
||||
|
||||
#if STRICT_ANSI
|
||||
void putchar(int c) BANKED;
|
||||
void putchar(int c);
|
||||
#else
|
||||
/** Put the character 'c' to stdout. */
|
||||
void putchar(char c) BANKED;
|
||||
void putchar(char c);
|
||||
#endif
|
||||
|
||||
/** Print the string and arguments given by format to stdout.
|
||||
|
@ -39,10 +39,10 @@ void puts(const char *s) NONBANKED;
|
|||
either a terminating newline or EOF, which it replaces with '\0'. No
|
||||
check for buffer overrun is per formed.
|
||||
*/
|
||||
char *gets(char *s) BANKED;
|
||||
char *gets(char *s);
|
||||
|
||||
/** getchar() gets a single character from stdin.
|
||||
*/
|
||||
char getchar(void) BANKED;
|
||||
char getchar(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,32 +15,30 @@ void exit(int status) NONBANKED;
|
|||
#if 0
|
||||
/** Compatibility function. Not implemented.
|
||||
*/
|
||||
int getkey(void) BANKED;
|
||||
int getkey(void);
|
||||
#endif
|
||||
|
||||
/** Returns the absolute value of a int.
|
||||
If i is negative, returns -i; else returns i.
|
||||
*/
|
||||
int abs(int i) BANKED;
|
||||
int abs(int i);
|
||||
/** Returns the absolute value of a long.
|
||||
*/
|
||||
long labs(long num) BANKED;
|
||||
long labs(long num);
|
||||
/** Converts an ASCII string to an int.
|
||||
The string may be of the format [\s]*[+-][\d]+[\D]* i.e. any number
|
||||
of spaces, an optional + or -, then an arbitrary number of digits.
|
||||
The result is undefined if the number doesnt fit in an int.
|
||||
*/
|
||||
int atoi(const char *s) NONBANKED;
|
||||
int atoi(const char *s);
|
||||
/** Converts an ASCII string to a long.
|
||||
*/
|
||||
long atol(const char *s) NONBANKED;
|
||||
long atol(const char *s);
|
||||
/** Converts an int into a base 10 ASCII string.
|
||||
Banked as it assumes that the destination is in non-banked RAM.
|
||||
*/
|
||||
char *itoa(int n, char *s) BANKED;
|
||||
char *itoa(int n, char *s);
|
||||
/** Converts a long into a base 10 ASCII string.
|
||||
Banked as it assumes that the destination is in non-banked RAM.
|
||||
*/
|
||||
char *ltoa(long n, char *s) BANKED;
|
||||
char *ltoa(long n, char *s);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ void *memcpy(void *dest, const void *src, size_t len) NONBANKED;
|
|||
For example 'abcdefg' will become 'gfedcba'. Banked as the string
|
||||
must be modifiable.
|
||||
*/
|
||||
char *reverse(char *s) BANKED;
|
||||
char *reverse(char *s);
|
||||
|
||||
char *strcat(char *s1, const char *s2) NONBANKED;
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@ typedef UINT16 time_t;
|
|||
*/
|
||||
clock_t clock(void) NONBANKED;
|
||||
|
||||
time_t time(time_t *t) BANKED;
|
||||
time_t time(time_t *t);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/Makefile/1.9/Fri Jul 21 02:26:54 2000//Tgbdk-295
|
||||
/Makefile.platform/1.3/Wed Jul 12 02:18:21 2000//Tgbdk-295
|
||||
/abs.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/atoi.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/atol.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/calloc.c/1.2/Wed Apr 5 03:45:18 2000//Tgbdk-295
|
||||
/free.c/1.2/Wed Apr 5 03:45:18 2000//Tgbdk-295
|
||||
/isalpha.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/isdigit.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/islower.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/isspace.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/isupper.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/itoa.c/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/labs.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/ltoa.c/1.4/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/malloc.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/printf.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/puts.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/realloc.c/1.2/Wed Apr 5 03:45:18 2000//Tgbdk-295
|
||||
/reverse.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/scanf.c/1.2/Wed Apr 5 03:45:18 2000//Tgbdk-295
|
||||
/strcat.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/string.c/1.2/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/strlen.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/strncat.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/strncmp.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/strncpy.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/time.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/tolower.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
/toupper.c/1.3/Thu Jul 20 04:19:30 2000//Tgbdk-295
|
||||
D/asm////
|
||||
D/consolez80////
|
||||
D/gb////
|
||||
D/rrgb////
|
||||
/Makefile.rules/1.4.2.2/Sat Jul 22 17:59:14 2000//Tgbdk-295
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/libc
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1 +0,0 @@
|
|||
Tgbdk-295
|
|
@ -4,21 +4,22 @@
|
|||
|
||||
TOPDIR = ..
|
||||
|
||||
include $(TOPDIR)/Makefile.common
|
||||
CSRC = abs.c atoi.c atol.c isalpha.c isdigit.c \
|
||||
islower.c isspace.c isupper.c itoa.c labs.c \
|
||||
printf.c puts.c reverse.c scanf.c strcat.c string.c \
|
||||
strlen.c strncat.c strncmp.c strncpy.c time.c \
|
||||
tolower.c toupper.c \
|
||||
_modulong.c _modslong.c _divulong.c _divslong.c _mullong.c
|
||||
# free.c malloc.c realloc.c calloc.c ltoa.c
|
||||
|
||||
OBJ = abs.o atoi.o atol.o isalpha.o isdigit.o \
|
||||
islower.o isspace.o isupper.o itoa.o labs.o ltoa.o \
|
||||
printf.o puts.o reverse.o scanf.o strcat.o string.o \
|
||||
strlen.o strncat.o strncmp.o strncpy.o time.o \
|
||||
tolower.o toupper.o
|
||||
# free.o malloc.o realloc.o calloc.o
|
||||
include $(TOPDIR)/Makefile.common
|
||||
|
||||
all: ports platforms
|
||||
|
||||
clean: port-clean ports-clean platform-clean
|
||||
|
||||
ports:
|
||||
for i in $(PORTS); do make port THIS=$$i; done
|
||||
for i in $(PORTS); do make port THIS=$$i PORT=$$i; done
|
||||
|
||||
platforms:
|
||||
for i in $(PLATFORMS); do make -C $$i platform THIS=$$i; done
|
||||
|
|
|
@ -1,53 +1,23 @@
|
|||
ifndef PORT
|
||||
PORT = gbz80
|
||||
endif
|
||||
|
||||
ifeq ($(ASM),rgbds)
|
||||
CFLAGS += --asm=rgbds
|
||||
# Override the default rule
|
||||
%.o: %.s
|
||||
|
||||
$(LIB): pre $(OBJ) $(CRT0)
|
||||
mkdir -p $(BUILD)
|
||||
ifneq ($(LIB_APPEND), 1)
|
||||
rm -f $(LIB)
|
||||
endif
|
||||
xlib $(LIB) a $(OBJ)
|
||||
ifdef CRT0
|
||||
cp -f $(CRT0) $(BUILD)
|
||||
endif
|
||||
|
||||
pre:
|
||||
-astorgb.pl global.s > global.asm
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
%.asm: %.s
|
||||
astorgb.pl $< > $@
|
||||
|
||||
%.o: %.rasm
|
||||
rgbasm -o$@ $<
|
||||
|
||||
%.o: %.asm
|
||||
rgbasm -o$@ $<
|
||||
# Maccer rule
|
||||
%.s: %.ms
|
||||
maccer -o $@ $<
|
||||
|
||||
ifeq ($(MODEL),small)
|
||||
NEAR_CALLS = 1
|
||||
else
|
||||
$(LIB): $(OBJ) $(CRT0) dummy
|
||||
mkdir -p $(BUILD)
|
||||
cp -f $(OBJ) $(BUILD)
|
||||
ifneq ($(LIB_APPEND), 1)
|
||||
ls $(OBJ) > $(LIB)
|
||||
else
|
||||
ls $(OBJ) >> $(LIB)
|
||||
endif
|
||||
ifdef CRT0
|
||||
cp -f $(CRT0) $(BUILD)
|
||||
NEAR_CALLS = 0
|
||||
endif
|
||||
|
||||
endif
|
||||
include $(TOPDIR)/libc/rules-$(ASM).mk
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(CLEANSPEC)
|
||||
|
||||
dummy:
|
||||
set-model:
|
||||
if [ -e global.s ]; then \
|
||||
sed -e "s/.NEAR_CALLS\W=\W[0-9]\+/.NEAR_CALLS = $(NEAR_CALLS)/" global.s > tmp1.txt ;\
|
||||
mv tmp1.txt global.s; \
|
||||
fi
|
||||
|
||||
build-dir:
|
||||
mkdir -p $(BUILD)
|
||||
|
|
264
gbdk-lib/libc/_divslong.c
Normal file
264
gbdk-lib/libc/_divslong.c
Normal file
|
@ -0,0 +1,264 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
_divslong.c - routine for division of 32 bit long
|
||||
|
||||
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
In other words, you are welcome to use, share and improve this program.
|
||||
You are forbidden to forbid anyone else to use, share and improve
|
||||
what you give them. Help stamp out software-hoarding!
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef GBDK
|
||||
#include <sdcc-lib.h>
|
||||
#endif
|
||||
|
||||
#if _SDCC_MANGLES_SUPPORT_FUNS || GBDK
|
||||
unsigned long _divulong (unsigned long a, unsigned long b);
|
||||
#endif
|
||||
|
||||
/* Assembler-functions are provided for:
|
||||
mcs51 small
|
||||
mcs51 small stack-auto
|
||||
*/
|
||||
|
||||
#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
|
||||
# if defined(SDCC_mcs51)
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# if defined(SDCC_STACK_AUTO)
|
||||
# define _DIVSLONG_ASM_SMALL_AUTO
|
||||
# else
|
||||
# define _DIVSLONG_ASM_SMALL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _DIVSLONG_ASM_SMALL
|
||||
|
||||
static void
|
||||
_divslong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r3
|
||||
|
||||
.globl __divslong
|
||||
|
||||
// _divslong_PARM_2 shares the same memory with _divulong_PARM_2
|
||||
// and is defined in _divulong.c
|
||||
#define b0 (__divslong_PARM_2)
|
||||
#define b1 (__divslong_PARM_2 + 1)
|
||||
#define b2 (__divslong_PARM_2 + 2)
|
||||
#define b3 (__divslong_PARM_2 + 3)
|
||||
|
||||
__divslong:
|
||||
; a3 in acc
|
||||
; b3 in (__divslong_PARM_2 + 3)
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr F0 ; Flag 0 in PSW
|
||||
; available to user for general purpose
|
||||
jnb acc.7,a_not_negative
|
||||
|
||||
setb F0
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
a_not_negative:
|
||||
|
||||
mov a,b3
|
||||
jnb acc.7,b_not_negative
|
||||
|
||||
cpl F0
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,b0
|
||||
mov b0,a
|
||||
clr a
|
||||
subb a,b1
|
||||
mov b1,a
|
||||
clr a
|
||||
subb a,b2
|
||||
mov b2,a
|
||||
clr a
|
||||
subb a,b3
|
||||
mov b3,a
|
||||
|
||||
b_not_negative:
|
||||
|
||||
mov a,a3 ; restore a3 in acc
|
||||
|
||||
lcall __divulong
|
||||
|
||||
jnb F0,not_negative
|
||||
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
not_negative:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#elif defined _DIVSLONG_ASM_SMALL_AUTO
|
||||
|
||||
static void
|
||||
_divslong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r3
|
||||
|
||||
.globl __divslong
|
||||
|
||||
__divslong:
|
||||
|
||||
; a3 in acc
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr F0 ; Flag 0 in PSW
|
||||
; available to user for general purpose
|
||||
jnb acc.7,a_not_negative
|
||||
|
||||
setb F0
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
a_not_negative:
|
||||
|
||||
mov a,sp
|
||||
add a,#-2 ; 2 bytes return address
|
||||
mov r0,a ; r0 points to b3
|
||||
mov a,@r0 ; b3
|
||||
|
||||
jnb acc.7,b_not_negative
|
||||
|
||||
cpl F0
|
||||
|
||||
dec r0
|
||||
dec r0
|
||||
dec r0
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,@r0 ; b0
|
||||
mov @r0,a
|
||||
clr a
|
||||
inc r0
|
||||
subb a,@r0 ; b1
|
||||
mov @r0,a
|
||||
clr a
|
||||
inc r0
|
||||
subb a,@r0 ; b2
|
||||
mov @r0,a
|
||||
clr a
|
||||
inc r0
|
||||
subb a,@r0 ; b3
|
||||
mov @r0,a
|
||||
|
||||
b_not_negative:
|
||||
dec r0
|
||||
dec r0
|
||||
dec r0 ; r0 points to b0
|
||||
|
||||
lcall __divlong
|
||||
|
||||
jnb F0,not_negative
|
||||
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
not_negative:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#else // _DIVSLONG_ASM
|
||||
|
||||
long
|
||||
_divslong (long a, long b)
|
||||
{
|
||||
long r;
|
||||
|
||||
r = _divulong((a < 0 ? -a : a),
|
||||
(b < 0 ? -b : b));
|
||||
if ( (a < 0) ^ (b < 0))
|
||||
return -r;
|
||||
else
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif // _DIVSLONG_ASM
|
351
gbdk-lib/libc/_divulong.c
Normal file
351
gbdk-lib/libc/_divulong.c
Normal file
|
@ -0,0 +1,351 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
_divulong.c - routine for division of 32 bit unsigned long
|
||||
|
||||
Ecrit par - Jean-Louis Vern . jlvern@writeme.com (1999)
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
In other words, you are welcome to use, share and improve this program.
|
||||
You are forbidden to forbid anyone else to use, share and improve
|
||||
what you give them. Help stamp out software-hoarding!
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
/* Assembler-functions are provided for:
|
||||
mcs51 small
|
||||
mcs51 small stack-auto
|
||||
*/
|
||||
|
||||
#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
|
||||
# if defined(SDCC_mcs51)
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# if defined(SDCC_STACK_AUTO)
|
||||
# define _DIVULONG_ASM_SMALL_AUTO
|
||||
# else
|
||||
# define _DIVULONG_ASM_SMALL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _DIVULONG_ASM_SMALL
|
||||
|
||||
static void
|
||||
_divlong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
.globl __divulong
|
||||
|
||||
__divulong:
|
||||
|
||||
#define count r2
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r3
|
||||
|
||||
#define reste0 r4
|
||||
#define reste1 r5
|
||||
#define reste2 r6
|
||||
#define reste3 r7
|
||||
|
||||
#if defined(SDCC_NOOVERLAY)
|
||||
.area DSEG (DATA)
|
||||
#else
|
||||
.area OSEG (OVR,DATA)
|
||||
#endif
|
||||
|
||||
.globl __divulong_PARM_2
|
||||
.globl __divslong_PARM_2
|
||||
|
||||
__divulong_PARM_2:
|
||||
__divslong_PARM_2:
|
||||
.ds 4
|
||||
|
||||
.area CSEG (CODE)
|
||||
|
||||
#define b0 (__divulong_PARM_2)
|
||||
#define b1 (__divulong_PARM_2 + 1)
|
||||
#define b2 (__divulong_PARM_2 + 2)
|
||||
#define b3 (__divulong_PARM_2 + 3)
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov a3,a ; save parameter a3
|
||||
|
||||
mov count,#32
|
||||
clr a
|
||||
mov reste0,a
|
||||
mov reste1,a
|
||||
mov reste2,a
|
||||
mov reste3,a
|
||||
|
||||
; optimization loop in lp0 until the first bit is shifted into rest
|
||||
|
||||
lp0: mov a,a0 ; a <<= 1
|
||||
add a,a0
|
||||
mov a0,a
|
||||
mov a,a1
|
||||
rlc a
|
||||
mov a1,a
|
||||
mov a,a2
|
||||
rlc a
|
||||
mov a2,a
|
||||
mov a,a3
|
||||
rlc a
|
||||
mov a3,a
|
||||
|
||||
jc in_lp
|
||||
djnz count,lp0
|
||||
|
||||
sjmp exit
|
||||
|
||||
loop: mov a,a0 ; a <<= 1
|
||||
add a,a0
|
||||
mov a0,a
|
||||
mov a,a1
|
||||
rlc a
|
||||
mov a1,a
|
||||
mov a,a2
|
||||
rlc a
|
||||
mov a2,a
|
||||
mov a,a3
|
||||
rlc a
|
||||
mov a3,a
|
||||
|
||||
in_lp: mov a,reste0 ; reste <<= 1
|
||||
rlc a ; feed in carry
|
||||
mov reste0,a
|
||||
mov a,reste1
|
||||
rlc a
|
||||
mov reste1,a
|
||||
mov a,reste2
|
||||
rlc a
|
||||
mov reste2,a
|
||||
mov a,reste3
|
||||
rlc a
|
||||
mov reste3,a
|
||||
|
||||
mov a,reste0 ; reste - b
|
||||
subb a,b0 ; carry is always clear here, because
|
||||
; reste <<= 1 never overflows
|
||||
mov a,reste1
|
||||
subb a,b1
|
||||
mov a,reste2
|
||||
subb a,b2
|
||||
mov a,reste3
|
||||
subb a,b3
|
||||
|
||||
jc minus ; reste >= b?
|
||||
|
||||
; -> yes; reste -= b;
|
||||
mov a,reste0
|
||||
subb a,b0 ; carry is always clear here (jc)
|
||||
mov reste0,a
|
||||
mov a,reste1
|
||||
subb a,b1
|
||||
mov reste1,a
|
||||
mov a,reste2
|
||||
subb a,b2
|
||||
mov reste2,a
|
||||
mov a,reste3
|
||||
subb a,b3
|
||||
mov reste3,a
|
||||
|
||||
orl a0,#1
|
||||
|
||||
minus: djnz count,loop ; -> no
|
||||
|
||||
exit: mov a,a3 ; prepare the return value
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#elif defined _DIVULONG_ASM_SMALL_AUTO
|
||||
|
||||
static void
|
||||
_divlong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
.globl __divulong
|
||||
|
||||
__divulong:
|
||||
|
||||
#define count r2
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r3
|
||||
|
||||
#define reste0 r4
|
||||
#define reste1 r5
|
||||
#define reste2 r6
|
||||
#define reste3 r7
|
||||
|
||||
.globl __divlong ; entry point for __divslong
|
||||
|
||||
#define b0 r1
|
||||
|
||||
ar0 = 0 ; BUG register set is not considered
|
||||
ar1 = 1
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov a3,a ; save parameter a3
|
||||
|
||||
mov a,sp
|
||||
add a,#-2-3 ; 2 bytes return address, 3 bytes param b
|
||||
mov r0,a ; r0 points to b0
|
||||
|
||||
__divlong: ; entry point for __divslong
|
||||
|
||||
mov ar1,@r0 ; load b0
|
||||
inc r0 ; r0 points to b1
|
||||
|
||||
mov count,#32
|
||||
clr a
|
||||
mov reste0,a
|
||||
mov reste1,a
|
||||
mov reste2,a
|
||||
mov reste3,a
|
||||
|
||||
; optimization loop in lp0 until the first bit is shifted into rest
|
||||
|
||||
lp0: mov a,a0 ; a <<= 1
|
||||
add a,a0
|
||||
mov a0,a
|
||||
mov a,a1
|
||||
rlc a
|
||||
mov a1,a
|
||||
mov a,a2
|
||||
rlc a
|
||||
mov a2,a
|
||||
mov a,a3
|
||||
rlc a
|
||||
mov a3,a
|
||||
|
||||
jc in_lp
|
||||
djnz count,lp0
|
||||
|
||||
sjmp exit
|
||||
|
||||
loop: mov a,a0 ; a <<= 1
|
||||
add a,a0
|
||||
mov a0,a
|
||||
mov a,a1
|
||||
rlc a
|
||||
mov a1,a
|
||||
mov a,a2
|
||||
rlc a
|
||||
mov a2,a
|
||||
mov a,a3
|
||||
rlc a
|
||||
mov a3,a
|
||||
|
||||
in_lp: mov a,reste0 ; reste <<= 1
|
||||
rlc a ; feed in carry
|
||||
mov reste0,a
|
||||
mov a,reste1
|
||||
rlc a
|
||||
mov reste1,a
|
||||
mov a,reste2
|
||||
rlc a
|
||||
mov reste2,a
|
||||
mov a,reste3
|
||||
rlc a
|
||||
mov reste3,a
|
||||
|
||||
mov a,reste0 ; reste - b
|
||||
subb a,b0 ; carry is always clear here, because
|
||||
; reste <<= 1 never overflows
|
||||
mov a,reste1
|
||||
subb a,@r0 ; b1
|
||||
mov a,reste2
|
||||
inc r0
|
||||
subb a,@r0 ; b2
|
||||
mov a,reste3
|
||||
inc r0
|
||||
subb a,@r0 ; b3
|
||||
dec r0
|
||||
dec r0
|
||||
|
||||
jc minus ; reste >= b?
|
||||
|
||||
; -> yes; reste -= b;
|
||||
mov a,reste0
|
||||
subb a,b0 ; carry is always clear here (jc)
|
||||
mov reste0,a
|
||||
mov a,reste1
|
||||
subb a,@r0 ; b1
|
||||
mov reste1,a
|
||||
mov a,reste2
|
||||
inc r0
|
||||
subb a,@r0 ; b2
|
||||
mov reste2,a
|
||||
mov a,reste3
|
||||
inc r0
|
||||
subb a,@r0 ; b3
|
||||
mov reste3,a
|
||||
dec r0
|
||||
dec r0
|
||||
|
||||
orl a0,#1
|
||||
|
||||
minus: djnz count,loop ; -> no
|
||||
|
||||
exit: mov a,a3 ; prepare the return value
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#else // _DIVULONG_ASM
|
||||
|
||||
#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1)
|
||||
|
||||
unsigned long
|
||||
_divulong (unsigned long a, unsigned long b)
|
||||
{
|
||||
unsigned long reste = 0L;
|
||||
unsigned char count = 32;
|
||||
#if defined(SDCC_STACK_AUTO) || defined(SDCC_z80)
|
||||
char c;
|
||||
#else
|
||||
bit c;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
// reste: a <- 0;
|
||||
c = MSB_SET(a);
|
||||
a <<= 1;
|
||||
reste <<= 1;
|
||||
if (c)
|
||||
reste |= 1L;
|
||||
|
||||
if (reste >= b)
|
||||
{
|
||||
reste -= b;
|
||||
// a <- (result = 1)
|
||||
a |= 1L;
|
||||
}
|
||||
}
|
||||
while (--count);
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif // _DIVULONG_ASM
|
269
gbdk-lib/libc/_modslong.c
Normal file
269
gbdk-lib/libc/_modslong.c
Normal file
|
@ -0,0 +1,269 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
_modslong.c - routine for modulus of 32 bit signed long
|
||||
|
||||
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
In other words, you are welcome to use, share and improve this program.
|
||||
You are forbidden to forbid anyone else to use, share and improve
|
||||
what you give them. Help stamp out software-hoarding!
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef GBDK
|
||||
#include <sdcc-lib.h>
|
||||
#endif
|
||||
|
||||
#if _SDCC_MANGLES_SUPPORT_FUNS || GBDK
|
||||
unsigned long _modulong (unsigned long a, unsigned long b);
|
||||
#endif
|
||||
|
||||
/* Assembler-functions are provided for:
|
||||
mcs51 small
|
||||
mcs51 small stack-auto
|
||||
*/
|
||||
|
||||
#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
|
||||
# if defined(SDCC_mcs51)
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# if defined(SDCC_STACK_AUTO)
|
||||
# define _MODSLONG_ASM_SMALL_AUTO
|
||||
# else
|
||||
# define _MODSLONG_ASM_SMALL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _MODSLONG_ASM_SMALL
|
||||
|
||||
static void
|
||||
_modslong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r1
|
||||
|
||||
.globl __modslong
|
||||
|
||||
// _modslong_PARM_2 shares the same memory with _modulong_PARM_2
|
||||
// and is defined in _modulong.c
|
||||
#define b0 (__modslong_PARM_2)
|
||||
#define b1 (__modslong_PARM_2 + 1)
|
||||
#define b2 (__modslong_PARM_2 + 2)
|
||||
#define b3 (__modslong_PARM_2 + 3)
|
||||
|
||||
__modslong:
|
||||
; a3 in acc
|
||||
; b3 in (__modslong_PARM_2 + 3)
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr F0 ; Flag 0 in PSW
|
||||
; available to user for general purpose
|
||||
jnb acc.7,a_not_negative
|
||||
|
||||
setb F0
|
||||
|
||||
clr a ; a = -a;
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
a_not_negative:
|
||||
|
||||
mov a,b3
|
||||
jnb acc.7,b_not_negative
|
||||
|
||||
cpl F0
|
||||
|
||||
clr a ; b = -b;
|
||||
clr c
|
||||
subb a,b0
|
||||
mov b0,a
|
||||
clr a
|
||||
subb a,b1
|
||||
mov b1,a
|
||||
clr a
|
||||
subb a,b2
|
||||
mov b2,a
|
||||
clr a
|
||||
subb a,b3
|
||||
mov b3,a
|
||||
|
||||
b_not_negative:
|
||||
|
||||
mov a,a3 ; restore a3 in acc
|
||||
|
||||
lcall __modulong
|
||||
|
||||
jnb F0,not_negative
|
||||
|
||||
; result in (a == r1), b, dph, dpl
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
; result in a, b, dph, dpl
|
||||
not_negative:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#elif defined _MODSLONG_ASM_SMALL_AUTO
|
||||
|
||||
static void
|
||||
_modslong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r1
|
||||
|
||||
#define b0 r2
|
||||
#define b1 r3
|
||||
#define b2 r4
|
||||
#define b3 r5
|
||||
|
||||
ar2 = 2 ; BUG register set is not considered
|
||||
ar3 = 3
|
||||
ar4 = 4
|
||||
ar5 = 5
|
||||
|
||||
.globl __modslong
|
||||
|
||||
__modslong:
|
||||
|
||||
; a3 in acc
|
||||
mov a3,a ; save a3
|
||||
|
||||
clr F0 ; F0 (Flag 0)
|
||||
; available to user for general purpose
|
||||
jnb acc.7,a_not_negative
|
||||
|
||||
setb F0
|
||||
|
||||
clr a ; a = -a;
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3
|
||||
mov a3,a
|
||||
|
||||
a_not_negative:
|
||||
|
||||
mov a,sp
|
||||
add a,#-2-3 ; 2 bytes return address, 3 bytes param b
|
||||
mov r0,a ; r1 points to b0
|
||||
|
||||
|
||||
mov ar2,@r0 ; load b0
|
||||
inc r0 ; r0 points to b1
|
||||
mov ar3,@r0 ; b1
|
||||
inc r0
|
||||
mov ar4,@r0 ; b2
|
||||
inc r0
|
||||
mov a,@r0 ; b3
|
||||
mov b3,a
|
||||
|
||||
jnb acc.7,b_not_negative
|
||||
|
||||
cpl F0
|
||||
|
||||
clr a ; b = -b;
|
||||
clr c
|
||||
subb a,b0
|
||||
mov b0,a
|
||||
clr a
|
||||
subb a,b1
|
||||
mov b1,a
|
||||
clr a
|
||||
subb a,b2
|
||||
mov b2,a
|
||||
clr a
|
||||
subb a,b3
|
||||
mov b3,a
|
||||
|
||||
b_not_negative:
|
||||
|
||||
lcall __modlong
|
||||
|
||||
jnb F0,not_negative
|
||||
|
||||
; result in (a == r1), b, dph, dpl
|
||||
clr a
|
||||
clr c
|
||||
subb a,a0
|
||||
mov a0,a
|
||||
clr a
|
||||
subb a,a1
|
||||
mov a1,a
|
||||
clr a
|
||||
subb a,a2
|
||||
mov a2,a
|
||||
clr a
|
||||
subb a,a3 ; result in a, b, dph, dpl
|
||||
|
||||
not_negative:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#else // _MODSLONG_ASM
|
||||
|
||||
long
|
||||
_modslong (long a, long b)
|
||||
{
|
||||
long r;
|
||||
|
||||
r = _modulong((a < 0 ? -a : a),
|
||||
(b < 0 ? -b : b));
|
||||
if ( (a < 0) ^ (b < 0))
|
||||
return -r;
|
||||
else
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif // _MODSLONG_ASM
|
360
gbdk-lib/libc/_modulong.c
Normal file
360
gbdk-lib/libc/_modulong.c
Normal file
|
@ -0,0 +1,360 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
_modulong.c - routine for modulus of 32 bit unsigned long
|
||||
|
||||
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
|
||||
|
||||
Bug fixes by Martijn van Balen, aed@iae.nl
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
In other words, you are welcome to use, share and improve this program.
|
||||
You are forbidden to forbid anyone else to use, share and improve
|
||||
what you give them. Help stamp out software-hoarding!
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
/* Assembler-functions are provided for:
|
||||
mcs51 small
|
||||
mcs51 small stack-auto
|
||||
*/
|
||||
|
||||
#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
|
||||
# if defined(SDCC_mcs51)
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# if defined(SDCC_STACK_AUTO)
|
||||
# define _MODULONG_ASM_SMALL_AUTO
|
||||
# else
|
||||
# define _MODULONG_ASM_SMALL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _MODULONG_ASM_SMALL
|
||||
|
||||
static void
|
||||
_modlong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
.globl __modulong
|
||||
|
||||
__modulong:
|
||||
|
||||
#if defined(SDCC_NOOVERLAY)
|
||||
.area DSEG (DATA)
|
||||
#else
|
||||
.area OSEG (OVR,DATA)
|
||||
#endif
|
||||
|
||||
.globl __modulong_PARM_2
|
||||
.globl __modslong_PARM_2
|
||||
|
||||
__modulong_PARM_2:
|
||||
__modslong_PARM_2:
|
||||
.ds 4
|
||||
|
||||
.area CSEG (CODE)
|
||||
|
||||
#define count r0
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r1
|
||||
|
||||
#define b0 (__modulong_PARM_2)
|
||||
#define b1 (__modulong_PARM_2 + 1)
|
||||
#define b2 (__modulong_PARM_2 + 2)
|
||||
#define b3 (__modulong_PARM_2 + 3)
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov a3,a ; save parameter a3
|
||||
|
||||
mov a,b0 ; b == 0? avoid endless loop
|
||||
orl a,b1
|
||||
orl a,b2
|
||||
orl a,b3
|
||||
jz div_by_0
|
||||
|
||||
mov count,#0
|
||||
clr c ; when loop1 jumps immediately to loop2
|
||||
|
||||
loop1: inc count
|
||||
|
||||
mov a,b3 ; if (!MSB_SET(b))
|
||||
jb acc.7,loop2
|
||||
|
||||
mov a,b0 ; b <<= 1
|
||||
add a,acc
|
||||
mov b0,a
|
||||
mov a,b1
|
||||
rlc a
|
||||
mov b1,a
|
||||
mov a,b2
|
||||
rlc a
|
||||
mov b2,a
|
||||
mov a,b3
|
||||
rlc a
|
||||
mov b3,a
|
||||
|
||||
mov a,a0 ; a - b
|
||||
subb a,b0 ; here carry is always clear
|
||||
mov a,a1
|
||||
subb a,b1
|
||||
mov a,a2
|
||||
subb a,b2
|
||||
mov a,a3
|
||||
subb a,b3
|
||||
|
||||
jnc loop1
|
||||
|
||||
|
||||
clr c
|
||||
mov a,b3 ; b >>= 1;
|
||||
rrc a
|
||||
mov b3,a
|
||||
mov a,b2
|
||||
rrc a
|
||||
mov b2,a
|
||||
mov a,b1
|
||||
rrc a
|
||||
mov b1,a
|
||||
mov a,b0
|
||||
rrc a
|
||||
mov b0,a
|
||||
|
||||
loop2: ; clr c never set
|
||||
mov a,a0 ; a - b
|
||||
subb a,b0
|
||||
mov r4,a
|
||||
mov a,a1
|
||||
subb a,b1
|
||||
mov r5,a
|
||||
mov a,a2
|
||||
subb a,b2
|
||||
mov r6,a
|
||||
mov a,a3
|
||||
subb a,b3
|
||||
|
||||
jc smaller ; a >= b?
|
||||
|
||||
mov a3,a ; -> yes; a = a - b;
|
||||
mov a2,r6
|
||||
mov a1,r5
|
||||
mov a0,r4
|
||||
smaller: ; -> no
|
||||
clr c
|
||||
mov a,b3 ; b >>= 1;
|
||||
rrc a
|
||||
mov b3,a
|
||||
mov a,b2
|
||||
rrc a
|
||||
mov b2,a
|
||||
mov a,b1
|
||||
rrc a
|
||||
mov b1,a
|
||||
mov a,b0
|
||||
rrc a
|
||||
mov b0,a
|
||||
|
||||
djnz count,loop2
|
||||
|
||||
mov a,a3 ; prepare the return value
|
||||
div_by_0:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#elif defined _MODULONG_ASM_SMALL_AUTO
|
||||
|
||||
static void
|
||||
_modlong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
.globl __modulong
|
||||
|
||||
__modulong:
|
||||
|
||||
#define count r0
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 b
|
||||
#define a3 r1
|
||||
|
||||
#define b0 r2
|
||||
#define b1 r3
|
||||
#define b2 r4
|
||||
#define b3 r5
|
||||
|
||||
ar2 = 2 ; BUG register set is not considered
|
||||
ar3 = 3
|
||||
ar4 = 4
|
||||
ar5 = 5
|
||||
|
||||
.globl __modlong ; entry point for __modslong
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov a3,a ; save parameter a3
|
||||
|
||||
mov a,sp
|
||||
add a,#-2-3 ; 2 bytes return address, 3 bytes param b
|
||||
mov r0,a ; r1 points to b0
|
||||
|
||||
|
||||
mov ar2,@r0 ; load b0
|
||||
inc r0 ; r0 points to b1
|
||||
mov ar3,@r0 ; b1
|
||||
inc r0
|
||||
mov ar4,@r0 ; b2
|
||||
inc r0
|
||||
mov ar5,@r0 ; b3
|
||||
|
||||
__modlong: ; entry point for __modslong
|
||||
; a in r1, b, dph, dpl
|
||||
; b in r5, r4, r3, r2
|
||||
|
||||
mov count,#0
|
||||
|
||||
mov a,b0 ; b == 0? avoid endless loop
|
||||
orl a,b1
|
||||
orl a,b2
|
||||
orl a,b3
|
||||
jz div_by_0
|
||||
|
||||
mov count,#0
|
||||
clr c ; when loop1 jumps immediately to loop2
|
||||
|
||||
loop1: inc count
|
||||
|
||||
mov a,b3 ; if (!MSB_SET(b))
|
||||
jb acc.7,loop2
|
||||
|
||||
mov a,b0 ; b <<= 1
|
||||
add a,acc
|
||||
mov b0,a
|
||||
mov a,b1
|
||||
rlc a
|
||||
mov b1,a
|
||||
mov a,b2
|
||||
rlc a
|
||||
mov b2,a
|
||||
mov a,b3
|
||||
rlc a
|
||||
mov b3,a
|
||||
|
||||
mov a,a0 ; a - b
|
||||
subb a,b0 ; here carry is always clear
|
||||
mov a,a1
|
||||
subb a,b1
|
||||
mov a,a2
|
||||
subb a,b2
|
||||
mov a,a3
|
||||
subb a,b3
|
||||
|
||||
jnc loop1
|
||||
|
||||
|
||||
clr c
|
||||
mov a,b3 ; b >>= 1;
|
||||
rrc a
|
||||
mov b3,a
|
||||
mov a,b2
|
||||
rrc a
|
||||
mov b2,a
|
||||
mov a,b1
|
||||
rrc a
|
||||
mov b1,a
|
||||
mov a,b0
|
||||
rrc a
|
||||
mov b0,a
|
||||
|
||||
loop2: ; clr c never set
|
||||
mov a,a0 ; a - b
|
||||
subb a,b0
|
||||
mov a,a1
|
||||
subb a,b1
|
||||
mov r6,a ; d1
|
||||
mov a,a2
|
||||
subb a,b2
|
||||
mov r7,a ; d2
|
||||
mov a,a3
|
||||
subb a,b3
|
||||
|
||||
jc smaller ; a >= b?
|
||||
|
||||
mov a3,a ; -> yes; a = a - b;
|
||||
mov a2,r7
|
||||
mov a1,r6
|
||||
mov a,a0
|
||||
subb a,b0
|
||||
mov a0,a
|
||||
smaller: ; -> no
|
||||
clr c
|
||||
mov a,b3 ; b >>= 1;
|
||||
rrc a
|
||||
mov b3,a
|
||||
mov a,b2
|
||||
rrc a
|
||||
mov b2,a
|
||||
mov a,b1
|
||||
rrc a
|
||||
mov b1,a
|
||||
mov a,b0
|
||||
rrc a
|
||||
mov b0,a
|
||||
|
||||
djnz count,loop2
|
||||
|
||||
mov a,a3 ; prepare the return value
|
||||
div_by_0:
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#else // _MODULONG_ASM
|
||||
|
||||
#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1)
|
||||
|
||||
unsigned long
|
||||
_modulong (unsigned long a, unsigned long b)
|
||||
{
|
||||
unsigned char count = 0;
|
||||
|
||||
while (!MSB_SET(b))
|
||||
{
|
||||
b <<= 1;
|
||||
if (b > a)
|
||||
{
|
||||
b >>=1;
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (a >= b)
|
||||
a -= b;
|
||||
b >>= 1;
|
||||
}
|
||||
while (count--);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif // _MODULONG_ASM
|
542
gbdk-lib/libc/_mullong.c
Normal file
542
gbdk-lib/libc/_mullong.c
Normal file
|
@ -0,0 +1,542 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
_mullong.c - routine for multiplication of 32 bit (unsigned) long
|
||||
|
||||
Written By - Jean Louis VERN jlvern@writeme.com (1999)
|
||||
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
In other words, you are welcome to use, share and improve this program.
|
||||
You are forbidden to forbid anyone else to use, share and improve
|
||||
what you give them. Help stamp out software-hoarding!
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
/* Signed and unsigned multiplication are the same - as long as the output
|
||||
has the same precision as the input.
|
||||
|
||||
To do: _mululong and _mulslong should be replaced by _mullong.
|
||||
|
||||
bernhard@bernhardheld.de
|
||||
|
||||
Assembler-functions are provided for:
|
||||
mcs51 small
|
||||
mcs51 small stack-auto
|
||||
*/
|
||||
|
||||
#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
|
||||
# if defined(SDCC_mcs51)
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# if defined(SDCC_STACK_AUTO)
|
||||
# define _MULLONG_ASM_SMALL_AUTO
|
||||
# else
|
||||
# define _MULLONG_ASM_SMALL
|
||||
# endif
|
||||
# elif defined(SDCC_MODEL_LARGE)
|
||||
# if !defined(SDCC_STACK_AUTO)
|
||||
# define _MULLONG_ASM_LARGE
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _MULLONG_ASM_SMALL || defined _MULLONG_ASM_SMALL_AUTO
|
||||
|
||||
void
|
||||
_mullong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
__mullong:
|
||||
__mululong: ; obsolete
|
||||
__mulslong: ; obsolete
|
||||
|
||||
.globl __mullong
|
||||
.globl __mululong ; obsolete
|
||||
.globl __mulslong ; obsolete
|
||||
|
||||
; the result c will be stored in r4...r7
|
||||
#define c0 r4
|
||||
#define c1 r5
|
||||
#define c2 r6
|
||||
#define c3 r7
|
||||
|
||||
; c0 a0 * b0
|
||||
; c1 a1 * b0 + a0 * b1
|
||||
; c2 a2 * b0 + a1 * b1 + a0 * b2
|
||||
; c3 a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3
|
||||
|
||||
#if !defined SDCC_STACK_AUTO
|
||||
|
||||
#if defined(SDCC_NOOVERLAY)
|
||||
.area DSEG (DATA)
|
||||
#else
|
||||
.area OSEG (OVR,DATA)
|
||||
#endif
|
||||
|
||||
__mullong_PARM_2:
|
||||
__mululong_PARM_2: ; obsolete
|
||||
__mulslong_PARM_2: ; obsolete
|
||||
|
||||
.globl __mullong_PARM_2
|
||||
.globl __mululong_PARM_2 ; obsolete
|
||||
.globl __mulslong_PARM_2 ; obsolete
|
||||
|
||||
.ds 4
|
||||
|
||||
.area CSEG (CODE)
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov r2,b ; save parameter a
|
||||
mov r3,a
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 r2
|
||||
#define a3 r3
|
||||
|
||||
b0 = __mullong_PARM_2
|
||||
b1 = (__mullong_PARM_2+1)
|
||||
b2 = (__mullong_PARM_2+2)
|
||||
b3 = (__mullong_PARM_2+3)
|
||||
|
||||
; Byte 0
|
||||
mov a,a0
|
||||
mov b,b0
|
||||
mul ab ; a0 * b0
|
||||
mov c0,a
|
||||
mov c1,b
|
||||
|
||||
; Byte 1
|
||||
mov a,a1
|
||||
mov b,b0
|
||||
mul ab ; a1 * b0
|
||||
add a,c1
|
||||
mov c1,a
|
||||
clr a
|
||||
addc a,b
|
||||
mov c2,a
|
||||
|
||||
|
||||
mov a,a0
|
||||
mov b,b1
|
||||
mul ab ; a0 * b1
|
||||
add a,c1
|
||||
mov c1,a
|
||||
mov a,b
|
||||
addc a,c2
|
||||
mov c2,a
|
||||
clr a
|
||||
rlc a
|
||||
mov c3,a
|
||||
|
||||
; Byte 2
|
||||
mov a,a2
|
||||
mov b,b0
|
||||
mul ab ; a2 * b0
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a1
|
||||
mov b,b1
|
||||
mul ab ; a1 * b1
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a0
|
||||
mov b,b2
|
||||
mul ab ; a0 * b2
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
; Byte 3
|
||||
mov a,a3
|
||||
mov b,b0
|
||||
mul ab ; a3 * b0
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a2
|
||||
mov b,b1
|
||||
mul ab ; a2 * b1
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a1
|
||||
mov b,b2
|
||||
mul ab ; a1 * b2
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a0
|
||||
mov b,b3
|
||||
mul ab ; a0 * b3
|
||||
add a,c3
|
||||
|
||||
mov b,c2
|
||||
mov dph,c1
|
||||
mov dpl,c0
|
||||
ret
|
||||
|
||||
#else // SDCC_STACK_AUTO
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov r2,b ; save parameter a
|
||||
mov r3,a
|
||||
|
||||
#define a0 dpl
|
||||
#define a1 dph
|
||||
#define a2 r2
|
||||
#define a3 r3
|
||||
|
||||
#define b0 r1
|
||||
|
||||
mov a,#-2-3 ; 1 return address 2 bytes, b 4 bytes
|
||||
add a,sp ; 1
|
||||
mov r0,a ; 1 r0 points to b0
|
||||
|
||||
; Byte 0
|
||||
mov a,a0
|
||||
mov b,@r0 ; b0
|
||||
mov b0,b ; we need b0 several times
|
||||
inc r0 ; r0 points to b1
|
||||
mul ab ; a0 * b0
|
||||
mov c0,a
|
||||
mov c1,b
|
||||
|
||||
; Byte 1
|
||||
mov a,a1
|
||||
mov b,b0
|
||||
mul ab ; a1 * b0
|
||||
add a,c1
|
||||
mov c1,a
|
||||
clr a
|
||||
addc a,b
|
||||
mov c2,a
|
||||
|
||||
|
||||
mov a,a0
|
||||
mov b,@r0 ; b1
|
||||
mul ab ; a0 * b1
|
||||
add a,c1
|
||||
mov c1,a
|
||||
mov a,b
|
||||
addc a,c2
|
||||
mov c2,a
|
||||
clr a
|
||||
rlc a
|
||||
mov c3,a
|
||||
|
||||
; Byte 2
|
||||
mov a,a2
|
||||
mov b,b0
|
||||
mul ab ; a2 * b0
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a1
|
||||
mov b,@r0 ; b1
|
||||
mul ab ; a1 * b1
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a0
|
||||
inc r0
|
||||
mov b,@r0 ; b2
|
||||
mul ab ; a0 * b2
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
; Byte 3
|
||||
mov a,a3
|
||||
mov b,b0
|
||||
mul ab ; a3 * b0
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a1
|
||||
mov b,@r0 ; b2
|
||||
mul ab ; a1 * b2
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a2
|
||||
dec r0
|
||||
mov b,@r0 ; b1
|
||||
mul ab ; a2 * b1
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov a,a0
|
||||
inc r0
|
||||
inc r0
|
||||
mov b,@r0 ; b3
|
||||
mul ab ; a0 * b3
|
||||
add a,c3
|
||||
|
||||
mov b,c2
|
||||
mov dph,c1
|
||||
mov dpl,c0
|
||||
|
||||
ret
|
||||
|
||||
#endif // SDCC_STACK_AUTO
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
|
||||
#elif defined _MULLONG_ASM_LARGE
|
||||
|
||||
void
|
||||
_mullong_dummy (void) _naked
|
||||
{
|
||||
_asm
|
||||
|
||||
__mullong:
|
||||
__mululong: ; obsolete
|
||||
__mulslong: ; obsolete
|
||||
|
||||
.globl __mullong
|
||||
.globl __mululong ; obsolete
|
||||
.globl __mulslong ; obsolete
|
||||
|
||||
; the result c will be stored in r4...r7
|
||||
#define c0 r4
|
||||
#define c1 r5
|
||||
#define c2 r6
|
||||
#define c3 r7
|
||||
|
||||
; c0 a0 * b0
|
||||
; c1 a1 * b0 + a0 * b1
|
||||
; c2 a2 * b0 + a1 * b1 + a0 * b2
|
||||
; c3 a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3
|
||||
|
||||
.area XSEG (XDATA)
|
||||
|
||||
__mullong_PARM_2:
|
||||
__mululong_PARM_2: ; obsolete
|
||||
__mulslong_PARM_2: ; obsolete
|
||||
|
||||
.globl __mullong_PARM_2
|
||||
.globl __mululong_PARM_2 ; obsolete
|
||||
.globl __mulslong_PARM_2 ; obsolete
|
||||
|
||||
.ds 4
|
||||
|
||||
.area CSEG (CODE)
|
||||
|
||||
; parameter a comes in a, b, dph, dpl
|
||||
mov r0,dpl ; save parameter a
|
||||
mov r1,dph
|
||||
mov r2,b
|
||||
mov r3,a
|
||||
|
||||
#define a0 r0
|
||||
#define a1 r1
|
||||
#define a2 r2
|
||||
#define a3 r3
|
||||
|
||||
; Byte 0
|
||||
mov b,a0
|
||||
mov dptr,#__mullong_PARM_2
|
||||
movx a,@dptr ; b0
|
||||
mul ab ; a0 * b0
|
||||
mov c0,a
|
||||
mov c1,b
|
||||
|
||||
; Byte 1
|
||||
mov b,a1
|
||||
movx a,@dptr ; b0
|
||||
mul ab ; a1 * b0
|
||||
add a,c1
|
||||
mov c1,a
|
||||
clr a
|
||||
addc a,b
|
||||
mov c2,a
|
||||
|
||||
|
||||
mov b,a0
|
||||
inc dptr ; b1
|
||||
movx a,@dptr
|
||||
mul ab ; a0 * b1
|
||||
add a,c1
|
||||
mov c1,a
|
||||
mov a,b
|
||||
addc a,c2
|
||||
mov c2,a
|
||||
clr a
|
||||
rlc a
|
||||
mov c3,a
|
||||
|
||||
; Byte 2
|
||||
mov b,a1
|
||||
movx a,@dptr ; b1
|
||||
mul ab ; a1 * b1
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov b,a0
|
||||
inc dptr ; b2
|
||||
movx a,@dptr
|
||||
mul ab ; a0 * b2
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
mov b,a2
|
||||
mov dptr,#__mullong_PARM_2
|
||||
movx a,@dptr ; b0
|
||||
mul ab ; a2 * b0
|
||||
add a,c2
|
||||
mov c2,a
|
||||
mov a,b
|
||||
addc a,c3
|
||||
mov c3,a
|
||||
|
||||
; Byte 3
|
||||
mov b,a3
|
||||
movx a,@dptr ; b0
|
||||
mul ab ; a3 * b0
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov b,a2
|
||||
inc dptr ; b1
|
||||
movx a,@dptr
|
||||
mul ab ; a2 * b1
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov b,a1
|
||||
inc dptr ; b2
|
||||
movx a,@dptr
|
||||
mul ab ; a1 * b2
|
||||
add a,c3
|
||||
mov c3,a
|
||||
|
||||
mov b,a0
|
||||
inc dptr ; b3
|
||||
movx a,@dptr
|
||||
mul ab ; a0 * b3
|
||||
add a,c3
|
||||
|
||||
mov b,c2
|
||||
mov dph,c1
|
||||
mov dpl,c0
|
||||
ret
|
||||
|
||||
_endasm ;
|
||||
}
|
||||
|
||||
#else // _MULLONG_ASM
|
||||
|
||||
struct some_struct {
|
||||
int a ;
|
||||
char b;
|
||||
long c ;};
|
||||
union bil {
|
||||
struct {unsigned char b0,b1,b2,b3 ;} b;
|
||||
struct {unsigned int lo,hi ;} i;
|
||||
unsigned long l;
|
||||
struct { unsigned char b0; unsigned int i12; unsigned char b3;} bi;
|
||||
} ;
|
||||
#if defined(SDCC_MODEL_LARGE) || defined (SDCC_ds390)
|
||||
#define bcast(x) ((union bil xdata *)&(x))
|
||||
#elif defined(__z80) || defined(__gbz80)
|
||||
#define bcast(x) ((union bil *)&(x))
|
||||
#else
|
||||
#define bcast(x) ((union bil near *)&(x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
3 2 1 0
|
||||
X 3 2 1 0
|
||||
----------------------------
|
||||
0.3 0.2 0.1 0.0
|
||||
1.3 1.2 1.1 1.0
|
||||
2.3 2.2 2.1 2.0
|
||||
3.3 3.2 3.1 3.0
|
||||
----------------------------
|
||||
|3.3|1.3|0.2|0.0| A
|
||||
|2.3|0.3|0.1| B
|
||||
|3.2|1.2|1.0| C
|
||||
|2.2|1.1| D
|
||||
|3.1|2.0| E
|
||||
|2.1| F
|
||||
|3.0| G
|
||||
|-------> only this side 32 x 32 -> 32
|
||||
*/
|
||||
unsigned long
|
||||
_mululong (unsigned long a, unsigned long b) // in future: _mullong
|
||||
{
|
||||
union bil t;
|
||||
|
||||
t.i.hi = bcast(a)->b.b0 * bcast(b)->b.b2; // A
|
||||
t.i.lo = bcast(a)->b.b0 * bcast(b)->b.b0; // A
|
||||
_asm ;johan _endasm;
|
||||
t.b.b3 += bcast(a)->b.b3 *
|
||||
bcast(b)->b.b0; // G
|
||||
t.b.b3 += bcast(a)->b.b2 *
|
||||
bcast(b)->b.b1; // F
|
||||
t.i.hi += bcast(a)->b.b2 * bcast(b)->b.b0; // E <- b lost in .lst
|
||||
// bcast(a)->i.hi is free !
|
||||
t.i.hi += bcast(a)->b.b1 * bcast(b)->b.b1; // D <- b lost in .lst
|
||||
|
||||
bcast(a)->bi.b3 = bcast(a)->b.b1 *
|
||||
bcast(b)->b.b2;
|
||||
bcast(a)->bi.i12 = bcast(a)->b.b1 *
|
||||
bcast(b)->b.b0; // C
|
||||
|
||||
bcast(b)->bi.b3 = bcast(a)->b.b0 *
|
||||
bcast(b)->b.b3;
|
||||
bcast(b)->bi.i12 = bcast(a)->b.b0 *
|
||||
bcast(b)->b.b1; // B
|
||||
bcast(b)->bi.b0 = 0; // B
|
||||
bcast(a)->bi.b0 = 0; // C
|
||||
t.l += a;
|
||||
|
||||
return t.l + b;
|
||||
}
|
||||
|
||||
long
|
||||
_mulslong (long a, long b) // obsolete
|
||||
{
|
||||
return _mululong (a, b);
|
||||
}
|
||||
|
||||
#endif // _MULLONG_ASM
|
|
@ -1,7 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <types.h>
|
||||
|
||||
int abs(int num) BANKED
|
||||
int abs(int num)
|
||||
{
|
||||
if(num < 0)
|
||||
return -num;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
/Makefile.port/1.3/Wed Jul 12 02:18:21 2000//Tgbdk-295
|
||||
D/gbz80////
|
||||
D/z80////
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue