Jump to content
IGNORED

Effectus - Action! cross-compiler using Mad-Assembler (MADS)


Gury

Recommended Posts

begin
	repeat until false;
end.
Mad Pascal Compiler version 1.6.4 [2020/06/25] for 6502
Compiling hello.pas
6 lines compiled, 0.64 sec, 4875 tokens, 387 idents, 155 blocks, 5 types
ZPAGE: $0080..$00D7
RTLIB: $2000..$1FFF
SYSTEM: $2030..$2033
CODE: $2000..$204A
DATA: $204B..$2056
m 80  
0080: 00 00 56 20 00 00 00 00 00 00 00 9E 93 00 00 00  ♥♥V ♥♥♥♥♥♥♥←╋♥♥♥
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E0  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥◆
00A0: 00 E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥◆♥♥♥♥♥♥♥♥♥♥♥♥♥♥
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
; ------------------------------------------------------------

	org $80

fxptr	.ds 2						; VBXE pointer
psptr	.ds 2						; PROGRAMSTACK Pointer

eax	.ds 4						;8 bytes (aex + edx) -> divREAL
edx	.ds 4
ecx	.ds 4
bp	.ds 2
bp2	.ds 2

TMP
ztmp
ztmp8	.ds 1
ztmp9	.ds 1
ztmp10	.ds 1
ztmp11	.ds 1

STACKORIGIN	.ds STACKWIDTH*4
zpend

; ------------------------------------------------------------

ax	= eax
al	= eax
ah	= eax+1

cx	= ecx
cl	= ecx
ch	= ecx+1

dx	= edx
dl	= edx
dh	= edx+1

	org eax

FP1MAN0	.ds 1
FP1MAN1	.ds 1
FP1MAN2	.ds 1
FP1MAN3	.ds 1

	org ztmp8

FP1SGN	.ds 1
FP1EXP	.ds 1

	org edx

FP2MAN0	.ds 1
FP2MAN1	.ds 1

FP2MAN2	.ds 1
FP2MAN3	.ds 1

	org ztmp10

FP2SGN	.ds 1
FP2EXP	.ds 1

	org ecx

FPMAN0	.ds 1
FPMAN1	.ds 1
FPMAN2	.ds 1
FPMAN3	.ds 1

	org bp2

FPSGN	.ds 1
FPEXP	.ds 1

	.ifdef MAIN.@DEFINES.S_VBXE
	opt h-
	ins 'atari\s_vbxe\sdxld2.obx'
	opt h+
	.endif

; ------------------------------------------------------------

Exactly as @tebe said: ZPAGE: $0080..$00D7 unfortunately it does't look like dynamically allocated memory.

Edited by zbyti
  • Like 1
Link to comment
Share on other sites

Ok, I understand. There will have to be some way to transfer these addresses during translation to properly compile Action! code. I can now understand why code I tested (FUNCtion returning result in $A0) didn't work.

Ow, can you please enlighten me what is the purpose of memory addresses $CA..$CF in Action!?

 

Edited by Gury
Link to comment
Share on other sites

@Gury

 

I think moving $Ax should be optional as a flag, because the problem will only occur if the code will be a Action! source with parameterized =*.

Action! RUNTIME in Effectus don't use $Ax at all, only some custom PROC/FUNC may will.

 

Effectus itself is not burdened with such problem and We can write programs in accordance to the new standards.

 

$CA..$CE according to some materials is the only free space on the zero page above the $80 available to the programmer (when the Action! environment exists in memory), I used this cells.

Edited by zbyti
$CA..$CE info
  • Like 1
Link to comment
Share on other sites

In this case it should be better to move $Ax automatically when parameterized =* FUNC/PROC is used. For other cases it should be optional; that is, writing Effectus code according to new standards using $Ex and beyond, or moving all $Ax to new address by option directive (if code includes $Ax addresses). For $CA..$CE ($CF?) it should be all automatic translation to new addresses.

What do you think?

 

Link to comment
Share on other sites

I think this issue should be last on Your list for now ;)

 

If high compatibility is Your main goal then yes, translation should change the $Ax automatically.

 

$CA..$CE is marginal and programmer shold change such accurance manually, proper info about ZPAGE: $0080..$00D7 should be in Effectus readme.txt.

 

Personally I'm going to use Effectus like Mad Pascal instead of Action! way, I just simply like the Action! syntax only ;)

mapa-pamięci.png

Edited by zbyti
what I like ;)
Link to comment
Share on other sites

New version 0.5.1 (link)

