Coding Query

Anything QL Software or Programming Related.
Post Reply
User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Coding Query

Post by Mr_Navigator »

The following:

Code: Select all

2650  FOR n= 0 TO 1200 STEP 2
2660   byte=PEEK(n+anf)
2670    IF byte >63 THEN byte=byte-64
2680    IF byte >15 THEN byte=byte-16
2690    IF byte >3 THEN byte=byte-4
2700    IF byte >0 THEN byte=byte-1
2710  POKE n+anf,byte
2720 NEXT n
is in a program I am looking at at the moment to try and get my rusty skills going again.

I have already found numerous errors and corrected them which is very pleasing, and the program seems to run OK without this bit included.

The variable anf is a respr value,
The code was found outside of any def procs on its own in the middle of the listing and I think the originator was testing the possible reversal of a graphic in a graphical program, at least that's what it appears to me.

However aesthetically the line

Code: Select all

2710  POKE n+anf,byte
should be written

Code: Select all

2710  POKE anf+n,byte
then I got to thinking, this code is 'called' from the start

Code: Select all

100 anf=RESPR(7200)
110 LBYTES flp1_sprsys_bin,anf:CALL anf:anf=anf+4
so unless that anf+4 bypasses significant machine code, the routine would just mash it up and make it unusable, perhaps he/she was testing out a form of protection??? I don't know as my m/c assembler, C etc. skills are non existent.

Any comments?

btw I think have found an interesting feature / bug in SMSQe on QemuLator in MODE 8 that I wasn't aware of, after some more testing I will post.


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
tofro
Font of All Knowledge
Posts: 2700
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Coding Query

Post by tofro »

Mr_Navigator,

answering your question would mean guessing what the machine code loaded at "anf" is.

Let's for the moment assume it's implementing an S*Basic extension - In this case the code linking in the extensions can savely be overwritten - It only needs to be intact once, when the basic commands are made known to QDOS - when a new command is executed, QDOS calls it directly - And the code for those commands could (well, must) be well behind the anf+4+1200 bytes area apparently used for some table.

Obviously, in order to work, there may not be any CALL into anf up to anf+4+1200 after he's been fiddling around with the data. The 4 bytes reserved at the beginning don't have enough room for an instruction to jump over 1200 bytes (would only be enough for a short branch, and that can only jump within a range of +- 128 bytes.)

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply