Jump to content



0

Lot of news on MLC and PreCompiler


1 reply to this topic

#1 moulinaie OFFLINE  

moulinaie

    Chopper Commander

  • 185 posts
  • Location:France, Burgundy

Posted Tue Dec 6, 2011 7:37 AM

Hello,

I have updated MLC and added this:
  • logical instructions
  • constant data initialization (tables of bytes, words, strings) (that could lead to an inline assembler...)
  • better I/O of strings through CALL LINK
And so the PreCompiler had to be upgraded too:
  • the things above from MLC
  • more pseudo-instructions
Example: N0DO / N0LOOP that can loop from N to 0 (n+1 loops)
N-1DO / N-1LOOP that can loop from N-1 to 0 (n loops)
  • The char definitions into $CHAR section can be "graphical", example:
$CHAR
	$PATTERN	   ; here one char is defined
	........
	..00000.
	.0.....0
	.0000000
	.0.....0
	.0.....0
	.0.....0
	........
	$$
	$PATTERN	   	 	  ; here two consecutive chars are defined
	........00000000
	.......0.0000000
	......0...000000
	.....0.....00000
	....0.......0000
	...0.........000
	..0...........00
	.0.............0
	$$
$$

  • The numbers can now be written in hex or bin with &H and &B prefixes.

To illustrate the new functions with data initialization, I have written ROMAN, a program that turns a number into a ROMAN number with letters M, D, C, L, X, V and I. The call is "CALL LINK("ROMAN",X,R$)" with X the number to convert and R$ a string with the returned value.

100 CALL CLEAR::DIM A$(44)
$MLC F 110 10 3000
300 INPUT "A=":A
310 CALL LINK("ROMAN",A,R$)
320 PRINT "  = ";R$
330 GOTO 300
$ROMAN
	HIGHMEM 0
	STARTDATA
		WORDS 1000,999,995,990,950,900  ; create a word table with values of
		WORDS 500,499,495,490,450,400   ; usable symbols or combined symbols (by pair)
		WORDS 100,99,95,90
		WORDS 50,49,45,40
		WORDS 10,9,5,4,1,0
	ENDDATA A						   ; this table pointed by A (because A, B, C, D are word table pointers)
	STARTDATA
		STRING "M IMVMXMLMCM"		   ; creeate a long string with symbols alone or by pair
		STRING "D IDVDXDLDCD"
		STRING "C ICVCXC"
		STRING "L ILVLXL"
		STRING "X IXV IVI "
	ENDDATA E						   ; pointed by E (because E, F, G, H are byte table pointers)
	DIMTABLE F 255					  ; the output string reserved here with 255 max chars
	GETPARAM 1 X						; get the value to be converted in X
	CLEAR K							 ; will point into output string (0 to 254)
	CLEAR I							 ; points into A() (from 0 to 25, the last A(25) is null for marker)
	CLEAR J							 ; points into E() string (from 0 to 49)
	DO
		GETTABLE A(I) Y				 ; one value from table A() into Y
	WHILE<>
		DO
			COMPARE X Y				 ; does Y fit in X?
		WHILE>=
			SUB X Y					 ; if YES, remove Y from X
			GETTABLE E(J) C			 ; get one symbol
			PUTTABLE F(K) C			 ; and put it into output string
			INC J					   ; see next
			INC K					   ; idem
			GETTABLE E(J) C			 ; get next symbol
			COMPARE C 32				; is it a SPACE? (32)
			IF<>
				PUTTABLE F(K) C		 ; if not, it's a pair, add second symbol
				INC K				   ; one more char
			ENDIF	  
			DEC J					   ; back on 1st symbol if to be repeated
		 LOOP
		 INC I						  ; if Y doesn't fit in X anymore, next value in A()
		 ADD J 2						; and next symbols in E()
	 LOOP
	 LET U 2							; second paramater in CALL LINK (U, V, W, X are string pointers in CALL LINK)
	 LET Z K							; get lenght of string in Z
	 PUTTABLE U(0) F					; return Z chars from F table to string R$ in CALL LINK
$$
$END

You can download things here:
MLC with a disk image with the compiler, the english manual and programs into MLC.ZIP:
http://gtello.pagesp...ge.fr/mlc_e.htm
The PreCompiler with other sources into PRECOMPILER.ZIP:
http://gtello.pagesp...precompiler.htm

Guillaume.

#2 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Tue Dec 6, 2011 7:45 AM

He he! This is seriously cool! This is turning into a great tool! Great job :thumbsup:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users