![]() |
Instrucciones para operar a nivel de bit - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +--- Thread: Instrucciones para operar a nivel de bit (/showthread.php?tid=64) |
Instrucciones para operar a nivel de bit - juan - 11-08-2008 Hola, boriel. ¿Hay en zx basic instrucciones o funciones para trabajar a nivel de bit? Las necesito, por ejemplo, para leer el teclado con IN. Gracias. Re: Instrucciones para operar a nivel de bit - boriel - 11-08-2008 juan Wrote:Hola, boriel. Hola, Juan. Pues me vas a matar, porque están previstas, pero no las he programado aún. :oops: Tienes dos opciones por ahora: 1) Usar divisiones y mutiplicaciones de potencias de 2 (el compilador creo que ya las optimiza). 2) Meter ensamblador en medio del código. Bueno, también puedes esperar a que las saque. Están previstos los Desplazamientos, BIT, AND, OR y XOR a nivel de BIT de hasta 32 bits. Pero no he tenido tiempo de hacerlo. En cuanto lo tenga te a aviso. Eso sí, estas operaciones no van a ser tan rápidas quizá como en ASM. Pero para lo que quieres hacer yo creo que de sobra. Re: Instrucciones para operar a nivel de bit - juan - 11-08-2008 No problem. Aislaré las operaciones a nivel de bit en funciones (y me apañaré con operaciones con múltiplos de 2), así, cuando el compilador las implemente, sólo tendré que cambiar estas funciones. Muchas gracias por contestar. Re: Instrucciones para operar a nivel de bit - boriel - 02-13-2009 juan Wrote:No problem. Aislaré las operaciones a nivel de bit en funciones (y me apañaré con operaciones con múltiplos de 2), así, cuando el compilador las implemente, sólo tendré que cambiar estas funciones.Gracias por tu paciencia, Juan. Ya he comenzado a implementar las funciones bit a bit. De momento empezaré con shr y shl. Te avisaré cuando estén. Por cierto, bájate la versión 1.0.5, ya que las anteriores tienen fallos que pueden impedir que tu programa compile bien. Re: Instrucciones para operar a nivel de bit - britlion - 01-30-2010 This should be fairly simple to implement for the most part. Certainly for 8 bits: Code: FUNCTION FASTCALL bNOT (sentIn as uByte) as uByte Of course I haven't worked out how to drop into asm mode well, because CALL and FASTCALL aren't documented as to where they put their parameters. It looks like a standard call puts them on the stack, but Boriel's code then plays with the stack pointer, which totally confuses me. Anyway, 8 bit binary NOT? - One line of asm ![]() For 16 bit function code: Code: FUNCTION FASTCALL bNOT (sentIn as uInteger) as uInteger Re: Instrucciones para operar a nivel de bit - britlion - 02-02-2010 Instructions for a binary AND, OR and NOT are in the how-to's section of this forum: <!-- l --><a class="postlink-local" href="http://www.boriel.com/forum/viewforum.php?f=14">viewforum.php?f=14</a><!-- l --> |