New features

  • INCLUDE directive supported:
    • files can be included, starting in the same directory as main compiled listing code
    • currently one level of included files is supported. This means only main listing program can read other files with the use of INCLUDE directive (this directive will be ignored in included files)
    • file is ignored if it isn't found
    Example:
      INCLUDE "D1:LIBRARY.EFF"
      INCLUDE "H1:lib_test.eff"
      INCLUDE "TEST01.EFF"
  • Shell parameter -nc flag changed to -t (Effectus only translate source to Mad Pascal) - changed by Zbyti
  • IF condition operators AND and OR supported (every condition must be surrounded by () pair for the program to be compiled properly)
    Example:
      IF (SIZEP(3) = 1) AND (P0 = P0HPOS) AND (A = 2) THEN
      IF (T1 = 1) OR (T2 = 3) OR (isFlag = 0) THEN

Bug fixes

  • Proper parsing of FUNCtions inside IF condition block
  • Proper handling of zero-page addresses from $A0 to $AF as parameters for machine language routines inside PROCedures and FUNCtions
  • Code refactoring and bug fixes by Zbyti:
    • doubled operator fix with all operands
    • SHL -> LSH bug correction
    • LSH -> SHR bug correction
  • Like 4
Link to comment
Share on other sites

Benchmark: YoshBenchPlus

 

program YoshBenchPlus;

uses crt;

{$define FAST}

{$ifdef FAST}
	var i	: word absolute $e0;
	var a	: word absolute $e2;
	var b	: word absolute $e4;
{$else}
	var i	: word;
	var a	: word;
	var b	: word;
{$endif}

var rtClock : byte absolute 20;

begin
	i:=0;a:=0;b:=0;

	Pause;
	rtClock := 0;

	while rtClock < 100 do begin
		Inc(a); b := a;
		Inc(b); a := b;
		Inc(i);
	end;

	WriteLn('YoshPlus - iterations in 100 frames.');
	{$ifdef FAST}
		Writeln('Mad Pascal 1.6.4 opt');
	{$else}
		Writeln('Mad Pascal 1.6.4');
	{$endif}
	Writeln('Counter = ', i);
	ReadKey;
end.
SET $E=$2000

BYTE RTCLOK=$14

CARD
  I=$CA,A=$CC,B=$CE

PROC WAIT=*(BYTE F)[$18$65$14$C5$14$D0$FC$60]

PROC MAIN()
  I=0 A=0 B=0
  WAIT(1) RTCLOK=0

  WHILE RTCLOK<100 DO
    A==+1 B=A
    B==+1 A=B
    I==+1
  OD

  PRINTC(I)
RETURN
  DO
    A==+1 B=A
    B==+1 A=B
    I==+1
    UNTIL RTCLOK=100
  OD
  DO
    A==+1 B=A
    B==+1 A=B
    I==+1
    IF RTCLOK=100 THEN EXIT FI
  OD
Mad Pascal 1.6.4 Zero Page: 41933 WHILE

Action! 3.6 Zero Page:      39802 WHILE
Action! 3.6 Zero Page:      40488 UNTIL
Action! 3.6 Zero Page:      38498 EXIT

Effectus 0.5.1 Zero Page:   41933 WHILE
Effectus 0.5.1 Zero Page:   41933 UNTIL
Effectus 0.5.1 Zero Page:   39803 EXIT

 

  • Like 1
Link to comment
Share on other sites

SET $E=$2000

BYTE RTCLOK=$14

CARD
  I=$CA,A=$CC,B=$CE

PROC WAIT=*(BYTE F)[$18$65$14$C5$14$D0$FC$60]

PROC MAIN()
  I=0 A=0 B=0
  WAIT(1) RTCLOK=0

  A==+1 B=A
  B==+1 A=B
  I==+1
  [$A9$64$C5$14$D0$D8]

  PRINTC(I)
RETURN
2000: 18        CLC
2001: 65 14     ADC $14     ;RTCLOK+2
2003: C5 14     CMP $14     ;RTCLOK+2
2005: D0 FC     BNE $2003
2007: 60        RTS
2008: 4C 0B 20  JMP $200B
200B: A0 00     LDY #$00
200D: 84 CB     STY $CB
200F: 84 CA     STY $CA     ;LOADFLG
2011: 84 CD     STY $CD
2013: 84 CC     STY $CC
2015: 84 CF     STY $CF
2017: 84 CE     STY $CE
2019: A9 01     LDA #$01
201B: 20 00 20  JSR $2000
201E: A0 00     LDY #$00
2020: 84 14     STY $14     ;RTCLOK+2
2022: E6 CC     INC $CC
2024: D0 02     BNE $2028
2026: E6 CD     INC $CD
2028: A5 CD     LDA $CD
202A: 85 CF     STA $CF
202C: A5 CC     LDA $CC
202E: 85 CE     STA $CE
2030: E6 CE     INC $CE
2032: D0 02     BNE $2036
2034: E6 CF     INC $CF
2036: A5 CF     LDA $CF
2038: 85 CD     STA $CD
203A: A5 CE     LDA $CE
203C: 85 CC     STA $CC
203E: E6 CA     INC $CA     ;LOADFLG
2040: D0 02     BNE $2044
2042: E6 CB     INC $CB
2044: A9 64     LDA #$64
2046: C5 14     CMP $14     ;RTCLOK+2
2048: D0 D8     BNE $2022
204A: A6 CB     LDX $CB
204C: A5 CA     LDA $CA     ;LOADFLG
204E: 20 E6 A4  JSR $A4E6
2051: 60        RTS

