Re: [Tuxnes-devel] yet more asm stuff--carry f
Brought to you by:
tmmm
|
From: Jim U. <ji...@3e...> - 2001-04-16 20:35:28
|
At 03:05pm on 2001 April 16, Rigel did write: > > [ I wrote ] > >Yes. What trouble are you having with the implementation? > >When carry is set, ebp is -1. When carry is clear, ebp is 0. > >For instructions which may carry, the sequence is: > >addl -1, %ebp # set i386 carry if %ebp >was set > ><instruction which may carry> # set i386 carry according to 6502 instruction > >sbbl %ebp, %ebp # set %ebp to -1 on >carry, else clear > Okay, I get that much. However, Mips doesn't > necessarily have a flags reg (I don't think). If it has a carry flag and instructions which add with carry/subtract with borrow, you can use the shortcut technique above. > let's say the operation is sh left, so in C: > modified=orig<<1; > carryf = modified ^ orig; // ^ is xor operator (?) Um... try, for example, orig=1. This gives carryf = 3. xoring won't work except by chance. ;) For ASL, try something like carryf = (orig & 0x80) ? 1 : 0; or equivalently carryf = (orig & 0x80) >> 7; Grab a copy of an (unencumbered) C 6502 core (e.g. Nofrendo) because it will tell you exactly how every instruction works in a high-level language. -- "There is a very hollow echo of a gaur in the birth of that animal to a cow in Iowa. To say that is a gaur is to disrespect all gaurs in all the places where gaurs live. That animal will never live its life in true gaurdom, to wander in the forests of India and frolic with other gaurs and die and let teak trees grow out of it. That's the gaur I'm working to save." -K. Redford ji...@3e... / 0x43340710 / 517B C658 D2CB 260D 3E1F 5ED1 6DB3 FBB9 4334 0710 |