From 13f9c770845e6d9d77cc779c0d86cea366e721d0 Mon Sep 17 00:00:00 2001 From: hachti Date: Sun, 23 Dec 2007 01:48:12 +0000 Subject: [PATCH] *** empty log message *** --- lib/hachti/Makefile | 65 ++++ lib/hachti/recipe/hachti.recipe | 2 +- lib/hachti/src/matrix.asm | 613 +++++++++++++++++--------------- lib/hachti/src/stack.asm | 9 +- 4 files changed, 399 insertions(+), 290 deletions(-) create mode 100644 lib/hachti/Makefile diff --git a/lib/hachti/Makefile b/lib/hachti/Makefile new file mode 100644 index 0000000..ecc3d67 --- /dev/null +++ b/lib/hachti/Makefile @@ -0,0 +1,65 @@ + +# Skript, das die neue Bibliothek zusammenbauen soll (01.01.06) + +export SRC_DIR = src +export OBJ_DIR = obj +export LIB_DIR = lib +export RECIPE_DIR = recipe +export RECIPE_SUFFIX=.recipe +export ENDBLOCK=$(H316)/snippets/endseq +export ORG_LIBDIR=original +export ORG_OBJDIR=org + +export MAKE + +MODULES = font matrix pl$$mv pl$$txt pl$$u stack + +FRTN_COMMAND = frtn_original +ASM_COMMAND = asm_original +LDC_COMMAND = ldc -saq + +############# + +RECIPES=$(foreach recipe,$(shell ls $(RECIPE_DIR) | egrep "recipe$$" | grep -v CVS),\ + $(RECIPE_DIR)/$(recipe)) + +LIBS=$(foreach lib,$(basename $(notdir $(RECIPES))),$(LIB_DIR)/$(lib).lib) + +OBJECTS=$(shell cat $(RECIPES)|egrep -v '^[[:space:]]*(\#.*)*$$'|\ + grep $(OBJ_DIR)|sort -u) + +OBJECT_FILES=$(foreach obj, $(MODULES), $(OBJ_DIR)/$(obj).obj) +SOURCE_FILES=$(foreach obj, $(MODULES), $(SRC_DIR)/$(obj).asm) + +#************ + +all: $(LIBS) + +$(ORG_OBJDIR)/lastrun: $(ORG_LIBDIR)/* + @if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi + @./buildlib.sh makeorg + +$(OBJECTS): $(OBJECT_FILES) + +$(OBJECT_FILES) : $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.asm +# @echo Building: $(subst $$,\$$,$@) + @if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi + @ rm -f $@ + @ cd $(OBJ_DIR) && $(ASM_COMMAND) ../$(subst $$,\$$,$^) $(LISTING) + @ cd $(OBJ_DIR) && $(LDC_COMMAND) $(notdir $(subst $$,\$$,$@)) + +# $(ORG_OBJDIR)/lastrun +$(LIBS):$(LIB_DIR)/%.lib: $(RECIPE_DIR)/%$(RECIPE_SUFFIX) $(OBJECTS) + @./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX) + +src/font.asm: + @ln -sf $(shell pwd)/fonts/font_hp_charset0_2.asm $(shell pwd)/src/font.asm + +clean: + @rm -rf $(OBJ_DIR) $(LIB_DIR) *.lst *.go src/font.asm *.obj *~ *.par + @./buildlib.sh clean + +.PHONY: clean all + +.PRECIOUS: org/lastrun + diff --git a/lib/hachti/recipe/hachti.recipe b/lib/hachti/recipe/hachti.recipe index 9a64e87..1ef6823 100644 --- a/lib/hachti/recipe/hachti.recipe +++ b/lib/hachti/recipe/hachti.recipe @@ -5,7 +5,7 @@ obj/PL$TXT obj/PL$MV # Matrix operations -obj/M$INIT +obj/MATRIX # Low level pulse motion driver obj/PL$U diff --git a/lib/hachti/src/matrix.asm b/lib/hachti/src/matrix.asm index 2bd09c6..34c42fb 100644 --- a/lib/hachti/src/matrix.asm +++ b/lib/hachti/src/matrix.asm @@ -1,87 +1,259 @@ -* -* -* -* MATRIX FORMAT: -* -* a11 a12 -* -* a21 a22 -* -* a11-a22 are single precision float variables (2 word). -* -* -* IN MEMORY LAYOUT: -* -* a11 -* a11 -* a12 -* a12 -* a21 -* a21 -* a22 -* a22 -* -* -* JST M$INIT INITIALIZE MATRIX TO IDENTITY -* DAC MATRIX ADDRESS -* -* +* MATRIX - AFFINE TRANSFORM SUPPORT PACKAGE +* +* +* AUTHOR: +* +* PHILIPP HACHTMANN +* +* VERSIONS: +* 0.1 - INITIAL REVISION (22.12.2007 +* +* +* PURPOSE: +* +* THIS LIBRARY PROVIDES AFFINE TRANSFORMATION ROUTINES TO +* PLOTTING ROUTINES AND OTHER SOFTWARE. +* +* +* DATA REPRESENTATION: +* +* +* MATRIX FORMAT: | A11 A12 | +* M= | | +* | A21 A22 | +* +* A11-A22 ARE SINGLE PRECISION FLOAT VALUES COMPLIANT TO THE +* HONEYWELL MATHEMATICAL LIBARAY. EVERY VALUE USES TWO +* 16 BIT MACHINE WORDS. +* IF A MATRIX IS USED AS A DAC ARGUMENT, A POINTER TO THE FIRST +* ELEMENT, A11, HAS TO BE USED. +* +* +* VECTOR FORMAT: | A1 | +* V= | | +* | A2 | +* +* A1 AND A2 ARE SIGNED INTEGER VALUES. EVERY VALUE USES ONE +* 16 BIT MACHINE WORD. +* IF A VECTOR IS USED AS A DAC ARGUMENT, A POINTER TO THE FIRST +* ELEMENT, A1, HAS TO BE USED. +* +* +* AFFINE TRANSFORM FORMAT: +* +* AN AFFINE TRANSFORM CONSISTS OF A MATRIX FOR ROTATING AND SCALING +* AND A VECTOR VOR RELOCATION OF THE RESULT. +* A VECTOR IS TRANSFORMED BY FIRST MULTIPLYING THE MATRIX WITH IT +* AND THEN ADDING THE RELOCATION VECTOR: +* +* | A11 A12 | | VI1 | | VT1 | +* VO = MT * VI + VT = | | * | | + | | +* | A21 A22 | | VI2 | | VT2 | +* +* | VI1*A11 + VI2*A12 + VT1 | +* = | | +* | VI1*A21 + VI2*A22 + VT2 | +* +* MT AND VT ARE THE TRANSFORMATION MATRIX AND VECTOR, VI THE INPUT +* VECTOR, VO THE RESULT VECTOR. +* +* AN AFFINE TRANSFORM IS STORED AS A CONCATENATION OF A MATRIX AND +* A VECTOR. HERE IS THE MEMORY LAYOUT: +* +* '000 : MT11 UPPER +* '001 : MT11 LOWER +* '002 : MT12 UPPER +* '003 : MT12 LOWER +* '004 : MT21 UPPER +* '005 : MT21 LOWER +* '006 : MT22 UPPER +* '007 : MT22 LOWER +* '010 : VT1 +* '011 : VT2 +* +* FOR EVERY TRANSFORMATION, '12 WORDS HAVE TO BE RESERVED. +* IN AN APPLICATION, A TRANFORMATION VARIABLE COULD BE +* DECLARED WITH: +* +* TRANS BSS '12 +* +* +* +********************************************************************************* +* +* +* +* M$INIT: INITIALISE MATRIX TO IDENTITY +* +* THE MATRIX ARGUMENT IS SET TO +* +* | 1.0 0.0 | +* M= | | +* | 0.0 1.0 | +* +* WICH RESULTS TO THE IDENTITY TRANSFORMATION. +* +* JST M$INIT +* DAC MATRIX POINTER TO A MATRIX +* +* +* +* M$MUL: MATRIX MULTIPLICATION +* +* JST M$MUL +* DAC TARGET POINTER TO TARGET MATRIX +* DAC MATRIX1 POINTER TO LEFT MATRIX +* DAC MATRIX2 POINTER TO RIGHT MATRIX +* DAC 0 FOR FORTRAN IV COMPATIBILITY +* +* +* +* M$APLI: APPLY MATRIX TO VECTOR +* +* THIS ROUTINE CONVERTS THE VECTOR ELEMENTS TO FLOATING POINT VALUES, +* APPLIES THE TRANSFORMATION TO THEM AND ROUNDS THE RESULTS BACK TO +* INTEGER VALUES. THEN IT SAVES THE NEW VECTOR IN THE PLACE OF THE +* OLD VECTOR. +* +* JST M$APLI +* DAC MATRIX MATRIX TO APPLY +* DAC VECTOR VECTOR TO TRANSFORM +* DAC 0 FOR FORTRAN IV COMPATIBILITY +* +* +* M$APII: APPLY MATRIX TO PAIR OF INTEGERS AS VECTOR +* +* THIS ROUTINE USES TWO DISTINCT INTEGER POINTERS INSTEAD OF ONE VECTOR +* POINTER. THE REST OF THE BEHAVIOR IS EXACTLY LIKE M$APL. +* +* JST M$APLI +* DAC MATRIX MATRIX TO APPLY +* DAC X X COORDINATE OF ARGUMENT VECTOR +* DAC Y Y COORDINATE OF ARGUMENT VECTOR +* +* +* M$ROT: ROTATE MATRIX +* +* THIS ROUTINE TAKES A MATRIX AND ADDS A ROTATION TO IT. +* INTERNALLY, THE ROUTINE CREATES A ROTATION MATRIX AND THEN +* MULTIPLIES IT WITH THE ARGUMENT MATRIX. THE ROTATION IS SPECIFIED +* COUNTERCLOCKWISE FORWARD, ANGLE IN RADIANT. +* THE ANGLE ARGUMENT IS A SINGLE PRECISION FLOATING POINT NUMER +* TAKING TWO WORDS TO STORE. +* +* JST M$ROT +* DAC MATRIX MATRIX TO MODIFY +* DAC ANGLE RADIANT ANGLE +* +* +* M$SCLE: SCALE MATRIX +* +* THIS ROUTINE WORKS SIMILAR TO M$ROT BUT SCALES THE ARGUMENT MATRIX. +* THE SCALE FACTOR IS A FLOATING POINT NUMBER. LIKE THE ROTATION ANGLE. +* +* JST M$SCLE +* DAC MATRIX MATRIX TO MODIFY +* DAC SCALE SCALE FACTOR +* +* ******************************************************************************** * - SUBR M$INIT,INIT INITIALIZE MATRIX +**** EXPORTED SYMBOLS +* + SUBR MATRIX,INIT JUST A FANCY LABEL + SUBR M$INIT,INIT INITIALISE MATRIX SUBR M$MUL,MUL MATRIX MULTIPLICATION SUBR M$APLI,APLI APPLY MATRIX TO INTEGER VECTOR SUBR M$APII,APII APPLY MATRIX TO PAIR OF INTEGERS - SUBR M$ROT,XXX ADD ROTATION TO MATRIX ARGUMENT + SUBR M$ROT,ROT ADD ROTATION TO MATRIX SUBR M$SCLE,SCLE SCALE MATRIX * - REL - ORG '0 -* -* -* -* -* + SUBR A$INIT,AFIN INITIALISE AFFINE TRANSFORMATION +* +* +******************************************************************************** +* +* + REL RELOCATEABLE MODE +* +* ******************************************************************************** * +* +**** INITIALIZE AFFINE TRANSFORMATION +* +AFIN DAC ** + LDA* AFIN + STA AFI1 STORE ARGUMENT POINTER + LDX AFIN LOAD INTO INDEX REGISTER, TOO + IRS AFIN TALLY RETURN ADDRESS +* + JST INIT MATRIX INIT +AFI1 DAC ** +* + CRA + STA 8,1 CLEAR FIRST VECTOR ELEMENT + STA 9,1 CLEAR SECOND VECTOR ELEMENT +* + JMP* AFIN RETURN TO CALLER +* +* +******************************************************************************** +* * +**** INITIALIZE MATRIX +* +* THIS ROUTINE SHOULD BE IMPROVED BY SUPPLYING +* A FLOATING POINT 1.0 CONSTANT! +* +**************************************** +* INIT DAC ** - LDX* INIT -* - LDA* INIT GET MATRIX BASE ADDRESS - STA IM11 - ADD =6 - STA IM22 - IRS INIT -* - CRA - STA 2,1 - STA 3,1 - STA 4,1 - STA 5,1 - CALL FLOAT - DAC ONE - CALL H$22 + LDX* INIT LOAD INDEX REGISTER WITH ADDRESS OF MATRIX + LDA* INIT LOAD MATRIX ADDRESS + STA IM11 STORE POINTER TO FIRST ELEMENT (A11) + ADD =6 IM12,IM21 ARE NOT TO BE INITIALISED WITH FP DATA + STA IM22 STORE POINTER TO FOURTH ELEMENT (A22) + IRS INIT CORRECT RETURN ADDRESS +* + CRA INITIALISE + STA 2,1 A12 + STA 3,1 + STA 4,1 A21 + STA 5,1 + CALL FLOAT GENERATE FLOATING POINT 1.0 + DAC ONE CONSTANT INTEGER 1 + CALL H$22 STORE FLOATING POINT IM11 DEC 0 CALL H$22 IM22 DEC 0 * - JMP* INIT -ONE DEC 1 -* -* + JMP* INIT RETURN. +* +* ******************************************************************************** +* +* +**** MATRIX MULTIPLICATION +* +* C = A * B +* +* | a11 a12 | | b11 b12 | +* = | | * | | +* | a21 a22 | | b21 b22 | +* +* | (a11*b11) (a21*b12) | +* = | | +* | (a12*b21) (a22*b22) | +* +* CALL: +* JST MUL +* DAC MC +* DAC MA +* DAC MB * -* C=A*B -* -* a11 a12 b11 b12 a11*b11 a21*b12 -* a21 a22 b21 b22 a12*b21 a22*b22 -* -* JST MUL -* DAC MC -* DAC MA -* DAC MB -* +**************************************** +* MUL DAC ** LDX* MUL * @@ -120,7 +292,6 @@ MUL DAC ** IRS MUL IRS MUL * -* * a11 a12 b11 b12 a11*b11 a21*b12 * a21 a22 b21 b22 a12*b21 a22*b22 * @@ -153,11 +324,14 @@ PB22 DEC 0 PC22 DEC 0 * * - JMP* MUL + JMP* MUL RETURN. * +* ******************************************************************************** * * +**** SCALE MATRIX +* SCLE DAC ** SCALE MATRIX LDX* SCLE * @@ -190,18 +364,36 @@ TM22 DAC 0 JMP* SCLE * * -* -* +******************************************************************************** +* +* +**** ROTATE MATRIX +* +* THIS ROUTINE IS NOT YET FINISHED! +* +**************************************** +* +ROT DAC ** ENTRY + IRS ROT TALLY RETURN ADDRESS + JMP* ROT EXIT +* +* ******************************************************************************** * * -* Apply Pair of integers and round +**** APPLY MATRIX TO PAIR OF INTEGERS * -* JST M$APII -* DAC MATRIX -* DAC X -* DAC Y -* DAC 0 +* SETS UP MATRIX POINTERS AND VECTOR POINTERS. +* THEN IT CALLS APL, THE REAL WORKING ROUTINE. +* +* CALL: +* JST M$APII +* DAC MATRIX +* DAC X +* DAC Y +* DAC 0 DON'T FORGET! +* +**************************************** * APII DAC ** * @@ -230,14 +422,21 @@ APII DAC ** ******************************************************************************** * * -* Apply to integer vector and round +**** APPLY MATRIX TO VECTOR +* +* SETS UP MATRIX POINTERS AND VECTOR POINTERS. THEN IT CALLS APL, +* THE REAL WORKING ROUTINE. * -* JST M$APLI -* DAC MATRIX -* DAC X Y MUST FOLLOW IN NEXT LOCATION! +* CALL: +* JST M$APLI +* DAC MATRIX +* DAC VECTOR +* DAC 0 DON'T FORGET! +* +**************************************** * APLI DAC ** -* +* LDA* APLI STA MP11 ADD =2 @@ -256,14 +455,20 @@ APLI DAC ** STA YP2 IRS APLI IRS APLI - JST APL - JMP* APLI + JST APL CALL INTERNAL ROUTINE + JMP* APLI RETURN. * * -**************************************** +******************************************************************************** * * -APL DAC ** REAL APPLY ROUTINE +**** INTERNAL ROUTINE OF M$APL AND M$APII. +* +* ALL DATA IS SET UP BY THE BOTH USER ROUTINES ABOVE. +* +**************************************** +* +APL DAC ** * CALL FLOAT LOAD SINGLE PRECISION FLOAT FROM 1-WORD INTEGER XP1 DAC 0 @@ -300,218 +505,50 @@ MP22 DAC 0 STA* XP1 JMP* APL RETURN TO CALLER. * -**************************************** +* +******************************************************************************** * -RND DAC ** ROUND A/B AND RETURN WITH INTEGER IN A - CALL A$22 ADD 0.5 - DAC HLF - CALL C$21 CONVERT TO INTEGER +* +**** ROUND FLOAT TO INTEGER ROUTINE +* +* THERE IS NO CORRECTLY WORKING ROUNDING ROUTINE IN THE LIBRARY. +* SO THIS IS A WORKAROUND. ADDS 0.5 TO THE VALUE AND USES ONE +* ONE OF THE TRUNCATE AND CONVERT ROUTINES. +* THE ARGUMENT IS IN REGISTERS A/B, THE RESULT IS PUT INTO A. +* +**************************************** +* +RND DAC ** + CALL A$22 ADD + DAC HLF 0.5 + CALL C$21 TRUNCATE TO INTEGER NOP JMP* RND +* +* +******************************************************************************** +* +* +**** CONSTANTS +* +ONE DEC 1 HLF OCT '040100 CONSTANT 0.5 OCT '000000 -* -**************************************** -* -TMP BSS 2 -* -* +* +* ******************************************************************************** -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* +* +**** VARIABLES +* +TMP BSS '10 SOME SPACE * * ******************************************************************************** * +* +**** END OF THE LINE +* END * +* ******************************************************************************** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/hachti/src/stack.asm b/lib/hachti/src/stack.asm index 45d930f..84c72b7 100644 --- a/lib/hachti/src/stack.asm +++ b/lib/hachti/src/stack.asm @@ -2,9 +2,15 @@ * * * AUTHOR: +* * PHILIPP HACHTMANN, 2007 * +* VERSIONS: +* +* 0.1 - INITIAL REVISION (22.12.2007) +* * PURPOSE: +* * TO PROVIDE A MULTI-PURPOSE STACK MECHANISM * TO PROVIDE A SPECIAL-PURPOSE STACK MECHANISM FOR RECURSIVE * PROGRAM CALLS @@ -15,9 +21,10 @@ * BUFFER FOR THE THE STACK. THE STACK USAGE IS MONITORED. * ON OVERFLOW, THE COMPUTER TYPES OUT AN ERROR MESSAGE AND HALTS. * +* * USAGE: * -* INITIALIZING STACK POINTER: +* INITIALISING STACK POINTER: * * CALL S$INIT * -- 2.32.0