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
[1866]
i see, but DAA not follows sub or add opcodes, he can act severall 
opcodes later
BrianH
23-Feb-2007
[1867]
It would mean more branch tables or some branch index arithmetic, 
but the interpreter could be made much faster in certain cases.
Steeve
23-Feb-2007
[1868]
Z80 just remember if the last math operation was an add or a substract
BrianH
23-Feb-2007
[1869]
What is the effect of the add/sub that affects the DAA? Is it some 
flag?
Steeve
23-Feb-2007
[1870x2]
yes a flag, but this flag is not visible
so in rebcode , i will have to manage this trick by myself, with 
seting my own DaaFlag after a sub or an add
BrianH
23-Feb-2007
[1872]
Sorry, that answers my question. Perhaps putting the DAA implementation 
in the blocks of an either statement on that flag would lessen the 
lookup overhead.
Steeve
23-Feb-2007
[1873]
*by setting
BrianH
23-Feb-2007
[1874]
I'm curious as to what the effect really is. Perhaps a positive/negative 
issue?
Steeve
23-Feb-2007
[1875x2]
you can sse the trick here http://www.zilog.com/docs/z80/um0080.pdf
*see
BrianH
23-Feb-2007
[1877x2]
So, it looks like 3 flags, one of which may be set afterwards, and 
some ranges. Either that means some really interesting math, or a 
4096 byte lookup table :(
What's the H flag?
Steeve
23-Feb-2007
[1879]
Half carry flag
BrianH
23-Feb-2007
[1880]
What's that for?
Steeve
23-Feb-2007
[1881]
set if bit 4 is set after an operation
BrianH
23-Feb-2007
[1882]
Got it.
Steeve
23-Feb-2007
[1883]
useless in most case (i don't manage it in my code)
BrianH
23-Feb-2007
[1884]
It seems to matter here. Perhaps you should set it after BCD operations.
Steeve
23-Feb-2007
[1885x2]
yep, i fear that
i have to handle it in all math operations
BrianH
23-Feb-2007
[1887]
Or for that matter, you could set the reference to the lookup table 
to be the appropriate one after the initial operation. That way you 
don't need to test the flag later - the flag could be implied.
Steeve
23-Feb-2007
[1888]
yep it's a possibility
BrianH
23-Feb-2007
[1889]
No need to follow CPU internal execution patterns when you aren't 
a real CPU.
Steeve
23-Feb-2007
[1890x7]
thats why the lookup table have 4096 entries
get the correct offset following the content of accumulator before 
math operation
then retrive the corrected BCD result using the byte AFTER the math 
operation
hum not sure about what i said, i have to think ... more
the problem with the Half carry flag is that you must compare the 
data before with the data after
you can't just test the 4th bit of the resulting data
5th sorry
BrianH
23-Feb-2007
[1897]
So, you do BCD arithmetic by using binary arithmetic on BCD values 
and then using DAA to fudge the data afterwards?
Steeve
23-Feb-2007
[1898]
i fear it will slow the math operations more than expected
BrianH
23-Feb-2007
[1899]
You can improve the overall speed elsewhere by combining strings 
of operations between writes to memory.
Steeve
23-Feb-2007
[1900x2]
it's not me who do that but Z80 :-)
combining...
BrianH
23-Feb-2007
[1902]
No, you can do it. The main reason that you have to branch back to 
the beginning of your interpreter at every step is because the next 
step might have been modified by the previous. You can speed that 
up though, by realizing that the only statements that really need 
that paranoia are memory writes and branches - other opcodes can 
by combined in your interpreter, like looking more than one move 
ahead in chess.
Steeve
23-Feb-2007
[1903]
yes but combining operations need more tests so it will decrease 
overall performance. i do'nt see how i can do that without consumming 
more times to compile series of opcodes
BrianH
23-Feb-2007
[1904x2]
It would require a more complex state machine, but since you wouldn't 
be starting over with every opcode it would execute less tests and 
branches per step than not combining. Think of combining opcodes 
as a kind of loop unrolling.
It would be not that different from your existing multi-byte opcode 
process, just for more opcodes.
Steeve
23-Feb-2007
[1906x3]
i see
so in fact it could be performed by a static analyse of the code 
before ther real execution, and will result in addition of new byte-opcodes.
yep
BrianH
23-Feb-2007
[1909]
You could even generate more of your interpreter by using more interesting 
macros, which would cut down on the programmer overhead of the increased 
number of states in your state machine.
Steeve
23-Feb-2007
[1910x4]
like what ?
like iterative macros
currently i want keep ly source readable
but after the debuguing phase, i think i could compact the code with 
more macros, i agree
BrianH
23-Feb-2007
[1914]
Perhaps you could specify your operations in a table and then go 
through it with a dialect processor like BURG - REBOL is good at 
that sort of thing. Then you could generate your interpreter from 
that table.
Steeve
23-Feb-2007
[1915]
BURG ? sort of beer effect ?