Binary files in basic, how ?

Page 2/3
1 | | 3

By WORP3

Paladin (804)

WORP3's picture

15-06-2010, 09:28

I just want to upload an 7K bin file to some i/o port, nothing more Big smile
And yes i did try the byte to byte method yesterday, just to see if it's working.
But even at 7Mhz the upload will take forever.

Will try that new method tonight Wink

I assume that each character inside the string is a 16 bits value and that the string pointer is pointing to the length of the string ? If not why are you adding +1 and +2 ?

I can reduce your example code as i read the file sequentially (from start to finish), so no need for that additional function Big smile

Thanks for the support mate, really appreciate it Wink

By NYYRIKKI

Enlighted (5382)

NYYRIKKI's picture

15-06-2010, 18:29

I assume that each character inside the string is a 16 bits value and that the string pointer is pointing to the length of the string ? If not why are you adding +1 and +2 ?

No, but close... We still live in 8bit world Tongue

Each character inside the string is 8bit value and varptr returns address of variable pointer. Variable pointer in case of string contains:
+0 lenght of string (64 in this case)
+1 lo address of start of string
+2 hi address of start of string

... when we add address of start of string and offset together we get address of data we want.

By WORP3

Paladin (804)

WORP3's picture

16-06-2010, 00:09

Thanks for the explanation mate Big smile
I just got the bin upload to work (with the mid$ command) and it will take about 40 seconds on a 7mhz msx, so that is not to bad.
Maybe i will try you idea somewhat later but for now i'm fine with the result LOL!

Cheers,
Tjeerd.

By NYYRIKKI

Enlighted (5382)

NYYRIKKI's picture

16-06-2010, 06:54

about 40 seconds on a 7mhz msx, so that is not to bad.

I don't think that we should talk about seconds on this kind of tasks...

... just to show you how easy this would be to solve in assembler... This is not even speed optimized, but it sure should not take a second even on 3.5MHz (sure it depends of the storage device you use)

;Usage: UPLOAD <filename.ext>
;
;Should compile on sjASM or similar... 
;Requires MSX-DOS, but easy to port as BASIC BIN-file if needed.

OUTPUT "UPLOAD.COM"

IOPORT:	EQU #00 ; I/O port where the data should be sent after load...


	ORG #100

	LD DE,#4000	;FREE SPACE
	LD C,#1A	;SET DATA TRANSFER ADDRESS
	CALL 5

	LD DE,#5C	;FCB

	LD C,#F 	;Open
        PUSH DE
	CALL 5
	POP DE
	
	LD HL,1
	LD (FCB+#E),HL

	LD HL,#4000
	LD C,#27	;Read all (but max 16K)
        PUSH DE
	CALL 5
	POP DE

	PUSH HL
	LD C,#10        ;Close
	CALL 5
	POP DE		;DE=Lenght of file = send all of the file

	LD HL,#4000
LOOP:
	LD A,(HL)
	OUT (IOPORT),A	;Send to device
	INC HL
	DEC DE
	LD A,D
	OR E
	RET Z
	JR LOOP
	

By WORP3

Paladin (804)

WORP3's picture

17-06-2010, 10:14

Yep i know, but doing it in assembly won't give a really good example for other developers, i'm using the basic file also as a resource/example file for others.
I did program a lot in assembly during my active msx years and i know that ML is far more efficient then basic Wink

By WORP3

Paladin (804)

WORP3's picture

29-10-2010, 22:10


LD DE,#5C ;FCB

LD C,#F ;Open
PUSH DE
CALL 5
POP DE

LD HL,1
LD (FCB+#E),HL

I was looking at you example code and i was wondering about something.
You use the parameter filename present from address 0x5C as a FCB, is this legally ?
Isn't this overwriting the second parameter space ?

I normally copy that filename into my own FCB and use that fb for opening my file, is there a reason that you do it this way ?

Cheers,
Tjeerd.

By NYYRIKKI

Enlighted (5382)

NYYRIKKI's picture

30-10-2010, 11:49


You use the parameter filename present from address 0x5C as a FCB, is this legally ?

Yes
Isn't this overwriting the second parameter space ?
Yes
I normally copy that filename into my own FCB and use that fb for opening my file, is there a reason that you do it this way ?
because this time I don't need to copy.

Quote from DOS2 environment manual:
The two FCBs set up at addresses 005Ch and 006Ch are valid unopened FCBs containing the first two command line parameters interpreted as filenames. If both filenames are to be used then the second one must be copied to a separate FCB elsewhere in memory because it will be overwritten when the first one is opened. See section 3.6 for the format of FCBs.

By WORP3

Paladin (804)

WORP3's picture

30-10-2010, 19:56

Thanks mate, i didn't know that, i always thought that you had to copy the filename to your own fcb, it seem's that i always can learn something Wink

Is that explanation you got there (msx2 dos manual) somewhere on the web ?

By NYYRIKKI

Enlighted (5382)

NYYRIKKI's picture

30-10-2010, 23:44

By WORP3

Paladin (804)

WORP3's picture

05-11-2010, 13:50

Mmm, it seems that their is an bug inside my msx-dos bios Sad
The filename is cut off when their is an '_' inside the parameter, when i give the following command inside msxdos: "a:\program fcb_test.txt" the bios will put only the letter "fcb" from address 0x5D, the rest is filled with spaces Sad
So i guess i have to do it myself using the complete parameter string present at address 0x80 !

Bummer Sad

Page 2/3
1 | | 3