Jump to content
IGNORED

Mad Pascal


Recommended Posts

Hi!

 

.

 

The provided mp.pas source has an error, I don't know if the posted EXE cames from the same source. In line 16945, changes the "j" inside the function call to "i", so the line changes from:

j := CompileConstFactor(j, ConstVal, ConstValType);
to read:

j := CompileConstFactor(i, ConstVal, ConstValType);
.

 

Without this, the program fails depending on the uninitialized value of "j". Also, another error on line 23193, change "i" to "j" on the Error call, the line must read:

         Error(j, 'Unresolved forward declaration of ' + Ident[j].Name);
.

 

After that, compile with " fpc -MDelphi -Os -Xi -Xs -XX mp-155.fix.pas " to get a working executable.

 

 

 

Thanks a lot for the quick reply, it works now.

 

Now I'm stuck with the workflow on how to create an Atari executable.

 

I compile the Pascal source with mp sourcename.pas, this creates an sourcename.a65 , which is Mads assembler if I'm correct.

 

Then I should create the executable with : mads source name.a65 , correct ?

 

I'll have another look at the mads documentation also.

Link to comment
Share on other sites

mads filename.a65 -x -i:base

\base\ is MP folder

 

 

 

Thanks, it kept failing until I figured out that you have to give the absolute filepath to the base folder.

Mads & Mad Pascal is absolutely fabulous, all the examples included will provide me with a lot of learning material , loving it.

Link to comment
Share on other sites

  • 1 month later...

Question / idea:

 

asm {} block is fantastic and stuff and I see only one serious drawback of using it on a wider scale - Pascal code can not access asm labels / addresses. It is fully understandable, it is just a foreign body in a Pascal source code.

maybe it could be possible to define variables in Pascal as placeholders for asm variables, so when the code gets to be assembled by MADS, the variables are naturally recognised and used in assembly. No really good example on hand, but I had this idea:

var
dl_addr1 : word; //?????? pointer?


//display list internals
asm{
    .by $41
dl_addr1 .word scr
}

so dl_addr1 could be accessed directly in Mad Pascal.

 

Is such a construct possible already? If not, would it be possible to have it added?

Link to comment
Share on other sites

Don't be so self critical, that could work 2 years ago :)

In previous versions of MP, there was no distinction between public and private methods.

It was introduced in version 1.4.5, on my personal request as far as I remember ;)

Yeah, but I could have researched that. Or open my eyes, because the samples have the interface declaration ;-)

BTW, shouldn't the missing interface be flagged as error?

Link to comment
Share on other sites

var dst: word absolute $8000;

procedure test; assembler;
var src: word absolute $4000;
asm
{
lda src
sta dst
lda src+1
sta dst+1

mwa #111 src
};
end;

function test2: word; assembler;
asm
{
lda MAIN.TEST.src
sta Result
lda MAIN.TEST.src+1
sta Result+1
};
end;

begin
test;
writeln(test2);
end.
Edited by tebe
Link to comment
Share on other sites

 

How about:

var dl_arr1: word asm = $4000; # Adress is optional.
asm {
  sta dl_arr1
}

 

Yes, this way it is easy, I was rather thinking about being able to DPoke(dl_addr1, scr2); from Pascal so it changes the value inside the asm{} block.

But I need to analyse TeBe's example, possibly it is what I wanted, just do not understand it on a first glance.

Link to comment
Share on other sites

Hi!

Thanks again for the example, I was not clear enough, but I meant something like in the example below - way to access variables that are defined inside ASM{} block.

The code below compiles, but obviously does not work as MP does not know what "src_mod" is. Proposal: define it like this

var src_mod: word asm_placeholder;

and pass just the label "src_mod" itself without any value to MADS, that would be able to compile it using correct address.

 

I understand it might be impossible, just asking.

var src_mod: word; //???

procedure test; assembler;
var src: word absolute $4000;
asm
{
src_mod 
    lda #111
    sta src     
};
end;

function test2: word; assembler;
asm
{
 lda MAIN.TEST.src
 sta Result
 lda MAIN.TEST.src+1
 sta Result+1
};
end;

