📄 main.s
字号:
.module main.c
.area lit(rom, con, rel)
_a_logo_vectors::
.byte 1,0
.byte 0,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,5
.byte 5,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 251,0
.byte 1,0
.byte 251,0
.byte 1,0
.byte 251,0
.byte 1,0
.byte 251,0
.byte 1,0
.byte 251,0
.byte 0,0
.byte 251,0
.byte 1,35
.byte 5,0
.byte 1,251
.byte 251,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,5
.byte 5,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,251
.byte 5,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 251,0
.byte 0,5
.byte 5,0
.byte 1,35
.byte 5,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 251,0
.byte 1,0
.byte 251,0
.byte 1,251
.byte 251,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 0,0
.byte 1,5
.byte 251,0
.byte 1,0
.byte 251,0
.byte 1,251
.byte 251,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,251
.byte 0,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 5,0
.byte 0,0
.byte 0,0
.byte 0,190
.byte 0,0
.byte 0,0
.byte 0,0
.dbfile ./main.h
.dbsym e a_logo_vectors _a_logo_vectors A[240:240]c
.area text(rom, con, rel)
.dbfile ./main.h
.dbfile ./main.c
.dbfunc e main _main fV
_main::
.dbline -1
push X
mov X,SP
add SP,6
.dbline 54
; //----------------------------------------------------------------------------
; // mian.c
; //----------------------------------------------------------------------------
; //
; // Program Description:
; //
; // Draw USB Example Firmware
; //
; // This example application enumerates as a three button USB Mouse (HID Class)
; // and moves the mouse cursor in the shape of the letters U, S, and B.
; // It demostrates the use of the USB User Module API.
; //
; // Note: For proper demostration, turn off Mouse Accelerator using the Windows
; // Control Panel.
; //
; // Hardware considerations: This application was written for the CY3655
; // Application Board that is provided in the CY3655 Development Kit.
; //
; // Switch S1 is connected to P0.2 (Down=Start Movement/Up=Stop Movement)
; // Switch S2 is connected to P0.3 (Down=Left Button Down/Up=Left Button Up)
; // Switch S3 is connected to P0.4 (Not used)
; //
; // LED D1 is connected to P0.5 (Tracks S1: On=Down/Off=Up)
; // LED D2 is connected to P0.6 (Tracks S2: On=Down/Off=Up)
; // LED D3 is connected to P1.3 (Not used)
; //
; //
; //
; // Target: CY7C63823-SXC
; // Tool chain: PSoC Designer / CY3655DK
; // Author: Jean hou
; //
; //----------------------------------------------------------------------------
;
;
; //----------------------------------------------------------------------------
; // Includes
; //----------------------------------------------------------------------------
; #include <m8c.h> // part specific constants and macros
; #include "main.h"
;
; //----------------------------------------------------------------------------
; // Global Constants
; //----------------------------------------------------------------------------
; BYTE left_button;
; BYTE move;
; BYTE a_ram[4];
; const unsigned char *p_data;
;
; //---------------------------------------------------------------------------
; // Main Function
; //---------------------------------------------------------------------------
; void main()
; {
.dbline 55
; USB_Start(0); // Enable USB
push X
mov A,0
xcall _USB_Start
pop X
.dbline 56
; M8C_EnableGInt; // and Global Interrupts
or F, 01h
L3:
.dbline 59
.dbline 59
L4:
.dbline 58
;
; while (USB_bGetConfiguration() == 0) // Wait for USB enumeration
push X
xcall _USB_bGetConfiguration
pop X
cmp A,0
jz L3
.dbline 61
; {}
;
; p_data = &a_logo_vectors[0]; // Point to the first of the logo vectors
mov [_p_data+1],<_a_logo_vectors
mov [_p_data],>_a_logo_vectors
.dbline 63
;
; move = STOP;
mov [_move],0
.dbline 64
; left_button = UP;
mov [_left_button],0
xjmp L7
L6:
.dbline 67
;
; while (1)
; {
.dbline 68
; move = ((P0DATA & 0x04) ? STOP : GO); // P0.2 Up or Down
tst REG[ 0],4
jz L10
mov [X+1],0
mov [X+0],0
xjmp L11
L10:
mov [X+1],1
mov [X+0],0
L11:
mov A,[X+1]
mov [_move],A
.dbline 69
; left_button = ((P0DATA & 0x08) ? UP : DOWN); // P0.3 Up or Down
tst REG[ 0],8
jz L13
mov [X+3],0
mov [X+2],0
xjmp L14
L13:
mov [X+3],1
mov [X+2],0
L14:
mov A,[X+3]
mov [_left_button],A
.dbline 70
; if (move == STOP)
cmp [_move],0
jnz L15
.dbline 71
; { P0DATA |= 0x20; // P0.5 high (off)
.dbline 71
or REG[ 0],32
.dbline 72
xjmp L16
L15:
.dbline 72
; }else {
.dbline 73
; P0DATA &= ~(0x20); // P0.5 low (on)
and REG[ 0],-33
.dbline 74
; }
L16:
.dbline 75
; if (left_button == UP)
cmp [_left_button],0
jnz L17
.dbline 76
; { P0DATA |= 0x40; // P0.6 high (off)
.dbline 76
or REG[ 0],64
.dbline 77
xjmp L18
L17:
.dbline 77
; }else{
.dbline 78
; P0DATA &= ~(0x40); // P0.6 low (on)
and REG[ 0],-65
.dbline 79
; }
L18:
.dbline 81
;
; if (move == GO)
cmp [_move],1
jnz L19
.dbline 82
; {
.dbline 84
; // Check to see if the endpoint is empty
; if (USB_bGetEPState(1) == IN_BUFFER_EMPTY)
push X
mov A,1
xcall _USB_bGetEPState
pop X
cmp A,1
jnz L21
.dbline 85
; {
.dbline 86
; a_ram[0] = ((left_button == DOWN) ? *p_data : *p_data & ~(LB_DOWN));
cmp [_left_button],1
jnz L24
mov [__r1],[_p_data+1]
mov A,[_p_data]
push X
mov X,[__r1]
romx
pop X
mov [X+5],A
mov [X+4],0
xjmp L25
L24:
mov [__r1],[_p_data+1]
mov A,[_p_data]
push X
mov X,[__r1]
romx
pop X
and A,-2
mov [X+5],A
mov [X+4],0
L25:
mov A,[X+5]
mov [_a_ram],A
.dbline 87
; p_data++;
inc [_p_data+1]
adc [_p_data],0
.dbline 88
; a_ram[1] = *p_data; p_data++;
mov [__r1],[_p_data+1]
mov A,[_p_data]
push X
mov X,[__r1]
romx
pop X
mov [_a_ram+1],A
.dbline 88
inc [_p_data+1]
adc [_p_data],0
.dbline 89
; a_ram[2] = *p_data; p_data++;
mov [__r1],[_p_data+1]
mov A,[_p_data]
push X
mov X,[__r1]
romx
pop X
mov [_a_ram+2],A
.dbline 89
inc [_p_data+1]
adc [_p_data],0
.dbline 90
; a_ram[3] = *p_data; p_data++;
mov [__r1],[_p_data+1]
mov A,[_p_data]
push X
mov X,[__r1]
romx
pop X
mov [_a_ram+3],A
.dbline 90
inc [_p_data+1]
adc [_p_data],0
.dbline 91
; if (p_data > &a_logo_vectors[sizeof(a_logo_vectors) - 1])
mov A,<_a_logo_vectors+239
sub A,[_p_data+1]
mov A,>_a_logo_vectors+239
sbb A,[_p_data]
jnc L29
X1:
.dbline 92
; p_data = &a_logo_vectors[0];
mov [_p_data+1],<_a_logo_vectors
mov [_p_data],>_a_logo_vectors
L29:
.dbline 93
; USB_LoadEP(1, &a_ram[0], 3);
mov [_USB_APIEPNumber],1
.dbline 93
mov [_USB_APICount],3
.dbline 93
push X
mov A,>_a_ram
push A
mov A,<_a_ram
mov X,A
pop A
xcall _USB_XLoadEP
pop X
.dbline 94
; }
L21:
.dbline 95
; }
L19:
.dbline 96
L7:
.dbline 66
xjmp L6
X0:
.dbline -2
.dbline 97
; }
; }
L2:
add SP,-6
pop X
.dbline 0 ; func end
jmp .
.dbend
.area bss(ram, con, rel)
.dbfile ./main.c
_p_data::
.blkb 2
.dbsym e p_data _p_data pc
_a_ram::
.blkb 4
.dbsym e a_ram _a_ram A[4:4]c
_move::
.blkb 1
.dbsym e move _move c
_left_button::
.blkb 1
.dbsym e left_button _left_button c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -