assembly.s90

来自「Mega8完美下载 包含源程序」· S90 代码 · 共 70 行

S90
70
字号

write_page:
        RCALL   WAIT_SPMEN  ;Wait for SPMEN flag cleared
        ;MOV     R31,R17         
        MOVW     R30,R16     ;move adress to z pointer (R31=ZH R30=ZL)
        MOV	 R17,R20
        RJMP	SPMSTUFF


fill_temp_buffer:

        RCALL   WAIT_SPMEN  ;Wait for SPMEN flag cleared

        ;MOV     R31,R17     ;move adress to z pointer (R31=ZH R30=ZL)   
        MOVW     R30,R16     
        ;MOV     R1,R21      ;move data to reg 0 and 1      
        MOVW     R0,R20
 
        LDI     R17,(1<<SPMEN)

SPMSTUFF:
;;        #ifdef _ATMEGA104
;;        STS     SPMCSR,R17  ;argument 2 decides function
;;        #else
        OUT     SPMCR,R17   ;argument 2 decides function
;;        #endif
        SPM                ;Store program memory
        .DW      0xFFFF      ;For future part compatibility, instruction alignment
        NOP
 

WAIT_SPMEN:
;;        #ifdef _ATMEGA104
;;        LDS     R19,SPMCSR
;;        SBRC    R19,SPMEN
;;        RJMP    WAIT_SPMEN  ;Wait for SPMEN flag cleared
;;        #endif
        
        RET



read_program_memory:
        RCALL    WAIT_SPMEN

        ;MOV     R31,R17     ;R31=ZH R30=ZL
        MOVW     R30,R16     ;move adress to z pointer
        SBRC    R20,0       ;read lockbits? (second argument=0x09)
                            ;if so, place second argument in SPMEN register
;;        #ifdef _ATMEGA104
;;        STS     SPMCSR,R20  ;argument 2 decides function
;;        #else
        OUT     SPMCR,R20   ;argument 2 decides function
;;        #endif
        
        LPM     R16,Z+              

        LPM     R17,Z+


        RET

write_lock_bits:
        RCALL   WAIT_SPMEN  ;Wait for SPMEN flag cleared

        MOV     R0,R16   
        LDI     R17,((1<<BLBSET)|(1<<SPMEN))
	RJMP SPMSTUFF
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?