Message board for the users of flat assembler.
> Main > count more than capacity
on pics, operations are only on 8 bits.
then, to make easy loops (bad practice i know) i use the W register (equivalent to Accumulator) and then, i use a sort of dec instruction.
in X86 it gives this kind of code:
tempo0: @@: inc al jne @b ret
then, considering the risc architecture, it can be possible to do a sort of incremental addition that will add 1, 2, 3, 4, 5, 6, etc... and then, maybe it will reach the 0 value later than if i use a simple inc.
tempo1 mov al,0 mov ah,0 @@: inc ah add al,ah jne @b ret
how many times i will do the loop tempo1? it is some mystery for me. is there a math method to find a good way for more than 256 counts on byte?
i can find with a little code, simulating the computation very fast, but it is not a clean method to solve the problem...
the goal is to count something like 20000 times just with one main byte and one increment byte, and of course, only one jcc because in pic, jcc doesn't exist and needs 2 instructions. and there is only one acumulator, means it is not possible to work easy on many registers at a time.
|20 Feb 2011, 11:27||
You want to find the point(s) where n(n+1)/2 mod 256 = 0
First solution is at 511 & 512 and then every 512 from there.
|20 Feb 2011, 11:46||
in fact, there is a simpler way to do the job, it exists incf instruction (to increment f register, folowed by a btfss Z flag, it an be ok to work on multibyte temporisations.
i am just trying to have the hello world working with code compiled with fasm.. and it does nothing else than light the green led... even if is fore the red led ot switch on, it don't work... i am very sad because apparentlly, the macro i've writen yesterday don't give the good opcodes...
|20 Feb 2011, 12:02||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.