Get drive free space

Anything QL Software or Programming Related.
User avatar
Andrew
Aurora
Posts: 795
Joined: Tue Jul 17, 2018 9:10 pm

Re: Get drive free space

Post by Andrew »

EmmBee wrote: I am suspecting you are really needing to use the function DEVICE_STATUS, where the file is not open yet.
No - I have checked with the file opend. My assembled code is not working. When calling the same function from Turbo Toolkit, it works.
I presume that it is not working because I did something wrong when I assembled it.
But it also might be that the code, as extracted by DEA, is not working.

That is why I asked for help - can someone assemble the code and check if it's working?
And if it is working please explain how you assembled it, to understand what was my mistake.


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Get drive free space

Post by dilwyn »

I haven't had time to look at the code itself, but one thing which strikes me from a quick glance is that the assembler code defines DEVICE_SPACE as a procedure, whereas I thought it was a function in Turbo Toolkit. If nobody has investigated further by tomorrow, I'll have a look at the code itself.


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Get drive free space

Post by dilwyn »

ds.zip
OK, curiosity got the better of me, so I did the minimal changes needed and assembled it. Luckily, I have the Computer One assembler on my system.

I only ran it on QPC2, not a QDOS system. The sequence OPEN #3,"filename" : PRINT DEVICE_SPACE(#3) : CLOSE #3 seems to work, although I haven't had time to check against the real drive capacity to see how correctly it works. It also seems to correctly do things like rejecting invalid parameters.

Did you extract this from turbo_tk_code or turbo_sms_code? I only ask because a quick glance at the assembler code shows a test for SMSQ version, didn't look at what it did (in case it was something that affected its ability to run on QDOS).

The attached zip file contains the ASM, CDE and LST file to help you see what I've done.


User avatar
Andrew
Aurora
Posts: 795
Joined: Tue Jul 17, 2018 9:10 pm

Re: Get drive free space

Post by Andrew »

dilwyn wrote:Did you extract this from turbo_tk_code or turbo_sms_code? I only ask because a quick glance at the assembler code shows a test for SMSQ version, didn't look at what it did (in case it was something that affected its ability to run on QDOS).
Thank you Dilwyn!
I extracted the code from turbo_tk_code


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Get drive free space

Post by dilwyn »

Played a little with it this morning. The amount of free space in bytes returned, divided by 512, seems to agree with the number of sectors returned by DIR on a drive, so looks like DEA successfully extracted the code; the only change needed was to change it from being a procedure to a function.

In case you plan to link it to a compiled program, you'll need a directive like this in QLiberator:
REMark $$asmb=win1_ds_cde,0,12

Or in Turbo:
REMark %%win1_ds_cde,0,12

Not actually tried this to test it, though.

The following notes are only intended to help you as you said you didn't have much experience of QL assembler.

In case it looks odd that I've defined "2" functions in the definition table in the assembler, it's just that as the keyword name is more than 7 characters long, it uses the formula on page 134 of the QL Technical Guide, to help you understand:
The 'approximate number' of procedures or functions is used to reserve internal table space. It should be exactly equal to the number of procedures or functions unless the average length of the procedure or function names exceeds 7, in which case it should be:
(total number of characters + number of functions or procedures+7)/8
So if you opt to rename the function "DEVICE_SPACE" to avoid a name clash with the Turbo version, e.g. to DEVSPC or a similar 7 character or less name, you might need to change that part of the assembler to something like this. I've put semi-colons in front of the comments as I think your C1 assembler needs them, not all 68K assemblers do.

Code: Select all

* FuNctions
dc.w 1            ;1 function
dc.w lab118ee-*   ;point to code start
dc.b 6,"DEVSPC"   ;name length+keyword name
dc.b 0            ;align to even address - omit if name is odd number of characters in length or use ALIGN directive
dc.w 0            ;end of functions
If you run into difficulties with this, I can create a new version for you with a new name to avoid a clash with Turbo Toolkit.
Last edited by dilwyn on Sat Jan 16, 2021 12:36 pm, edited 1 time in total.
Reason: Typos spotted after pressing SUBMIT


User avatar
Andrew
Aurora
Posts: 795
Joined: Tue Jul 17, 2018 9:10 pm

Re: Get drive free space

Post by Andrew »

dilwyn wrote:If you run into difficulties with this, I can create a new version for you with a new name to avoid a clash with Turbo Toolkit.
Thank you Dilwyn!


Post Reply