HP Forums
Why DEG? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Why DEG? (/thread-22400.html)



Why DEG? - toml_12953 - 09-26-2024 10:19 AM

In the following Nqueens benchmark, why is DEG used after the ISG and DSE statements? There are no trig functions in the program. If they're supposed to be NOPs, why not just use a register increment or decrement? I'm confused.

Code:
LBL "NQUEENS"
        TIME
        STO "T0"
LBL A   CLRG
        8 STO 11
LBL 00  RCL 00 RCL 11
        X=Y? GTO 04
        ISG 00 DEG
        STO IND 00
LBL 01  ISG 10 DEG
        RCL 00 STO 09
LBL 02  DSE 09 DEG
        RCL 09 X=0? GTO 00
        RCL IND 00 RCL IND 09 -
        X=0? GTO 03
        ABS RCL 00 RCL 09 -
        X<>Y? GTO 02
LBL 03  DSE IND 00 GTO 01
        DSE 00 GTO 03
LBL 04  RCL 10
        TIME
        RCL "T0"
        HMS-
        →HR
        3600
        ×
        RTN



RE: Why DEG? - rprosperi - 09-26-2024 11:55 AM

Just a guess, but I'd say DEG is being used as a NOP and it executes much faster than any register access or math operation, as it only sets some internal status bit(s).


RE: Why DEG? - Pekis - 09-26-2024 11:59 AM

(09-26-2024 11:55 AM)rprosperi Wrote:  Just a guess, but I'd say DEG is being used as a NOP and it executes much faster than any register access or math operation, as it only sets some internal status bit(s).

... and there won't be any [useful]line skip after the ISG or DSE op


RE: Why DEG? - dmh - 09-26-2024 12:45 PM

It is used as a NOP.

I tried changing it to a synthetic NOP to see if it was much faster but it wasn't much different.

(09-26-2024 11:55 AM)rprosperi Wrote:  Just a guess, but I'd say DEG is being used as a NOP and it executes much faster than any register access or math operation, as it only sets some internal status bit(s).



RE: Why DEG? - brouhaha - 09-26-2024 10:41 PM

(09-26-2024 10:19 AM)toml_12953 Wrote:  If they're supposed to be NOPs, why not just use a register increment or decrement?

What specific instruction(s) are you suggesting for "register increment or decrement"? On most HP RPN calculators, ISG/DSE are the fastest register increment and decrement, and the only ones that don't affect the stack. Having to use a NOP of some sort after, if you don't use the conditional execution of the next line, is a small price to pay.


RE: Why DEG? - toml_12953 - 09-27-2024 12:36 AM

(09-26-2024 10:41 PM)brouhaha Wrote:  
(09-26-2024 10:19 AM)toml_12953 Wrote:  If they're supposed to be NOPs, why not just use a register increment or decrement?

What specific instruction(s) are you suggesting for "register increment or decrement"? On most HP RPN calculators, ISG/DSE are the fastest register increment and decrement, and the only ones that don't affect the stack. Having to use a NOP of some sort after, if you don't use the conditional execution of the next line, is a small price to pay.

1
STO+ 00

or

1
STO- 00


RE: Why DEG? - xerxes - 09-27-2024 02:27 AM

(09-26-2024 10:19 AM)toml_12953 Wrote:  In the following Nqueens benchmark, why is DEG used after the ISG and DSE statements?

Using ISG/DSE or ISZ/DSZ is a small optimization, because normally it's faster than 1 STO+/-.
As brouhaha stated, DEG (NOP) is necessary to suppress a skip.


RE: Why DEG? - Didier Lachieze - 09-27-2024 05:08 AM

(09-27-2024 12:36 AM)toml_12953 Wrote:  1
STO+ 00

or

1
STO- 00

This disturbs the stack by leaving 1 in X and T content is lost. So not a direct replacement for ISG 00 DEG or DSG 00 DEG.