PDA

View Full Version : Interpret these Commands




peterk
19 Sep 2009, 09:16 AM
Hi all, I can work my way through dvd commands but these ones I don't understand. Can someone please explain what these example instructions mean and how the result was achieved?

set gprm(4) =(mov) 268
if gprm(4) & 65280 then goto line 5 -> reply....(268 & 65280) : true
set gprm(6) =(mov) gprm(4) -> reply....gprm(6) = 268
set gprm(6) /=(div) 256 -> reply....gprm(6) = 1
set gprm(4) &=(and) 255 -> reply....gprm(4) = 12

Set gprm(0) =(mov) sprm(5:Title number in VTS) -> reply gprm(0) = 1
set gprm(0) *=(nul) 256 -> reply.... gprm(0) = 256
Set gprm(0) |=(or) sprm(7:Chapter number (or PGN)) -> reply gprm(0) = 257

It is the symbols I guess that need clarification and how to apply them but with the above example it sould shed some light on my problem.
ie, &; /=; &=; *=; l=;
I have also seen +; etc amongst others

Thankyou

blutach
19 Sep 2009, 01:34 PM
The first command sets register 4 to be equal to 268
The second tests whether the value logically AND'ed with 65280 results in a non-zero number (it does and is equal to 256, so we branch to line 5).
The third copies the value in register 4 to register 6 overwriting what's in register 6 in the process.
The fourth divides what's in register 6 by 256. Since registers can only carry integers, the answer is 1 (in other words the remainder of 12 is ignored). I bet this sets the title number.
The next logically ANDs what's in register 4 (268) with 255 and results in 12 (I bet this sets the chapter number).

Set gprm(0) =(mov) sprm(5:Title number in VTS) -> reply gprm(0) = 1
This copies the title number in the VTS (which is sprm(5)) to register 0. In this case, you are playing the first title in the VTS.
set gprm(0) *=(mul) 256 -> reply.... gprm(0) = 256
This multiplies what's in register 0 by 256, to get an answer of 256.
Set gprm(0) |=(or) sprm(7:Chapter number (or PGN)) -> reply gprm(0) = 257This logically ORs what's in register 0 with the current chapter number. In this case, you are playing chapter 1 because the result is 257. If you were playing chapter 6, the result would be 262, etc.

Those symbols mean logical AND (in a conditional statement), divided by, AND (in a set statement), multiply and logical OR. But just use the mnemonics in PgcEdit for ease. It also pays to install the Hex bit operands plugin by M_Knox which makes understanding AND and OR operations a breeze. It's on the PgcEdit site or just click here (http://download.videohelp.com/r0lZ/pgcedit/plugins/hexbitoperands_plugin_v08.zip).

Regards

peterk
19 Sep 2009, 04:11 PM
Thanks a lot blutach for making the time for the explanation
Studying your answer I can see that your assumption about the titles/chapters is correct

I assume that these instructions are based on binary math.

if gprm(4) & 65280 then goto line 5 -> reply....(268 & 65280) : true
This tests whether the value logically AND'ed with 65280 results in a non-zero number (it does and is equal to 256, so we branch to line 5).

binary for 65280 is.....and 268 is.....and the binary total is 256 as you said

01111111100000000 +
00000000100001100
--------------------
00000000100000000

Where did the value of 65280 come from do you think. (I'm looking at 13 chapters, no correllation here, I think)

Does the "&" function always have a True result for a non-zero answer. Won't the result always be non-zero unless it is AND'ed to 255 in this example?

In my navigation I can't see the significance of the values 255 and 256. Any insight?

blutach
19 Sep 2009, 04:38 PM
65280 is decimal for the hex FF00. So what it is testing for is any bit higher than bit 7 (they start numbering at the right and this is called bit 0). So basically, it is looking for numbers higher than 255 and branching over a command if true.

Yes, AND is true is the result is non-zero, false otherwise.

Regards

peterk
19 Sep 2009, 04:46 PM
I'll just take your word on that, thanks

r0lZ
20 Sep 2009, 04:45 PM
It is frequent to find that kind of authoring in commercial DVDs. They store in the same GPRM the title number AND the chapter number:

Set gprm(0) =(mov) sprm(5:Title number in VTS)
set gprm(0) *=(nul) 256
Set gprm(0) |=(or) sprm(7:Chapter number (or PGN))

The title number is stored in gprm(0) and then gprm(0) is multiplied by 256 (0x100). That means that the title number occupies now the 8 upper bits of the gprm.
Finally, the chapter number is stored in the 8 lower bits of the gprm.

GPRM 0 can then be used to retrieve the title and chapter number, by doing the opposite:

set gprm(6) =(mov) gprm(0)
set gprm(6) /=(div) 256
set gprm(0) &=(and) 255

Since we need 2 values, it is necessary to copy the gprm containing the title and chapter numbers to a temporary gprm that will hold the title number. In this case, it's gprm(6).
Then, gprm 6 is divided by 256. Since it's an integer division, that has the effect to move the 8 upper bits to the 8 lower bits (and to clear the upper bits). Now, the title number is in gprm(6).
Finally, the 8 upper bits of the original gprm are cleared by the AND operation, to clear the title number, and leave only the chapter number.

The notation /=, *=, &=, |= etc., are common in the programming languages. The programmers are lazy people :), and they prefer to write short lines of code. So, for example, "X /= 256" is equivalent to "x = x / 256". Similarly, in PgcEdit, "set gprm(0) /=(div) 256" means "set gprm(0) = gprm(0) / 256".

As blutach has suggested, I highly recommend to install the hexbitoperands plugin, especially if you are not comfortable with decimal to hexadecimal conversions or with binary operations.

peterk
24 Sep 2009, 03:59 PM
Thanks to blutach and r0LZ for making this clear

peterk
26 Sep 2009, 09:58 AM
Just to continue on the commands theme when setting gprm's and then if/goto's are to be executed I have noticed that some gprm's contain values in the 20's or 30's range of digits. It would serve the same purpose if values in the range 1-10 were to be used for example, after all, they are only branching instructions.

Is this just a convention so that it enables easy visibility whilst tracing or is there some standard that requires it this way?

blutach
26 Sep 2009, 02:16 PM
Usually, but not always, the values reflect the (original) title numbers. There is no convention. Leave these alone!

Regards