Page 11 of 13
Re: MDV Low Level Routines
Posted: Tue Aug 09, 2016 1:27 pm
by Martin_Head
tcat wrote:Tobias, Martin,
Thank you, now to the last block allocated, FDFD value in the map, does not seem right, or perhaps I cannot interpret it correctly?
I can also imagine, that some copy protection may obfuscate this value?
Many thanks
Tomas
I think it's just one byte of the last word in the map that is used (not sure if it's the upper, or lower byte).
So if file 05 was the last one written, I would have expected either $4D00 or $004D in the last word of the map.
You might want to look at some other image files to see if they make sense.
I suppose, in theory, the operating system would not need to actually write out that last word of the map to the microdrive cartridge. But I can't think why it would not.
Martin Head
Re: MDV Low Level Routines
Posted: Thu Sep 08, 2016 9:26 pm
by tcat
Hi,
I am now toying with dumping, the reverse task to MDV copying. My code seems doing things, but I am looking into ways of possible optimisation of the two assembly snippets down here, in the hope to get shorter execution in between gaps.
ONE
Code: Select all
sec_cont suba.l #514,a1 ;Point Image Ptr to File-Blk
move.b d1,(a1)+ ;Record File Number
move.b d2,(a1)+ ;Record Block Number
adda.l #514,a1 ;Reset Image Ptr
;Make room for check sum
jsr cnt_dwn ;Count down and read next
bra.s sec_loop
TWO
Code: Select all
red_fail movea.l bad,a0 ;Recover Bad Ptr list
move.b d7,(a0) ;Mark failing sector
lea bad,a0 ;Increment Bad Ptr
addq.l #$01,(a0)
movea.l image,a1 ;Reset Image Ptr
bra.s sec_loop ;Read next sector
Many thanks in advance
Tomas
Re: MDV Low Level Routines
Posted: Thu Sep 08, 2016 9:54 pm
by RWAP
Just a couple of things spring to mind (bearing in mind I could not find my book which has the time taken to undertake each command):
a) Suba and Adda are quite slow - you are better storing the value of A1 temporarily
b) Can you not combine D1 and D2 and write a word to (A1)+ - that is quicker than two MOVE.B commands with post increment
Re: MDV Low Level Routines
Posted: Fri Sep 09, 2016 6:52 am
by M68008
If for 'gaps' you mean the Microdrive gap, they are relatively long. 2.8 ms according to the "QL advanced guide", probably enough for at least a thousand instructions at 7.5 MHz
Re: MDV Low Level Routines
Posted: Fri Sep 09, 2016 8:04 am
by tcat
Hi,
Thank you all for your suggestions, while I might be well within gap timings, I wish to learn to write a neater code.
Can this work with negative offset?
ONE (a)
Code: Select all
sec_cont move.w #-514,d3 ;Offset(-) to File-Blk
move.b d1,$00(a1,d3.w) ;Record File Number
move.b d2,$01(a1,d3.w) ;Record Block Number
addq.l #$02,a1 ;Make room for check sum
jsr cnt_dwn ;Count down and read next
bra.s sec_loop
ONE (b)
Code: Select all
sec_cont move.w #-514,d3 ;Offset(-) to File-Blk
lsl.w #8,d1 ;d1=File-no
or.w d1,d2 ;d2=File-no+Blk-No
move.w d2,$00(a1,d3.w) ;Record File-no+Blk-No
addq.l #$02,a1 ;Make room for check sum
jsr cnt_dwn ;Count down and read next
bra.s sec_loop
Tomas
Re: MDV Low Level Routines
Posted: Fri Sep 09, 2016 4:34 pm
by Martin_Head
In the first example, If you kept a register always pointing at the start of the buffer/sector, say A5. Then you would not have to keep resetting your image pointer
Code: Select all
sec_cont move.b d1,15(a5)
move.b d2,16(a5)
jsr cnt_dwn
bra.s sec_loop
(The offsets I used may not be right for you)
Re: MDV Low Level Routines
Posted: Sat Sep 10, 2016 5:46 pm
by mk79
tcat wrote:Hi,
ONE (b)
Code: Select all
sec_cont move.w #-514,d3 ;Offset(-) to File-Blk
lsl.w #8,d1 ;d1=File-no
or.w d1,d2 ;d2=File-no+Blk-No
move.w d2,$00(a1,d3.w) ;Record File-no+Blk-No
addq.l #$02,a1 ;Make room for check sum
jsr cnt_dwn ;Count down and read next
bra.s sec_loop
Tomas
You can leave out the move.w completely:
Code: Select all
sec_cont lsl.w #8,d1 ;d1=File-no
or.w d1,d2 ;d2=File-no+Blk-No
move.w d2,-514(a1) ;Record File-no+Blk-No
addq.l #$02,a1 ;Make room for check sum
jsr cnt_dwn ;Count down and read next
bra.s sec_loop
I guess variant B with only one memory access is probably faster.
Marcel
Re: MDV Low Level Routines
Posted: Mon Sep 12, 2016 9:47 am
by tcat
Hi,
Thank you, this helps.
How about the snippet TWO, any room for optimisation?
Coded in C language
*bad++ = d7;
Code: Select all
red_fail movea.l bad,a0 ;Recover Bad Ptr list
move.b d7,(a0) ;Mark failing sector
lea bad,a0 ;Increment Bad Ptr
addq.l #$01,(a0)
movea.l image,a1 ;Reset Image Ptr
bra.s sec_loop ;Read next sector
Tomas
Re: MDV Low Level Routines
Posted: Mon Sep 12, 2016 10:11 am
by mk79
tcat wrote:Hi,
Thank you, this helps.
How about the snippet TWO, any room for optimisation?
Coded in C language
*bad++ = d7;
Code: Select all
red_fail movea.l bad,a0 ;Recover Bad Ptr list
move.b d7,(a0) ;Mark failing sector
lea bad,a0 ;Increment Bad Ptr
addq.l #$01,(a0)
movea.l image,a1 ;Reset Image Ptr
bra.s sec_loop ;Read next sector
Code: Select all
red_fail movea.l bad,a0 ;Recover Bad Ptr list
move.b d7,(a0)+ ;Mark failing sector
move.l a0,bad
movea.l image,a1 ;Reset Image Ptr
bra.s sec_loop ;Read next sector
Of course it would help even more if you can keep the bad-pointer in a register somewhere, any memory access is having a big impact. But snippet for snippet I think this is at least slightly better.
Cheers, Marcel
Re: MDV Low Level Routines
Posted: Mon Sep 12, 2016 12:12 pm
by tcat
Hi Marcel,
I am afraid on MC68008, storing values to effective address is not possible, as the effective address has to be loaded first. While I believe on later MC processors it is allowed.
on MC68008 above come as two instructions
Tomas