r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[rebcode] Rebcode discussion

Steeve
23-Feb-2007
[1939x2]
for example, if i want to test the 7th bit , i do
and  var 128
ift [ do the job]
instead of doing
and var 128
eq.i var 128
ift [ do the job]
BrianH
23-Feb-2007
[1941]
Whae does SETT do here?
Steeve
23-Feb-2007
[1942x2]
sett ?
you mean
BrianH
23-Feb-2007
[1944]
It sets the T flag based on the contents of a variable. I think it 
sets T to false if the var has 0, none or false, and sets T to true 
otherwise.
Steeve
23-Feb-2007
[1945]
and var 128
sett var
ift [do the job]
BrianH
23-Feb-2007
[1946x2]
Yeah.
Try it. My memory of the behavior of SETT on 0 is a little sparse.
Steeve
23-Feb-2007
[1948]
i don't see any gain
BrianH
23-Feb-2007
[1949]
It would be faster than a compare.
Steeve
23-Feb-2007
[1950x4]
i use 3 instructions to test a bit in all cases
should have:
bit 7 [do the job]
:-)
missing the operand
BrianH
23-Feb-2007
[1954]
I'm curious, did you check SETT to see if the value 0 sets the T 
flag to false?
Steeve
23-Feb-2007
[1955x3]
no sorry , i test now
it works
anyway it's not really a problem, i never perform such tests
BrianH
23-Feb-2007
[1958x2]
Cool. So SETT can replace ZERO? and NONE?, which otherwise don't 
have rebcode equivalents.
Or rather NOT ZERO? and NOT NONE?, but the effect is the same.
Steeve
23-Feb-2007
[1960x2]
i don't understand usage of ext8 and ext16
perhaps, they should be usefull for me
BrianH
23-Feb-2007
[1962x2]
Sign extension, so that you can use signed arithmetic on integers 
that contain values retrieved from 8 or 16 bit data.
It's so you don't have to do arithmetic on bytes.
Steeve
23-Feb-2007
[1964x5]
hum i see
i think i should replace this:
gt.i decal 127 ift [sub.i decal 256]
by this: ext8 decal
eureka !!!!
BrianH
23-Feb-2007
[1969]
Looks like.
Steeve
23-Feb-2007
[1970x2]
thi code is the macro i use the most
*is in the macro
BrianH
23-Feb-2007
[1972]
I wonder how much other code generated by your macros could be optimized...
Steeve
23-Feb-2007
[1973x3]
not as much as that
i hope
but surely some of them
BrianH
23-Feb-2007
[1976x3]
Perhaps some of those and x 255 operations could be put off until 
the value is written to memory.
While the values are in the registers, who cares what precision they 
are internally.
It would make the C flag easy to keep track of. Perhaps some of the 
multibyte operation sequences could be combined.
Steeve
23-Feb-2007
[1979]
hum
BrianH
23-Feb-2007
[1980]
Where it matters you could replicate the overflow behavior on purpose.
Steeve
23-Feb-2007
[1981]
but you see, the 8bit registers are often combined into 16bits registers, 
so i should perform AND 255 before to translate them into 16 bit, 
i'm not sure  there is a real gain
BrianH
23-Feb-2007
[1982x4]
That combination of 8-bit values into 16-bit registers has got to 
be a common code pattern. Are the 16-bit operations distinct from 
the 8-bit ones? This is the kind of code pattern that you could combine 
and optimize. Internally, do you need to have the 16-bit registers 
be a combination of the 8, or could they be seperate and have their 
values transfered over if it would be faster?
Are the 16-bit values loaded in one statement or two?
Need there be a difference?
It's what the modern processor designers call register renaming :)
Steeve
23-Feb-2007
[1986x2]
sorry,
disconnected
not sure to understand what u mean
BrianH
23-Feb-2007
[1988]
I would have to read your Z80 manual to be sure, but it seems to 
me that these 16-bit operations seem to be great candidates for opcode 
combining. It may even be a good idea to have the 16-bit registers 
be seperate variables internally.