Turbo Pascal PopolonY2k's Framework

Страница 2/5
1 | | 3 | 4 | 5

By popolony2k

Hero (544)

Аватар пользователя popolony2k

22-06-2016, 18:57

@rolandve, you can find the official Turbo Pascal 3 manual from Borland, googling on internet. I bought this book in 2012 at Amazon and surprisingly it was brand new, I think that this book was well stored because there's no any old yellow pages marks. Here is the link I found googling http://bitsavers.informatik.uni-stuttgart.de/pdf/borland/tur...

About the Inc procedure, it was added since Turbo Pascal 4 but could be added to Turbo Pascal3 writing code in Turbo Pascal or even in ASM through Inline call.

The Inc routine described by you could be written as described below:

Procedure Inc( Var nValue );
Begin
  Inline( $2A/nValue/      { LD HL, (nValue)  }
          $34              { INC(HL)          } );
End;

Try this code and it will work fine (for integer operands, for byte operands too but don't forget the limits of a Byte :) )

I'm used to assembly code using Inline calls directly in Turbo Pascal but after I discovered the excellent tool created by Hans Otten in 1986, known as INLASS, my life changed forever :).
INLASS is capable of assembly code written directly in ASM, generating Turbo Pascal Inline calls. This is very cool because you can create long jumps, relative jumps, conditional jumps in your ASM code easily and the INLASS can manage this perfectly well. I'm using INLASS since the last year and I'm really impressed with this tool. This is a kind of tool which you never can forget when you're creating things for MSX in Turbo Pascal.

Check about INLASS here http://msx.hansotten.com/index.php?page=msxpascal
The INLASS documentation can be found here http://pascal.hansotten.com/uploads/msx/inlass.pdf
A good web site with the complete Z80 instruction set can be found here http://nemesis.lonestar.org/computers/tandy/software/apps/m4...

[]'s
PopolonY2k

By AxelStone

Prophet (3199)

Аватар пользователя AxelStone

22-06-2016, 22:52

Impressive tool, really a jump forward. I see that Turbo Pascal is really a mature language for use, when I used it a lot of years ago I only had TP 3.0 and Borland manual. Nowadays, practically you can do anything Smile

By rolandve

Champion (372)

Аватар пользователя rolandve

24-06-2016, 11:33

Everything is possible if you know how to code in assembly Smile Until now, I ran in to the following issues:
- Mmmm, function doesn't exist is TP3, is there is Library that does the same thing (and where)
- Mmmm, that include file also has a function called XXXYZ and it behaves different from that library so you can't just mix libraries.
- Documentation of the library is not always up-to-standard. Popolony's libraries are OK, others are not, so you are forced to read the source (good luck, not always decently structured).
- Libraries are not consistent. For example (I believe its Kali's) code has a write to vram function where you can store blocks of data in vram by using (location, amount and character). Reading however: (location, amount and address).
- TP quits after 1 error, correcting the error, recompile and finding the next is really annoying.
- sometimes things are impossible if you do not speak assembly, because nobody ever had a need for that capability. (After all a library is made by someone when he/she has need).

This is not complaining: it comes with the fact that your trying to write code for 33 year old systems, but it is annoying and keeps people from programming because you spend more time debugging/collecting/finding/rewriting than doing your own coding. Thats when people either decide to quit or create a n' th version of a library. After all, when a hobby starts to hurt, people stop.There is a positive thing: the people here are really helpful Smile

By AxelStone

Prophet (3199)

Аватар пользователя AxelStone

24-06-2016, 12:14

rolandve wrote:

This is not complaining: it comes with the fact that your trying to write code for 33 year old systems, but it is annoying and keeps people from programming because you spend more time debugging/collecting/finding/rewriting than doing your own coding. Thats when people either decide to quit or create a n' th version of a library. After all, when a hobby starts to hurt, people stop.There is a positive thing: the people here are really helpful Smile

You are right, in MSX-C there is a similar problem. However is a fact that coding for 33 years old system is slower since you don't have same resources to debug / test your code. Anyway I think that compiled languages are the future of MSX programming. We only need to be a little more organiced and, as you say, developed libraries should be correctly documented.

The big advantage of compiled languages is it's "lib oriented programming" that allows you to reutilize them (I mean reuse lib, not reuse code with copy paste). In a near future, I'm sure there will be more people using TP / MSX-C

By rolandve

Champion (372)

Аватар пользователя rolandve

24-06-2016, 15:54

@AxelStone, thats one thing I haven't seen in MSX yet. The equivalent of DLL's.
Another thing, I will not see happen soon is being organised. Most people around here, have no intent to spend much time on MSX related business. They have their pet projects and thats it.

Having said that, I would contribute my time to creating new TP3 libraries for Pacal that combine and extend the currently available libraries.

By popolony2k

Hero (544)

Аватар пользователя popolony2k

24-06-2016, 16:39

Hi friends.

I have the same opinion of you about the consistency of current libraries but in the most cases these libraries have been made since 20 years ago and in those days the information about the MSX standard were not available easily (I remember when I started my Framework in the university), so were hard to get some consistent information to know if the code could work in all MSX computers.
In my case, since 2011 I'm adding new features for newer MSX devices, fixing old bugs or even trying to make the framework a little bit more modern, like newer PC's libraries framework.
About the documentation, this is the reason I writing code well documented and ready to be documented by a documentation tool like JavaDoc or Doxygen. My framework is 100% doxygen ready. After the next realease I'll create an area at my http://www.popolony2k.com.br website with the latest updated documentation generated by DoxyGen, of my libraries.
I really like the Kali's library and I studied it sometimes and are very well done, but in several functions I realized that he used some "techniques" not optimized or that could be resolved just using the Z80 instead the MSX standard that sometimes is a little bit slower than just using the power of the processor. But this was an attempt made 20 years ago or more and still today is impressive.
In fact my plans for framework is that it will be a complete framework for MSX, covering all existing technologies for this standard, so using Kali's library in the future will be only another option that you can choose and maybe unnecessary because PopolonY2K's framework will be a complete library set.

[]'s
PopolonY2k

By popolony2k

Hero (544)

Аватар пользователя popolony2k

24-06-2016, 16:49

@rolandve, about a feature like DLL, very soon will be possible to create things very close to a dll using my framework. I have coded a solution for this, not so open as Windows DLL or Linux SO (Shared Objects) but will help a lot when you're trying to create a non monolithic software with loadable modules, using better the memory area that is limited even when you're using extended memory devices like Memory Mapper or MegaRAM.

Another good technology which I already have implemented is the possibility to add support of to use Memory Mapper (and MegaRAM in the future). I already have ready here, implementations for using Mapper through the standard mapper functions and directly (this is the best way for me because is faster than stardard mapper functions).

[]'s
PopolonY2k

By rogermm

Master (130)

Аватар пользователя rogermm

24-06-2016, 17:45

rolandve wrote:

@AxelStone, thats one thing I haven't seen in MSX yet. The equivalent of DLL's.
Another thing, I will not see happen soon is being organised. Most people around here, have no intent to spend much time on MSX related business. They have their pet projects and thats it.

FUZIX is planning to support DLL's(It runs on MSX and other platforms) and a CPM emulation engine(untested) on Z80, so it can run Turbo Pascal : https://github.com/EtchedPixels/FUZIX/tree/master/Kernel/cpm... . The Fuzix DLL cannot be used on Turbo Pascal thown, only native FUZIX applications compiled on SDCC(C compiler that run on PC) can use DLL

By rolandve

Champion (372)

Аватар пользователя rolandve

24-06-2016, 20:33

Hi Popolony2k,
DLL's can be implemented in simple ways or complex ways Smile
The easiest way, I imagine in just the assembly, located at some address in memory. A load routine places it there, can be in a memory mapper of the current memory block, depending on the size Smile

Because the loader routine knows, where the code is loaded, it can jump there. The jump routine is the routine where the user gives the memory address of the parameters expected by the routine and then the processor jumps to the loaded routine, knowing where to store its result and where to jump when done.

struct lib_parameters {
     register.a = &H3000
     register.x = &H13
}

Load_Library('a:\sdk\pascal\screen.lib',segment, address);
Call (@lib_parameters, address);

What is more problematic is:
- DLL's calling other DLL's. Something you should not do, because there is no guaranty that memory will not be overwritten. After all, the creator of the dll can do al kinds of nasty things..
- Versioning (aka as DLL hell) and associated upward compatibility
- Loading & unloading: since the compiler has no support for this (thus no dynamic), loading and unloading has to be done by the user.
- Message passing: the DLL probably does something and leaves a result. This result should be available to the calling code when the dll is done.

However, far more complex and large programs can be written, when external libraries of code can be called and executed on demand. I love to think with you. My assembly is non existent so I my practical value is 1/X.

By rogermm

Master (130)

Аватар пользователя rogermm

24-06-2016, 21:54

rolandve wrote:

Hi Popolony2k,
DLL's can be implemented in simple ways or complex ways Smile
The easiest way, I imagine in just the assembly, located at some address in memory. A load routine places it there, can be in a memory mapper of the current memory block, depending on the size Smile

Because the loader routine knows, where the code is loaded, it can jump there. The jump routine is the routine where the user gives the memory address of the parameters expected by the routine and then the processor jumps to the loaded routine, knowing where to store its result and where to jump when done.

struct lib_parameters {
     register.a = &H3000
     register.x = &H13
}

Load_Library('a:\sdk\pascal\screen.lib',segment, address);
Call (@lib_parameters, address);

What is more problematic is:
- DLL's calling other DLL's. Something you should not do, because there is no guaranty that memory will not be overwritten. After all, the creator of the dll can do al kinds of nasty things..
- Versioning (aka as DLL hell) and associated upward compatibility
- Loading & unloading: since the compiler has no support for this (thus no dynamic), loading and unloading has to be done by the user.
- Message passing: the DLL probably does something and leaves a result. This result should be available to the calling code when the dll is done.

However, far more complex and large programs can be written, when external libraries of code can be called and executed on demand. I love to think with you. My assembly is non existent so I my practical value is 1/X.

Well done. The SDCC compiler that is used on FUZIX, was patched to be able to manage memory banks (https://github.com/EtchedPixels/FUZIX/tree/master/Kernel/pat...). I think the same can be done to manage DLL in a more complex/efficient way, as you pointed out. Since the Turbo Pascal is a closed box, I think it cannot be done in this way as you pointed out too.

Страница 2/5
1 | | 3 | 4 | 5