' oscmode = 17579780 con oscmode = 17579780 ' ' freq = 160_000_000 ' freq = 160000000 freq = 160000000 ' ' baud = 2_000_000 ' baud = 2000000 baud = 2000000 ' ' ' ' _rom_baud = 115_200 ' _rom_baud = 115200 _rom_baud = 115200 ' ' _rom_rx_pin = 51 ' pin serial receiver ' _rom_rx_pin = 51 _rom_rx_pin = 51 ' ' _rom_tx_pin = 53 ' pin serial transmitter ' _rom_tx_pin = 53 _rom_tx_pin = 53 dat org 0 alignl _dat_ '-' ' start original program in COG1 and jmp COG0 into TAQOZ, patching ROM serial pins '-' orgh 0 '-' org 0 '-' '-' ' patch ROM '-' ' tx_pin in _Enter_Monitor '-' wrbyte #_rom_tx_pin, ##$FCA98 ' new - wypin lmm_x, #_rom_tx_pin byte $e5, $07, $00, $ff, $98, $6a, $4c, $fc '-' ' old - wypin lmm_x, #tx_pin '-' ' tx_pin & rx_pin in _SerialInit '-' wrbyte #_rom_tx_pin, ##$FCABC ' new - wrpin ##_txmode, #_rom_tx_pin byte $e5, $07, $00, $ff, $bc, $6a, $4c, $fc '-' ' old - wrpin ##_txmode, #tx_pin '-' wrbyte #_rom_tx_pin, ##$FCAC0 ' new - wxpin lmm_x, #_rom_tx_pin byte $e5, $07, $00, $ff, $c0, $6a, $4c, $fc '-' ' old - wxpin lmm_x, #tx_pin '-' wrbyte #(_rom_tx_pin<<1),##$FCAC5 ' new - dirh #_rom_tx_pin byte $e5, $07, $00, $ff, $c5, $d4, $4c, $fc '-' ' old - dirh #tx_pin '-' wrbyte #$88, ##$FCACA ' new - wrpin ##%0000_0001_000_0000000000000_00_11111_0, #_rx_pin byte $e5, $07, $00, $ff, $ca, $10, $4d, $fc '-' ' old - wrpin ##_rxmode, #rx_pin '-' wrbyte #_rom_rx_pin, ##$FCACC ' new - wrpin ##%0000_0001_000_0000000000000_00_11111_0, #_rom_rx_pin byte $e5, $07, $00, $ff, $cc, $66, $4c, $fc '-' ' old - wrpin ##_rxmode, #rx_pin '-' wrbyte #_rom_rx_pin, ##$FCAD0 ' new - wxpin lmm_x, #_rom_rx_pin byte $e5, $07, $00, $ff, $d0, $66, $4c, $fc '-' ' old - wxpin lmm_x, #rx_pin '-' wrbyte #(_rom_rx_pin<<1),##$FCAD5 ' new - dirh #_rom_rx_pin byte $e5, $07, $00, $ff, $d5, $cc, $4c, $fc '-' ' old - dirh #rx_pin '-' wrbyte #_rom_tx_pin, ##$FCADC ' new - wypin lmm_x, #_rom_tx_pin byte $e5, $07, $00, $ff, $dc, $6a, $4c, $fc '-' ' old - wypin lmm_x, #tx_pin '-' ' tx_pin in _HubTx '-' wrbyte #(_rom_tx_pin<<1),##$FCAF5 ' new - testp #_rom_tx_pin wc byte $e5, $07, $00, $ff, $f5, $d4, $4c, $fc '-' ' old - testp #tx_pin wc '-' wrbyte #_rom_tx_pin, ##$FCAFC ' new - wypin lmm_x, #_rom_tx_pin byte $e5, $07, $00, $ff, $fc, $6a, $4c, $fc '-' ' old - wypin lmm_x, #tx_pin '-' ' rx_pin in _HubRx '-' wrbyte #(_rom_rx_pin<<1),##$FCB11 ' new - testp #_rom_rx_pin wc byte $e5, $07, $00, $ff, $11, $cd, $4c, $fc '-' ' old - testp #rx_pin wc '-' wrbyte #_rom_rx_pin, ##$FCB18 ' new - rdpin lmm_x, #_rom_tx_pin byte $e5, $07, $00, $ff, $18, $67, $4c, $fc '-' ' old - rdpin lmm_x, #tx_pin '-' ' _REENTER_TAQOZ not _START_TAQOZ on ESC cr '-' wrbyte #$B4, ##$FCD8C ' new - if_e jmp #@_REENTER_TAQOZ byte $e6, $07, $00, $ff, $8c, $69, $4d, $fc '-' ' old - if_e jmp #@_START_TAQOZ '-' 'TAQOZ '-' wrbyte #(_rom_tx_pin<<1),##$FE9D1 ' new - dirh #_rom_tx_pin byte $f4, $07, $00, $ff, $d1, $d5, $4c, $fc '-' ' old - dirh #tx_pin '-' wrbyte #_rom_tx_pin, ##$FE9D4 ' new - wypin #$0D, #_rom_tx_pin byte $f4, $07, $00, $ff, $d4, $6b, $4c, $fc '-' ' old - wypin #$0D, #tx_pin '-' wrbyte #(_rom_rx_pin<<1),##$FE9DD ' new - dirh #_rom_rx_pin byte $f4, $07, $00, $ff, $dd, $cd, $4c, $fc '-' ' old - dirh #rx_pin '-' wrbyte #_rom_rx_pin, ##$FE9E0 ' new - rdpin fz,#_rom_rx_pin wc byte $f4, $07, $00, $ff, $e0, $67, $4c, $fc '-' ' old - rdpin fz,#rx_pin wc '-' wrlong rxsetsel, ##$FE9F0 ' new - setse1 #%110<<6+_rom_rx_pin byte $f4, $07, $00, $ff, $f0, $69, $64, $fc '-' ' old - setse1 #%110<<6+rx_pin '-' wrbyte #_rom_rx_pin, ##$FEA14 ' new - rdpin fz,#_rom_rx_pin byte $f5, $07, $00, $ff, $14, $66, $4c, $fc '-' ' old - rdpin fz,#rx_pin wc '-' wrbyte #_rom_tx_pin, ##$FF358 ' new - mov txpin,#_rom_tx_pin byte $f9, $07, $00, $ff, $58, $6b, $4c, $fc '-' ' old - mov txpin,#tx_pin '-' wrbyte #_rom_tx_pin, ##$FF370 ' new - txpin long _rom_tx_pin byte $f9, $07, $00, $ff, $70, $6b, $4c, $fc '-' ' old - txpin long tx_pin '-' '-' ' now start '-' mov $1ef, ##$FC000 ' lmm_bufad, locn of hub buffer for serial routine byte $e0, $07, $00, $ff, $00, $de, $07, $f6 '-' mov $1e0, ##(freq / _rom_baud) << 16 + 7 ' _rom_baud baud, 8 bits ' lmm_x, sets serial baud byte $00, $b6, $02, $ff, $07, $c0, $07, $f6 '-' call #$fcab8 ' initialise serial _SerialInit byte $b8, $ca, $af, $fd '-' '-' 'SETQ ptra_val ' would end up in ptra of new cog '-' coginit #1,##@_mainprogram ' Start Main program in COG #1 byte $80, $00, $00, $ff, $00, $02, $ec, $fc '-' '-' '.monitor call #$fcd78 ' to the monitor/debugger '-' ' jmp #.monitor ' loop back in case of "Q" '-' '-' jmp #$FD028 ' and transfer control of COG 0 to TAQOZ byte $28, $d0, $8f, $fd '-' rxsetsel setse1 #%110<<6+_rom_rx_pin byte $20, $66, $67, $fd, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 byte $00[65312] '-' fit $1E0 ' ensure LMM reserved area cog $1E0-$1EF available '-' ''--------------------------------------------------------------------------------------------------- '-' orgh $10000 ' leave the first 64K free for TAQOZ '-' org 0 '-' _mainprogram '-' ''--------------------------------------------------------------------------------------------------- '-' '' HERE NOW THE SOURCE OF WHATEVER YOU WANT TO PLAY WITH (it will run on COG #1++) '-' '' '-' '' you have to change orgh $800 against orgh $10800 in you code following this '-' ''--------------------------------------------------------------------------------------------------- '-' org 0 '-' entry '-' cmp ptra, #0 wz byte $00, $f0, $0f, $f2 '-' if_ne jmp #spininit byte $10, $00, $90, $5d '-' mov ptra, ptr_stackspace_ byte $2b, $f0, $03, $f6 '-' calla #@_demo byte $08, $08, $c1, $fd '-' cogexit '-' cogid arg01 byte $01, $60, $60, $fd '-' cogstop arg01 byte $03, $60, $60, $fd '-' spininit '-' rdlong objptr, ptra byte $00, $4b, $04, $fb '-' add ptra, #4 byte $04, $f0, $07, $f1 '-' rdlong result1, ptra byte $00, $59, $04, $fb '-' add ptra, #4 byte $04, $f0, $07, $f1 '-' rdlong arg01, ptra byte $00, $61, $04, $fb '-' add ptra, #4 byte $04, $f0, $07, $f1 '-' rdlong arg02, ptra byte $00, $63, $04, $fb '-' add ptra, #4 byte $04, $f0, $07, $f1 '-' rdlong arg03, ptra byte $00, $65, $04, $fb '-' add ptra, #4 byte $04, $f0, $07, $f1 '-' rdlong arg04, ptra byte $00, $67, $04, $fb '-' sub ptra, #16 byte $10, $f0, $87, $f1 '-' calla result1 byte $2e, $58, $60, $fd '-' jmp #cogexit byte $c0, $ff, $9f, $fd '-' '-' unsdivide_ '-' setq #0 byte $28, $00, $64, $fd '-' qdiv muldiva_, muldivb_ byte $38, $6e, $10, $fd '-' getqx muldivb_ byte $18, $70, $60, $fd '-' getqy muldiva_ byte $19, $6e, $60, $fd '-' reta byte $2e, $00, $64, $fd '-' '-' divide_ '-' abs muldiva_,muldiva_ wc 'abs(x) byte $37, $6e, $50, $f6 '-' muxc itmp2_,#%11 'store sign of x byte $03, $48, $84, $f5 '-' abs muldivb_,muldivb_ wcz 'abs(y) byte $38, $70, $58, $f6 '-' if_c xor itmp2_,#%10 'store sign of y byte $02, $48, $64, $c5 '-' calla #unsdivide_ byte $d8, $ff, $df, $fd '-' test itmp2_,#1 wc 'restore sign, remainder byte $01, $48, $d4, $f7 '-' negc muldiva_,muldiva_ byte $37, $6e, $80, $f6 '-' test itmp2_,#%10 wc 'restore sign, division result byte $02, $48, $d4, $f7 '-' negc muldivb_,muldivb_ byte $38, $70, $80, $f6 '-' reta byte $2e, $00, $64, $fd '-' '-' itmp1_ '-' long 0 byte $00, $00, $00, $00 '-' itmp2_ '-' long 0 byte $00, $00, $00, $00 '-' objptr '-' long @objmem byte $2a, $0d, $01, $00 '-' ptr_L__0016_ '-' long @LR__0028 byte $dc, $0c, $01, $00 '-' ptr_L__0017_ '-' long @LR__0029 byte $e7, $0c, $01, $00 '-' ptr_L__0018_ '-' long @LR__0030 byte $f2, $0c, $01, $00 '-' ptr_L__0027_ '-' long @LR__0031 byte $fc, $0c, $01, $00 '-' ptr_L__0028_ '-' long @LR__0032 byte $13, $0d, $01, $00 '-' ptr_stackspace_ '-' long @stackspace byte $ba, $0d, $01, $00 '-' result1 '-' long 0 byte $00, $00, $00, $00 '-' COG_BSS_START byte $00[1868] '-' fit 496 '-' orgh $10800 '-' long 80000000 byte $00, $b4, $c4, $04 '-' long 100 byte $64, $00, $00, $00 '-' hubentry '-' '-' ' '-' ' PUB demo | c '-' _demo '-' wrlong local01, ptra++ byte $61, $69, $64, $fc '-' wrlong local02, ptra++ byte $61, $6b, $64, $fc '-' ' clkset(oscmode, freq) '-' mov arg01, ##17579780 byte $1f, $86, $00, $ff, $04, $61, $04, $f6 '-' mov arg02, ##160000000 byte $b4, $c4, $04, $ff, $00, $62, $04, $f6 '-' mov arg03, #3 byte $03, $64, $04, $f6 '-' calla #@__system__clkset byte $88, $04, $d0, $fd '-' ' ser.start(63, 62, 0, baud) '-' mov arg01, #63 byte $3f, $60, $04, $f6 '-' mov arg02, #62 byte $3e, $62, $04, $f6 '-' mov arg03, #0 byte $00, $64, $04, $f6 '-' mov arg04, ##2000000 byte $42, $0f, $00, $ff, $80, $66, $04, $f6 '-' calla #@_SmartSerial_start byte $ac, $02, $d0, $fd '-' ' rom.start(_rom_tx_pin+1, _rom_rx_pin+1, 0, _rom_baud) '-' mov arg01, #54 byte $36, $60, $04, $f6 '-' mov arg02, #52 byte $34, $62, $04, $f6 '-' mov arg03, #0 byte $00, $64, $04, $f6 '-' mov arg04, ##115200 byte $e1, $00, $00, $ff, $00, $66, $04, $f6 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_start byte $80, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' ' '-' ' repeat 30000 '-' mov local01, ##30000 byte $3a, $00, $00, $ff, $30, $69, $04, $f6 '-' LR__0001 '-' ' '-' ' if (c:=rom.rxcheck)>-1 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_rxcheck byte $f0, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0002 byte $08, $00, $90, $ed '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $b4, $02, $d0, $fd '-' LR__0002 '-' ' if (c:=ser.rxcheck)>-1 '-' calla #@_SmartSerial_rxcheck byte $dc, $02, $d0, $fd '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0003 byte $10, $00, $90, $ed '-' ' rom.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_tx byte $88, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' LR__0003 '-' djnz local01, #@LR__0001 byte $ed, $69, $6c, $fb '-' ' '-' ' rom.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_tx byte $74, $03, $d0, $fd '-' ' rom.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $6c, $03, $d0, $fd '-' ' rom.str(string("56 BLINK",13,10)) '-' mov arg01, ptr_L__0016_ byte $26, $60, $00, $f6 '-' calla #@_TaqozSerial_str byte $ac, $03, $d0, $fd '-' ' rom.str(string("57 BLINK",13,10)) '-' mov arg01, ptr_L__0017_ byte $27, $60, $00, $f6 '-' calla #@_TaqozSerial_str byte $a4, $03, $d0, $fd '-' ' rom.str(string("2 2 + .",13,10)) '-' mov arg01, ptr_L__0018_ byte $28, $60, $00, $f6 '-' calla #@_TaqozSerial_str byte $9c, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' ' '-' ' repeat '-' LR__0004 '-' ' '-' ' if (c:=rom.rxcheck)>-1 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_rxcheck byte $74, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0005 byte $08, $00, $90, $ed '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $38, $02, $d0, $fd '-' LR__0005 '-' ' if (c:=ser.rxcheck)>-1 '-' calla #@_SmartSerial_rxcheck byte $60, $02, $d0, $fd '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0006 byte $10, $00, $90, $ed '-' ' rom.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_tx byte $0c, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' LR__0006 '-' jmp #@LR__0004 byte $b4, $ff, $9f, $fd '-' ' '-' ' '-' ' '-' ' repeat '-' LR__0007 '-' ' repeat while ((c:=rom.rxcheck)>-1) '-' LR__0008 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_rxcheck byte $28, $03, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0009 byte $0c, $00, $90, $ed '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $ec, $01, $d0, $fd '-' jmp #@LR__0008 byte $d8, $ff, $9f, $fd '-' LR__0009 '-' ' ser.str(string("EnterTAQOZ one liner",13,10)) '-' mov arg01, ptr_L__0027_ byte $29, $60, $00, $f6 '-' calla #@_SmartSerial_str byte $4c, $02, $d0, $fd '-' ' ser.str(string("EnterTAQOZ one liner",13,10)) '-' mov arg01, ptr_L__0028_ byte $2a, $60, $00, $f6 '-' calla #@_SmartSerial_str byte $44, $02, $d0, $fd '-' ' getinput '-' calla #@_getinput byte $dc, $00, $d0, $fd '-' ' ser.str(@name) '-' add objptr, #16 byte $10, $4a, $04, $f1 '-' mov arg01, objptr byte $25, $60, $00, $f6 '-' sub objptr, #16 byte $10, $4a, $84, $f1 '-' calla #@_SmartSerial_str byte $30, $02, $d0, $fd '-' ' ser.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' calla #@_SmartSerial_tx byte $bc, $01, $d0, $fd '-' ' ser.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_SmartSerial_tx byte $b4, $01, $d0, $fd '-' ' '-' ' rom.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_tx byte $9c, $02, $d0, $fd '-' ' rom.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $94, $02, $d0, $fd '-' ' rom.str(@name) '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' mov arg01, objptr byte $25, $60, $00, $f6 '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' calla #@_TaqozSerial_str byte $cc, $02, $d0, $fd '-' ' rom.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $7c, $02, $d0, $fd '-' ' rom.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $74, $02, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' ' repeat while ((c:=rom.rxcheck)>-1) '-' LR__0010 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_rxcheck byte $94, $02, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0011 byte $0c, $00, $90, $ed '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $58, $01, $d0, $fd '-' jmp #@LR__0010 byte $d8, $ff, $9f, $fd '-' LR__0011 '-' ' rom.str(@name) '-' add objptr, #16 byte $10, $4a, $04, $f1 '-' mov arg01, objptr byte $25, $60, $00, $f6 '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' calla #@_TaqozSerial_str byte $80, $02, $d0, $fd '-' ' rom.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $30, $02, $d0, $fd '-' ' rom.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_TaqozSerial_tx byte $28, $02, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' ' repeat while ((c:=rom.rxcheck)>-1) '-' LR__0012 '-' add objptr, #8 byte $08, $4a, $04, $f1 '-' calla #@_TaqozSerial_rxcheck byte $48, $02, $d0, $fd '-' sub objptr, #8 byte $08, $4a, $84, $f1 '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' cmps local02, ##-1 wcz byte $ff, $ff, $7f, $ff, $ff, $6b, $5c, $f2 '-' if_be jmp #@LR__0013 byte $0c, $00, $90, $ed '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $0c, $01, $d0, $fd '-' jmp #@LR__0012 byte $d8, $ff, $9f, $fd '-' LR__0013 '-' jmp #@LR__0007 byte $f4, $fe, $9f, $fd '-' rdlong local02, --ptra byte $5f, $6b, $04, $fb '-' rdlong local01, --ptra byte $5f, $69, $04, $fb '-' _demo_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' '-' ' PUB getinput | c, i '-' _getinput '-' wrlong local01, ptra++ byte $61, $69, $64, $fc '-' wrlong local02, ptra++ byte $61, $6b, $64, $fc '-' wrlong local03, ptra++ byte $61, $6d, $64, $fc '-' ' i := 0 '-' mov local01, #0 byte $00, $68, $04, $f6 '-' ' repeat '-' LR__0014 '-' ' c := ser.rx '-' calla #@_SmartSerial_rx byte $2c, $01, $d0, $fd '-' mov local02, result1 byte $2c, $6a, $00, $f6 '-' ' if (c == 8) '-' cmp local02, #8 wz byte $08, $6a, $0c, $f2 '-' if_ne jmp #@LR__0016 byte $18, $00, $90, $5d '-' ' if i > 0 '-' cmps local01, #0 wcz byte $00, $68, $5c, $f2 '-' if_be jmp #@LR__0015 byte $0c, $00, $90, $ed '-' ' --i '-' sub local01, #1 byte $01, $68, $84, $f1 '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $c4, $00, $d0, $fd '-' LR__0015 '-' jmp #@LR__0019 byte $44, $00, $90, $fd '-' LR__0016 '-' ' elseif (c == 13) or (c == 10) '-' cmp local02, #13 wz byte $0d, $6a, $0c, $f2 '-' if_e jmp #@LR__0017 byte $08, $00, $90, $ad '-' cmp local02, #10 wz byte $0a, $6a, $0c, $f2 '-' if_ne jmp #@LR__0018 byte $14, $00, $90, $5d '-' LR__0017 '-' ' ser.tx(13) '-' mov arg01, #13 byte $0d, $60, $04, $f6 '-' calla #@_SmartSerial_tx byte $a8, $00, $d0, $fd '-' ' ser.tx(10) '-' mov arg01, #10 byte $0a, $60, $04, $f6 '-' calla #@_SmartSerial_tx byte $a0, $00, $d0, $fd '-' ' quit '-' jmp #@LR__0020 byte $24, $00, $90, $fd '-' ' else '-' LR__0018 '-' ' name[i++] := c '-' mov local03, local01 byte $34, $6c, $00, $f6 '-' add objptr, #16 byte $10, $4a, $04, $f1 '-' add local03, objptr byte $25, $6c, $00, $f1 '-' wrbyte local02, local03 byte $36, $6a, $40, $fc '-' ' ser.tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' sub objptr, #16 byte $10, $4a, $84, $f1 '-' add local01, #1 byte $01, $68, $04, $f1 '-' calla #@_SmartSerial_tx byte $7c, $00, $d0, $fd '-' LR__0019 '-' jmp #@LR__0014 byte $90, $ff, $9f, $fd '-' LR__0020 '-' ' name[i] := 0 '-' add objptr, #16 byte $10, $4a, $04, $f1 '-' add local01, objptr byte $25, $68, $00, $f1 '-' mov local03, #0 byte $00, $6c, $04, $f6 '-' wrbyte local03, local01 byte $34, $6c, $40, $fc '-' sub objptr, #16 byte $10, $4a, $84, $f1 '-' rdlong local03, --ptra byte $5f, $6d, $04, $fb '-' rdlong local02, --ptra byte $5f, $6b, $04, $fb '-' rdlong local01, --ptra byte $5f, $69, $04, $fb '-' _getinput_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' PUB start(rxpin, txpin, mode, baudrate) | bitperiod, txmode, rxmode '-' _SmartSerial_start '-' ' bitperiod := 7 + ((CLKFREQ / baudrate) << 16) '-' rdlong muldiva_, ##2048 byte $04, $00, $00, $ff, $00, $6e, $04, $fb '-' mov muldivb_, arg04 byte $33, $70, $00, $f6 '-' calla #divide_ byte $19, $00, $c0, $fd '-' shl muldivb_, #16 byte $10, $70, $64, $f0 '-' mov _var01, #7 byte $07, $5a, $04, $f6 '-' add _var01, muldivb_ byte $38, $5a, $00, $f1 '-' ' rx_pin := rxpin '-' wrlong arg01, objptr byte $25, $60, $60, $fc '-' ' tx_pin := txpin '-' add objptr, #4 byte $04, $4a, $04, $f1 '-' wrlong arg02, objptr byte $25, $62, $60, $fc '-' sub objptr, #4 byte $04, $4a, $84, $f1 '-' ' txmode := _txmode '-' mov _var02, #124 byte $7c, $5c, $04, $f6 '-' ' rxmode := _rxmode '-' mov _var03, #62 byte $3e, $5e, $04, $f6 '-' ' asm '-' wrpin _var02, arg02 byte $31, $5c, $00, $fc '-' wxpin _var01, arg02 byte $31, $5a, $10, $fc '-' dirh arg02 byte $41, $62, $60, $fd '-' wrpin _var03, arg01 byte $30, $5e, $00, $fc '-' wxpin _var01, arg01 byte $30, $5a, $10, $fc '-' dirh arg01 byte $41, $60, $60, $fd '-' ' return 1 '-' mov result1, #1 byte $01, $58, $04, $f6 '-' _SmartSerial_start_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' PUB tx(val) | txpin, z '-' _SmartSerial_tx '-' ' txpin := tx_pin '-' add objptr, #4 byte $04, $4a, $04, $f1 '-' rdlong _var01, objptr byte $25, $5a, $00, $fb '-' sub objptr, #4 byte $04, $4a, $84, $f1 '-' ' asm '-' wypin arg01, _var01 byte $2d, $60, $20, $fc '-' waitx #1 byte $1f, $02, $64, $fd '-' ' z := 1 '-' mov _var02, #1 wz byte $01, $5c, $0c, $f6 '-' ' repeat while z <> 0 '-' LR__0021 '-' ' asm '-' testp _var01 wc byte $40, $5a, $70, $fd '-' if_b mov _var02, #0 byte $00, $5c, $04, $c6 '-' cmp _var02, #0 wz byte $00, $5c, $0c, $f2 '-' if_ne jmp #@LR__0021 byte $f0, $ff, $9f, $5d '-' _SmartSerial_tx_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' ' check if byte received (never waits) '-' ' ' returns -1 if no byte, otherwise byte '-' ' '-' ' PUB rxcheck : rxbyte | rxpin, z '-' _SmartSerial_rxcheck '-' ' rxbyte := -1 '-' mov result1, ##-1 byte $ff, $ff, $7f, $ff, $ff, $59, $04, $f6 '-' ' rxpin := rx_pin '-' rdlong _var01, objptr byte $25, $5a, $00, $fb '-' ' asm '-' testp _var01 wc byte $40, $5a, $70, $fd '-' if_b rdpin result1, _var01 byte $2d, $58, $88, $ca '-' if_b shr result1, #24 byte $18, $58, $44, $c0 '-' _SmartSerial_rxcheck_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' ' receive a byte (waits until one ready) '-' ' PUB rx : v '-' _SmartSerial_rx '-' wrlong local01, ptra++ byte $61, $69, $64, $fc '-' ' repeat '-' LR__0022 '-' ' v := rxcheck '-' calla #@_SmartSerial_rxcheck byte $dc, $ff, $df, $fd '-' mov local01, result1 byte $2c, $68, $00, $f6 '-' cmp local01, ##-1 wz byte $ff, $ff, $7f, $ff, $ff, $69, $0c, $f2 '-' if_e jmp #@LR__0022 byte $ec, $ff, $9f, $ad '-' mov result1, local01 byte $34, $58, $00, $f6 '-' rdlong local01, --ptra byte $5f, $69, $04, $fb '-' _SmartSerial_rx_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' while v == -1 '-' ' '-' ' ' transmit a string '-' ' PUB str(s) | c '-' _SmartSerial_str '-' wrlong local01, ptra++ byte $61, $69, $64, $fc '-' wrlong local02, ptra++ byte $61, $6b, $64, $fc '-' mov local01, arg01 byte $30, $68, $00, $f6 '-' ' REPEAT WHILE ((c := byte[s++]) <> 0) '-' LR__0023 '-' rdbyte local02, local01 wz byte $34, $6a, $c8, $fa '-' add local01, #1 byte $01, $68, $04, $f1 '-' if_e jmp #@LR__0024 byte $0c, $00, $90, $ad '-' ' tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_SmartSerial_tx byte $74, $ff, $df, $fd '-' jmp #@LR__0023 byte $e8, $ff, $9f, $fd '-' LR__0024 '-' rdlong local02, --ptra byte $5f, $6b, $04, $fb '-' rdlong local01, --ptra byte $5f, $69, $04, $fb '-' _SmartSerial_str_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' PUB start(rxpin, txpin, mode, baudrate) | bitperiod, txmode, rxmode '-' _TaqozSerial_start '-' ' bitperiod := 7 + ((CLKFREQ / baudrate) << 16) '-' rdlong muldiva_, ##2048 byte $04, $00, $00, $ff, $00, $6e, $04, $fb '-' mov muldivb_, arg04 byte $33, $70, $00, $f6 '-' calla #divide_ byte $19, $00, $c0, $fd '-' shl muldivb_, #16 byte $10, $70, $64, $f0 '-' mov _var01, #7 byte $07, $5a, $04, $f6 '-' add _var01, muldivb_ byte $38, $5a, $00, $f1 '-' ' rx_pin := rxpin '-' wrlong arg01, objptr byte $25, $60, $60, $fc '-' ' tx_pin := txpin '-' add objptr, #4 byte $04, $4a, $04, $f1 '-' wrlong arg02, objptr byte $25, $62, $60, $fc '-' sub objptr, #4 byte $04, $4a, $84, $f1 '-' ' txmode := _txmode '-' mov _var02, #124 byte $7c, $5c, $04, $f6 '-' ' rxmode := _rxmode '-' mov _var03, ##1879048254 byte $00, $00, $38, $ff, $3e, $5e, $04, $f6 '-' ' asm '-' wrpin _var02, arg02 byte $31, $5c, $00, $fc '-' wxpin _var01, arg02 byte $31, $5a, $10, $fc '-' dirh arg02 byte $41, $62, $60, $fd '-' wrpin _var03, arg01 byte $30, $5e, $00, $fc '-' wxpin _var01, arg01 byte $30, $5a, $10, $fc '-' dirh arg01 byte $41, $60, $60, $fd '-' ' return 1 '-' mov result1, #1 byte $01, $58, $04, $f6 '-' _TaqozSerial_start_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' PUB tx(val) | txpin, z '-' _TaqozSerial_tx '-' ' txpin := tx_pin '-' add objptr, #4 byte $04, $4a, $04, $f1 '-' rdlong _var01, objptr byte $25, $5a, $00, $fb '-' sub objptr, #4 byte $04, $4a, $84, $f1 '-' ' asm '-' wypin arg01, _var01 byte $2d, $60, $20, $fc '-' waitx #1 byte $1f, $02, $64, $fd '-' ' z := 1 '-' mov _var02, #1 wz byte $01, $5c, $0c, $f6 '-' ' repeat while z <> 0 '-' LR__0025 '-' ' asm '-' testp _var01 wc byte $40, $5a, $70, $fd '-' if_b mov _var02, #0 byte $00, $5c, $04, $c6 '-' cmp _var02, #0 wz byte $00, $5c, $0c, $f2 '-' if_ne jmp #@LR__0025 byte $f0, $ff, $9f, $5d '-' _TaqozSerial_tx_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' '-' ' ' check if byte received (never waits) '-' ' ' returns -1 if no byte, otherwise byte '-' ' '-' ' PUB rxcheck : rxbyte | rxpin, z '-' _TaqozSerial_rxcheck '-' ' rxbyte := -1 '-' mov result1, ##-1 byte $ff, $ff, $7f, $ff, $ff, $59, $04, $f6 '-' ' rxpin := rx_pin '-' rdlong _var01, objptr byte $25, $5a, $00, $fb '-' ' asm '-' testp _var01 wc byte $40, $5a, $70, $fd '-' if_b rdpin result1, _var01 byte $2d, $58, $88, $ca '-' if_b shr result1, #24 byte $18, $58, $44, $c0 '-' _TaqozSerial_rxcheck_ret '-' reta byte $2e, $00, $64, $fd '-' '-' ' while v == -1 '-' ' '-' ' ' transmit a string '-' ' PUB str(s) | c '-' _TaqozSerial_str '-' wrlong local01, ptra++ byte $61, $69, $64, $fc '-' wrlong local02, ptra++ byte $61, $6b, $64, $fc '-' mov local01, arg01 byte $30, $68, $00, $f6 '-' ' REPEAT WHILE ((c := byte[s++]) <> 0) '-' LR__0026 '-' rdbyte local02, local01 wz byte $34, $6a, $c8, $fa '-' add local01, #1 byte $01, $68, $04, $f1 '-' if_e jmp #@LR__0027 byte $0c, $00, $90, $ad '-' ' tx(c) '-' mov arg01, local02 byte $35, $60, $00, $f6 '-' calla #@_TaqozSerial_tx byte $98, $ff, $df, $fd '-' jmp #@LR__0026 byte $e8, $ff, $9f, $fd '-' LR__0027 '-' rdlong local02, --ptra byte $5f, $6b, $04, $fb '-' rdlong local01, --ptra byte $5f, $69, $04, $fb '-' _TaqozSerial_str_ret '-' reta byte $2e, $00, $64, $fd '-' hubexit '-' jmp #cogexit byte $04, $00, $80, $fd '-' '-' ' $e == known to be in HUB memory (so no specific COG owner) '-' __system__clkset '-' ' $f == free '-' wrlong arg02, ##2048 byte $04, $00, $00, $ff, $00, $62, $64, $fc '-' ' $10 = reserved (never free automatically) '-' wrlong arg01, ##2052 byte $04, $00, $00, $ff, $04, $60, $64, $fc '-' ' $20 = inuse (block was observed to be in use during GC) '-' hubset #0 byte $00, $00, $64, $fd '-' hubset arg01 byte $00, $60, $60, $fd '-' waitx ##200000 byte $86, $01, $80, $ff, $1f, $80, $66, $fd '-' add arg01, arg03 byte $32, $60, $00, $f1 '-' hubset arg01 byte $00, $60, $60, $fd '-' __system__clkset_ret '-' reta byte $2e, $00, $64, $fd '-' '-' LR__0028 '-' byte "56 BLINK" byte $35, $36, $20, $42, $4c, $49, $4e, $4b '-' byte 13 byte $0d '-' byte 10 byte $0a '-' byte 0 byte $00 '-' LR__0029 '-' byte "57 BLINK" byte $35, $37, $20, $42, $4c, $49, $4e, $4b '-' byte 13 byte $0d '-' byte 10 byte $0a '-' byte 0 byte $00 '-' LR__0030 '-' byte "2 2 + ." byte $32, $20, $32, $20, $2b, $20, $2e '-' byte 13 byte $0d '-' byte 10 byte $0a '-' byte 0 byte $00 '-' LR__0031 '-' byte "EnterTAQOZ one liner" byte $45, $6e, $74, $65, $72, $54, $41, $51, $4f, $5a, $20, $6f, $6e, $65, $20, $6c byte $69, $6e, $65, $72 '-' byte 13 byte $0d '-' byte 10 byte $0a '-' byte 0 byte $00 '-' LR__0032 '-' byte "EnterTAQOZ one liner" byte $45, $6e, $74, $65, $72, $54, $41, $51, $4f, $5a, $20, $6f, $6e, $65, $20, $6c byte $69, $6e, $65, $72 '-' byte 13 byte $0d '-' byte 10 byte $0a '-' byte 0 byte $00 '-' objmem '-' long 0[36] byte $00[144] '-' stackspace '-' long 0[1] byte $00, $00, $00, $00 '-' org COG_BSS_START '-' _var01 '-' res 1 '-' _var02 '-' res 1 '-' _var03 '-' res 1 '-' arg01 '-' res 1 '-' arg02 '-' res 1 '-' arg03 '-' res 1 '-' arg04 '-' res 1 '-' local01 '-' res 1 '-' local02 '-' res 1 '-' local03 '-' res 1 '-' muldiva_ '-' res 1 '-' muldivb_ byte $00, $00