??? 08/28/04 09:49 Read: times |
#76526 - RE: how to do calculations Responding to: ???'s previous message |
hi,
also, u used EQU in that software. this is not in the instruction set or do all assemblers use it no matter which chip the assembler is being used for? EQU is the directive for the text preprocessor of compiler. For example, REFRESH_DATA EQU 0x40Here it says: if you see anywhere in code the word "REFRESH_DATA" then just replace it with 0x40 immediately. i calculated the way u said and but i got 490 machine cycles, not 1200 Oh, I recall that example beack to here and show you how: ; pre-processor directives; they do not add time REFRESH_DATA EQU 0x40 RSH_DAT EQU P1.0 RSH_CLK EQU P1.1 ; ... ; refresh subroutine: here we start to calculate. ; I`ll comment line by letter and number of machine cycles of each command RSH_MATRIX: MOV R0,#REFRESH_DATA ; A - 1 RSH_NEXT_BYTE: MOV A,@R0 ; B - 1 MOV R7,#8 ; C - 1 RSH_NEXT_BIT: CLR RSH_CLK ; D - 1 RRC A ; E - 1 MOV RSH_DAT,C ; F - 2 SETB RSH_CLK ; G - 1 DJNZ R7,RSH_NEXT_BIT ; H - 2 INC R0 ; I - 1 CJNE R0,#(REFRESH_DATA+20),RSH_NEXT_BYTE ; J - 2 RET ; K - 2 Now we start our calculations. First of all, let calculate loops. - loop RSH_NEXT_BIT: D...H = 7 machine cycles. And it repeats 8 times so it takes 56 cycles. - loop RSH_NEXT_BYTE: B...C + (D...H)*8 + I...J 2 + 56 + 3 = 61 cycles. It repeats 20 times (note REFRESH_DATA+20) so 61 * 20 = 1220 machine cycles. Finally add state A and K: 1220 + 1 + 2 = 1223 Just only one note: in this example, the routine refreshes 160 columns (20*8). In your case this number is smaller. Regards, Oleg |