atari000.png

Action! 3.6 Zero Page:      39802 WHILE
Action! 3.6 Zero Page:      40488 UNTIL
Action! 3.6 Zero Page:      38498 EXIT

Action! 3.6 Zero Page:      41932 ML

 

Edited by zbyti
ML
  • Like 1
Link to comment
Share on other sites

// Eratosthenes Sieve 1028 Benchmark

uses crt;

{$define FAST}

const
 size = 8191;

var
  flags: array [0..size] of boolean;
  rtClock: byte absolute $14;

{$ifdef FAST}
  n: byte absolute $e0;
  k: word absolute $e2;
  count: word absolute $e6;
{$else}
  n, k, count: word;
{$endif}

begin
	
	writeln('Mad Pascal 1.6.4 MASTER');
	writeln('Eratosthenes 1028 Sieve Benchmark');
	
	Pause;
	rtClock := 0;
	
	fillchar(flags, sizeof(flags), true);
	
	for n := 2 to 91 do begin
		if flags[n] then begin
			k := n shl 1;
			while k <= size do begin
				flags[k] := false;
				Inc(k,n);
			end;
		end;	
	end;
	writeln(rtClock, ' frames');
	
	count :=0;
	for k := 2 to size do begin
		if flags[k] then Inc(count);
	end;

	writeln(count, ' primes');
	repeat until keypressed;
end.
SET $E=$2000

BYTE ARRAY FLAGS(8192)

BYTE
  RTCLOCK=$14,N=$CE

CARD
  COUNT=$CA,K=$CC

PROC WAIT=*(BYTE F)[$18$65$14$C5$14$D0$FC$60]

PROC MAIN=*()
  COUNT=0 K=0
  WAIT(1) RTCLOCK=0

  SETBLOCK(FLAGS,8192,'T)

  FOR N=2 TO 91 DO
    IF FLAGS(N)='T THEN
      K=N LSH 1
      WHILE K<=8191 DO
        FLAGS(K)='F
        K==+N
      OD
    FI
  OD

  PRINTB(RTCLOCK)

  FOR K=2 TO 8191 DO
    IF FLAGS(K)='T THEN COUNT==+1 FI
  OD

  PRINTF("%E%U PRIMES%E",COUNT)
RETURN
Sieve 1028 Benchmark (less is better)

Mad Pascal 1.6.4     36 frames
Effectus 0.5.1       36 frames
Action! 3.6          45 frames

 

Edited by zbyti
another benchmark
  • Like 2
Link to comment
Share on other sites

OFF-TOPIC

We have to be careful with using RUNTIME from the internet, some are real crap, e.g. the one I've used so far:

PROC SetBlock=*(CARD a, l BYTE v)
[$85$A0$86$A1$84$A2$A0$00$A5$A2$D0$04
$A5$A3$F0$16$A5$A4$91$A0$C8$D0$02$E6
$A1$C6$A2$A5$A2$C9$FF$D0$E7$C6$A3$38
$B0$E2$60]

11 frames in SIEVE 1028 benchmark Vs. originally 3 frames (Action! 3.6 cartridge). Still is a room to improve since Mad Pascal ended fill in 2 frames.

RUNTIME.ACT

Edited by zbyti
OT
  • Like 1
Link to comment
Share on other sites

On 7/10/2020 at 1:27 AM, Gury said:

So, to my understanding these tests show that, Mad Pascal and consequently Effectus are very fast :)

Action! with ML is nearly as fast.

            org $2000
			
            .var i,a,b .word = $80
			
            mwa #0 a \ mwa #0 b \ mwa #0 i

            wait
			
loop        inw a \ mwa a b
            inw b \ mwa b a
            inw i			
            lda $14 \ cmp #100
            bne loop
			
            jsr printf
            .by '% iterations',$9b,0
            dta a(i)
			
            jmp *
			
			.proc wait
				lda:cmp:req $14
				mwa #0 $13
				rts
			.endp			
			
			.link 'printf.obx'
> m 80
0080: CD A3 9A 47 9A 47 00 00 00 00 00 9E 93 00 00 00 

atari000.png

Edited by zbyti
formatting
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...