Just place an _underscore before any BASIC variables you want to access in assembler,
and an _underscore in front of the assembler label you want to call from BASIC.
Give this a shot.
Just be aware of bank & page switching as your program grows.Code:crc_hi VAR BYTE bank0 crc_lo VAR BYTE bank0 temp VAR BYTE bank0 ToCrc VAR BYTE bank0 CRC VAR WORD X VAR BYTE Space CON " " Main: crc_lo = 0 crc_hi = 0 ToCrc = $ff CALL crc_8408 ' Show HEX value HSEROUT ["Input = ",IHEX2 ToCrc,Space,"Output = ",_ IHEX4 (crc_hi << 8 | crc_lo),13,10] ' Show ASCII values FOR X = 2 to 8 ToCrc = X + "0" ' Convert X val to ASCII CALL crc_8408 GOSUB Show NEXT X PAUSE 1000 GOTO Main Show: HSEROUT ["Input = ",DEC ToCrc-"0",Space,"Output = ",_ IHEX4 (crc_hi << 8 | crc_lo),13,10] RETURN ASM _crc_8408 movf _ToCrc,W ;Load value into W xorwf _crc_lo,W ;W = CD ^ ab ==> xy movwf _temp ;temp = xy swapf _temp,F ;W = yx rrf _temp,w andlw 0x78 ;y<<3 xorwf _crc_hi,W ;W = AB ^ (y<<3) movwf _crc_lo ;LO = AB ^ (y<<3) swapf _temp,W ;W = xy xorwf _temp,W ;W = (y^x) | (x^y) = kk movwf _crc_hi ;HI = kk andlw 0x0f ;W = 0k xorwf _crc_lo,W ;W = AB ^ (y<<3) ^ k btfsc _crc_hi,0 ; xorlw 0x80 ;W = AB ^ (y<<3) ^ k ^ (k<<7) movwf _crc_lo ;LO = AB ^ (y<<3) ^ k ^ (k<<7) swapf _temp,W ;W = xy andlw 0xf0 ;W = x0 xorwf _crc_hi,F ;W = y<<4 | x^y rrf _crc_hi,W ;W = (y<<4 | x^y) >> 1 andlw 7 ;W = x^y >> 1 swapf _crc_hi,F ;W = x^y<<4 | y xorwf _crc_hi,F ;HI = kx ^ k>>1 = (k<<4) ^ y ^ (k>>1) return ENDASM




Bookmarks