asm2.c

来自「Cypress公司Cy7c6xxxx芯片的USB键盘及USB鼠标的firmwar」· C语言 代码 · 共 75 行

C
75
字号
#pragma option f0 /* remove page breaks from listing file */
/* 
 * CYC Code Development System
 * Tutorial Example
 * ASM2.C
 * This code may be adapted for any purpose
 * when used with the CYC Code Development
 * System.  No warranty is implied or given
 * as to their usability for any purpose.
 * 
 * (c) Copyright 2000 Byte Craft Limited
 * 421 King St.N., Waterloo, ON, Canada, N2J 4E4
 * VOICE: 1 (519) 888 6911
 * FAX  : 1 (519) 746 6751
 * email: support@bytecraft.com
 * 
 * REVISION HISTORY
 * v1.00 AL 08/2000 Initial Version.
 */
#include <dev\c63413.h>
#pragma option CALLMAP

long long_global;

int i=0;
                                                                        /* figure_d */
void init_long_global(long);

#asm
init_long_global:
        MOV  [long_global+1],A  ;move A to low byte
        MOV  A,X                ;move X to high byte
        MOV  [long_global+0],A
        RET                     ;return
#endasm

                                                                        /* figure_d */

                                                                        /* figure_e */
long read_long_global(void);

#asm
read_long_global:
        MOV A,[long_global+0]   ;load high byte into X
        MOV X,A
        MOV A,[long_global+1]   ;load low byte inot A
        RET
#endasm
                                                                        /* figure_e */

                                                                        /* figure_c */

#asm
clear_ram:
         MOV A,0 ;value to store in RAM
         MOV X,REGISTER_SIZE ;start offset
clear_next_loc:
         MOV [X+REGISTER_START],A ; clear RAM location
         DEC X                    ; point to next location
         JNZ clear_next_loc
         MOV [REGISTER_START],A
         RET
#endasm

void main(void)
{
        long l;
        clear_ram();
        init_long_global(0x1234);
        l=read_long_global();

        while(1);
}
                                                                        /* figure_c */

⌨️ 快捷键说明

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