Are there any cheats for using BSAVE and BLOAD, or how to get the addresses they need, or can addresses be omitted ?

Por informn

Supporter (6)

imagem de informn

20-03-2020, 04:22

Are there any cheats for using BSAVE and BLOAD, or how to get the addresses they need, or can addresses be omitted ?

I am using the machine on Bluemsx, just labelled MSX .

I wrote a tiny 3D-demo program, in BASIC, and would like to convert the whole program to machine code, or, the slowest parts of the program to binary/machine-code, obviously to speed it up.

My 3D-demo is below for download .dsk .sta .cas
My 3D Demo

I have tried various stated save-from -- save-to memory-addresses on this site and numerous other sites, no luck, and have absolutely no idea of execution address , I know the execute address can be omitted .

I wrote a PEEK program to try view the memory, and then remembered / read that things are stored all over the place, not in the list format that the program is in, I will not be doing that again .

Easy Option Question
- So, couldn't I just save all the ram as a binary/machine-code file, and that would save everything, what would be the BSAVE command and the SPECIFIC / EXACT addresses to do that, or can addresses be omitted and it does things by default ?

Other Option Question
- Or, if I only want to save the slowest parts of my 3D-demo as binary/machine-code files and then insert the binary/machine-code files into my BASIC code of my 3D-demo, since they should run faster as binary/machine-code, how could I do that, theres no way I can determine the addresses ?
[ NOTE - I could just keep the slowest-parts of my program in memory, by erasing all the other line numbers in the program, and then BSAVE that as individual binary/machine-code files/programs to insert into the BASIC code of my original 3D-demo, however, theres no way I can get the required addresses, and don't know if any addresses can be omitted ( I know execute address can be omitted ) ]

Entrar ou registrar-se para comentar

Por NYYRIKKI

Enlighted (5506)

imagem de NYYRIKKI

20-03-2020, 07:42

informn wrote:

Are there any cheats for using BSAVE and BLOAD, or how to get the addresses they need, or can addresses be omitted ?

Mandatory for BLOAD is name and mandatory for BSAVE is name, begin and end address.
This program will read the addresses for you:

10 'Print BIN-file address info
20 LINE INPUT "Filename:";N$:OPEN N$ AS #1 LEN=7
30 FIELD #1,1 AS TP$, 2 AS BG$, 2 AS EN$, 2 AS ST$
40 GET #1:CLOSE
50 IF TP$<>CHR$(&HFE) THEN PRINT "Not a BIN-file":END
60 PRINT"Begin address: ";HEX$(CVI(BG$))
70 PRINT"End   address: ";HEX$(CVI(EN$))
80 PRINT"Start address: ";HEX$(CVI(ST$))
Quote:

Easy Option Question
- So, couldn't I just save all the ram as a binary/machine-code file, and that would save everything, what would be the BSAVE command and the SPECIFIC / EXACT addresses to do that, or can addresses be omitted and it does things by default ?

RAM looking from BASIC is located between #8000 and #FFFE, but MSX standard does not allow you to save and restore all of it as there are disk drive buffers, stack etc also there... For that kind of stuff I recommend using emulator "save state"-functionality. In BlueMSX you can find "Save CPU state" from "file"-menu.

Quote:

how could I do that, theres no way I can determine the addresses ?

I'm not quite sure what you are asking, but if you mean where you should put you machine language routines then best place is between end of your BASIC program variables and stack. Naturally those addresses are not fixed, but usually I tend to start ie. from #C000 ... If your BASIC program is relative small like now, I would say between #A000 and #D800 you may safely mess around as much as you like.

Por Dolphin101546015

Master (254)

imagem de Dolphin101546015

20-03-2020, 15:31

Try Kun-Basic first Wink

Por Grauw

Ascended (8917)

imagem de Grauw

20-03-2020, 17:20

I might have misunderstood you, but are you under the impression that with BSAVE you can compile parts of your MSX-BASIC program to machine code automatically? Because, it would be cool if it were, but that is not possible. You need to manually write the machine code parts in assembly language, then you can load them from MSX-BASIC using BLOAD and call ’em with DEFUSR / USR.

As Dolphin mentioned, if you want to speed up MSX-BASIC programs Basic-kun is a good choice.

Por NYYRIKKI

Enlighted (5506)

imagem de NYYRIKKI

21-03-2020, 05:43

Yes, indeed... How you save something does not have any magical effect to speed. You can use SAVE, BSAVE or pen and paper and the execution speed will be exactly same. It is also important to realize that MSX-BASIC is interpreted, not compiled language. In other words the BASIC it self does not generate any kind of machine code.

Quote:

I wrote a PEEK program to try view the memory, and then remembered / read that things are stored all over the place, not in the list format that the program is in, I will not be doing that again .

What you have seen is tokenized version of the BASIC listing. It is in order and represents the listing as is, but it has been just a bit "packed" to reduce memory consumption and to make interpreting a bit more easy... The known commands have been replaced with single byte that represents the command and so on... When you type a line, it will be stored in this format to memory and then when you ie. use LIST-command, it converts this tokenized stuff back to plain text. This is anyway just storage format, it is not executable code.