begin
 test;
 writeln(test2);
 Poke(src_mod+1,112);
 writeln(test2);
end.
Edited by pirx
Link to comment
Share on other sites

It's possible to access asm labels, but you have to write some kind of 'accessor function' ;)

 

Not very convenient, especialy when you wish to access plenty of labels... but still possible.

function test:byte; assembler;
asm {
mylabel
    lda #123
    sta result
};
end;
 
function mylabel:word; assembler;
asm { mwa #test.mylabel result }; 
end;

begin
    writeln(test); // 123
    poke(mylabel+1, 33);
    writeln(test); // 33 ! 
    Readkey;
end.

Edited by bocianu
Link to comment
Share on other sites

Hi.

 

This doesn't seem to be supported at the moment. Am I correct?

type
  Vector = object
    function add(x, y: Vector): Vector;
  end;

FreePascal uses this syntax for classes:

type
  Vector = Class;
  Vector = Class
    function add(x, y: Vector): Vector;
  end;

Is it possible to implement something like that?

Edited by JoSch
Link to comment
Share on other sites

  • 2 weeks later...

MadPascal 1.5.6

 

http://mads.atari8.info

- SYSUTILS: Click
- SYSTEM: Sqrt(Integer): Single
- MATH: Sign
- added new functionality, function returns result by its name, previously only through the variable RESULT
- adding support for STRING arrays (example /games/tower.pas)
- new directive {$LIBRARYPATH path1;path2;...}
- new library BLIBS
- PASDOC (https://gitlab.com/bocianu/pasdoc)
(* source: CLSN PASCAL            *)
(* This program uses a mutually   *)
(* recursive routine to calculate *)
(* the number PI                  *)
 
uses crt;
 
function a(t: byte): single; forward;
 
function b(n: byte): single;
begin
  if (n=0) then
    b:=1/sqrt(2)
  else
    b:=sqrt(a(n-1)*b(n-1));
end;
 
function a(t:byte): single;
begin
  if (t=0) then
    a:=1
  else
    a:=(a(t-1)+b(t-1))*0.5;
end;
 
function d(n: byte): single;
var
  j: byte;
  s: single;
begin
  s:=0;
 
  for j:=1 to n do
    s:=s+(1 shl (j+1))*(sqr(a(j))-sqr(b(j)));
 
  d:=1-s;
end;
 
function x_pi: single;
const
  level=2;
 
begin
  x_pi:=4*a(level)*b(level)/d(level);
end;
 
begin
  writeln('PI=',x_pi);
 
  repeat until keypressed;
end.
Edited by tebe
  • Like 3
Link to comment
Share on other sites

  • 4 months later...

Mad Pascal 1.5.8, http://mads.atari8.info

 

 

- GRAPHICS: Font, FontInitialize, FillRect, TextOut, TextWidth, MoveTo, LineTo
- SYSTEM: FileMode (RESET), [fmOpenRead, fmOpenWrite, fmOpenAppend, fmOpenReadWrite]
- {$info user_defined}, {$warning user_defined}, {$error user_defined}, {$include filename}, {$resource filename}
- PROGRAM (par1, par2 ...)
- MAIN.@DEFINES.name
  • Like 4
Link to comment
Share on other sites

  • 7 months later...

MadPascal 1.6.0, http://mads.atari8.info

 


- SYSTEM: TDateTime
- GRAPH, FASTGRAPH: Arc, PieSlice, TLastArcCoords, LastArcCoords
- SYSUTILS: Now, Date, DateToStr, DecodeDate, DecodeDateTime, DecodeTime, EncodeDate, EncodeDateTime, EncodeTime, IsLeapYear, BoolToStr, StrToBool
- STRUTILS: AddChar, AddCharR, PadLeft, PadRight
- dodana obsługa {$INCLUDE %DATE%}, {$INCLUDE %TIME%}, https://www.freepascal.org/docs-html/prog/progsu41.html
- -CODE:, -DATA:, -STACK:, -ZPAGE: without '$' mark

  • Like 5
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...