Hi,
to replicate this issue, compile this file:
/*********************************************************************************
*********************************************************************************/
#define HOST_DD1 0x01
#define HOST_DD2 0x02
#define HOST_DR1 0x04
#define HOST_DR2 0x08
#define HOST_DEV 0x40
#define HOST_DSK 0x80
#define NUMBER_OF_DEVICES 6
#define GPIO_A_5 2
#define GPIO_A_6 3
/********************************************************************************/
typedef struct _BSS_t
{
// Hardware type
unsigned char hwType;
// Hardware version
unsigned char hwVersion;
// Swap order LEDs
unsigned char swapActivityLeds;
// Device type bitmap for USB ports 1
unsigned char host1DevType;
// Device type bitmap for USB ports 2
unsigned char host2DevType;
// Devices state
unsigned char devsState;
// State of monitor LEDs
unsigned char monLEDsON;
// Sate of Individual monitor LEDs
unsigned char monLEDsState;
} BSS_t;
/********************************************************************************/
/********************************************************************************/
unsigned char msk1;
unsigned char msk2;
unsigned char msk3;
unsigned char msk4;
unsigned char msks1;
unsigned char msks2;
BSS_t *BSS;
/*********************************************************************************
*********************************************************************************/
void main(void)
{
for (;;
}
/********************************************************************************/
/********************************************************************************/
void cmd_cr()
{
msk1 = HOST_DD1;
msk2 = HOST_DD2;
msk3 = HOST_DR1;
msk4 = HOST_DR2;
msks1 = (HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
msks2 = ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
BSS->devsState &= ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
}
/********************************************************************************/
/********************************************************************************/
using the following commands:
VinC.exe -c -d 1 -O 4 -o Debug\USB-BUG.asm USB-BUG.c
VinAsm.exe -v -d 1 -o Debug\USB-BUG.obj Debug\USB-BUG.asm
VinL.exe -d 1 -o Debug\USB-BUG Debug\USB-BUG.obj
and you will obtain this file with the bug:
003c0 fa00 03e0 JUMP 0x003e0
003c2 fa00 03c0 JUMP 0x003c0
003c4 fa00 03be JUMP 0x003be
003c6 fa00 03c0 JUMP 0x003c0
003c8 fa00 03c0 JUMP 0x003c0
003ca fa00 03c0 JUMP 0x003c0
003cc fa00 03c0 JUMP 0x003c0
003ce fa00 03c0 JUMP 0x003c0
003d0 b500 0000 OUTPORT 0x100 0x0000
003d2 0000 NOP
003d3 0000 NOP
003d4 0000 NOP
003d5 0000 NOP
003d6 0000 NOP
003d7 0000 NOP
003d8 2e78
003d9 7a79
003da 0000 NOP
003db 0000 NOP
003dc 0000 NOP
003dd 0000 NOP
003de 0000 NOP
003df 0000 NOP
003e0 b028 0001 OUTPORT 0x028 $0x01
003e2 bc00 3ffc INPORT 0x000 0x3ffc
003e4 3204 3ffc SHR8 0x3ffc $0x04
003e6 da01 3ffc CMP8 0x3ffc $0x01
003e8 fa40 0408 JNZ 0x00408
003ea b00f 0000 OUTPORT 0x00f $0x00
003ec b080 0012 OUTPORT 0x080 $0x12
003ee b088 000f OUTPORT 0x088 $0x0f
003f0 b089 00f0 OUTPORT 0x089 $0xf0
003f2 b084 0000 OUTPORT 0x084 $0x00
003f4 b085 0000 OUTPORT 0x085 $0x00
003f6 b08a 00ff OUTPORT 0x08a $0xff
003f8 b08b 003f OUTPORT 0x08b $0x3f
003fa b081 0001 OUTPORT 0x081 $0x01
003fc c883 0000 PORTTST 0x083 $0 Z
003fe fa40 03fc JNZ 0x003fc
00400 b080 0000 OUTPORT 0x080 $0x00
00402 b088 0000 OUTPORT 0x088 $0x00
00404 b089 0000 OUTPORT 0x089 $0x00
00406 b083 00ff OUTPORT 0x083 $0xff
00408 2600 3ffa 08c4 0000 LD32 0x3ffa $0x000008c4
0040c 3201 bffa SHR32 0x3ffa $0x01
0040e 2400 3ffe 0000 LD16 0x3ffe $0x0000
00411 2400 3ff8 001e LD16 0x3ff8 $0x001e
00414 3201 7ff8 SHR16 0x3ff8 $0x01
00416 dc00 3ff8 0000 CMP16 0x3ff8 $0x0000
00419 fa1c 042a JLE 0x0042a
0041b 2d01 3ffa 3ffe CPYROM (0x3ffe) 0x3ffa $01
0041e 6c00 3ffe 0002 ADD16 0x3ffe $0x0002
00421 6e00 3ffa 0001 0000 ADD32 0x3ffa $0x00000001
00425 6c20 3ff8 0001 SUB16 0x3ff8 $0x0001
00428 fa00 0416 JUMP 0x00416
0042a 2600 3ffc 0000 0000 LD32 0x3ffc $0x00000000
0042e 2600 3ff8 0000 0000 LD32 0x3ff8 $0x00000000
00432 0a00 0000 SP_LOAD $0x0000
00434 fa00 043a JUMP 0x0043a
00436 0000 NOP
00437 0000 NOP
00438 0000 NOP
00439 0000 NOP
0043a fa00 043a JUMP 0x0043a
0043c 0006 RTS
0043d f200 800c PUSH32 0x000c
0043f f200 8010 PUSH32 0x0010
00441 2201 0020 LD8 0x0020 $0x01
00443 2202 0021 LD8 0x0021 $0x02
00445 2204 0022 LD8 0x0022 $0x04
00447 2208 0023 LD8 0x0023 $0x08
00449 220f 0024 LD8 0x0024 $0x0f
0044b 22f0 0025 LD8 0x0025 $0xf0
0044d 2400 000c 001e LD16 0x000c $0x001e
00450 4401 400c 000c CPY16 0x000c (0x000c)
00453 8205 400c INC16 0x000c $0x05
00455 4401 000c 0010 CPY8 0x0010 (0x000c)
00458 4a30 0010 AND8 0x0010 $0x30
0045a 4500 0010 000c CPY8 (0x000c) 0x0010
0045d f380 0010 POP32 0x0010
0045f f380 000c POP32 0x000c
00461 0006 RTS
00462 0000 NOP
00463 0000 NOP
00464 0000 NOP
00465 0000 NOP
00466 0000 NOP
00467 0000 NOP
00468 0000 NOP
00469 0000 NOP
0046a 0000 NOP
0046b 0000 NOP
0046c 0000 NOP
0046d 0000 NOP
0046e 0000 NOP
0046f 0000 NOP
00470 0000 NOP
00471 1808
00472 150e
00473 1014
00474 d182
Willy.