[[作品例]]

* FPGAでエレクラブを動かす [#q9b77dfb]
- 高松の電子工作グループ「えれくら」(https://www.facebook.com/elecra296)で作られた「えれくらぶ」をFPGAの miniCPUで動かしてみます(えれくらさんに感謝します)。
- 高松の電子工作グループ「えれくら」(https://www.facebook.com/elecra296 )で作られた「えれくらぶ」をFPGAの miniCPUで動かしてみます(えれくらさんに感謝します)。
-- えれくらぶ: http://www64.atwiki.jp/elecra296/pages/29.html
- 光センサで光を感じたら歩き出し、暗くすると止まります。
- 動きを工夫してみてください。センサを加えて、その入力の組み合わせで動作を変える、というのにも挑戦してみてください。
* 動画と写真 [#mdd1eef1]
- 学生さん達の作品の動画です。
-- その1. https://www.youtube.com/watch?v=fW3lvfMit28
-- その2. https://www.youtube.com/watch?v=2ng4ymnDvx0
-- その3. https://www.youtube.com/watch?v=DrolYMI_PmM
-- その4. https://www.youtube.com/watch?v=juk0ILjAEOI
- 私のサンプル(以下の ram.v)で動かした youtube の動画です。
-- https://www.youtube.com/watch?v=dOWk0cgx4Us
- 写真
-- &ref(エレクラブ/elecrub-small.jpg,30%); &ref(エレクラブ/elecrub-small-2.jpg,30%);
* 回路 [#xb79ac2e]
-- [[光センサの値でサーボモータを制御]]と同じです。
* verilog [#s6fb19e4]
- ram.v

 module ram(clk, load, addr, d, q
 );
 parameter DWIDTH=16, AWIDTH=12, WORDS=4096;
 
 input clk, load;
 input [AWIDTH-1:0] addr;
 input [DWIDTH-1:0] d;
 output [DWIDTH-1:0] q;
 reg [DWIDTH-1:0] q;
 reg [DWIDTH-1:0] mem [WORDS-1:0];
 
 always @(posedge clk)
 begin
 if(load) mem[addr] <= d;
 q <= mem[addr];
 end
 
 integer i;
 initial begin
 for(i=0; i<WORDS; i=i+1)
 mem[i]=12'h000;
 /*
 // Elecrab example 1.
 //   use Ada fruit PCA9685 I2C PWM controller
 //
 // initialize
 main_start:  pushi main_a0
 			 jmp servoInit    // initialize the I2C servo motor driver(PWM controller)
 main_a0: jz main_loop
 			 pushi 0x03
 			 out
          halt
 			 jmp main_start
 // move to center
 main_loop: pushi main_lightVal
          pushi main_getLight
 			 jmp getLight          // get light intensity
 main_getLight: jz main_judge
          pushi 0x07
 			 out
          halt
 			 jmp main_loop
 main_judge: push main_lightVal
             push 0x03
 				 bor
 				 out
             pushi 0x0100
 			    pushi main_judge_1       // wait
 			    jmp waitLoop
 main_judge_1: jz main_judge_2
 			 pushi 0x07
 			 out
 			 halt
 			 jmp main_loop				 
 main_judge_2: in        // get reference data from the slide-sws
           pushi 0x08
      	  shr
           pushi 0x00ff  
  			  band
           push main_lightVal
 			 pushi 0x00ff
 			 band
 			 gt
 			 jnz main_move   // if getLight()<sw then goto main_move else goto main_stop
 // when dark, turn left
 main_stop: pushi main_stop_1
          jmp stopServo
 main_stop_1: jz main_wait
          pushi 0x0b
 			 out
          halt
          jmp main_loop
 main_move: pushi main_move_1 
          jmp oneStep
 main_move_1: jz main_wait
          pushi 0x0f
 			 out
          halt
 			 jmp main_loop
 // when bright, turn right
 main_wait: pushi 0x0040
 			 pushi main_loopEnd       // wait
 			 jmp waitLoop
 main_loopEnd: jz main_loop
 			 pushi 0x013
 			 out
 			 halt
 			 jmp main_loop
 main_error: 0x0000
 main_lightVal: 0x0000
 //
 // elecrab one step.
 //   use Ada fruit PCA9685 I2C PWM controller
 //
 oneStep: push oneStep_jmp
 			 bor
          pop oneStep_rtn
 oneStep_a0_1: pushi 0    // move ch0 servo 0-> -90 -> 0 -> 90 >0
 			 push servoHalfMax
 			 push servoCh1
 			 push servoAddr
 			 pushi oneStep_a1
 			 jmp wi2c4           // move ch1 to half max
 oneStep_a1: jz oneStep_a1_1
 			 pushi 0x01
          jmp oneStep_rtn
 // wait
 oneStep_a1_1: pushi 0x0200
 			 pushi oneStep_a2
 			 jmp waitLoop        // wait
 oneStep_a2: jz oneStep_a2_1
          pushi 0x02
 			 jmp oneStep_rtn
 //          halt
 // move to min
 oneStep_a2_1: pushi 0  
 			 push servoHalfMax
 			 push servoCh0
 			 push servoAddr
 			 pushi oneStep_a3
 			 jmp wi2c4           // move ch0 to half max
 oneStep_a3: jz oneStep_a3_1
          pushi 0x03
 			 jmp oneStep_rtn
 //          halt
 // wait
 oneStep_a3_1: pushi 0x0200
 			 pushi oneStep_a4       // wait
 			 jmp waitLoop
 oneStep_a4: jz oneStep_a4_1
          pushi 0x04
 			 jmp oneStep_rtn
 //          halt
 // move to center
 oneStep_a4_1: pushi 0
 			 push servoHalfMin
 			 push servoCh1
 			 push servoAddr
 			 pushi oneStep_a5
 			 jmp wi2c4          // move ch1 to half min
 oneStep_a5: jz oneStep_a5_1
          pushi 0x05
 			 jmp oneStep_rtn
 //          halt
 // wait
 oneStep_a5_1:  pushi 0x0200
 			 pushi oneStep_a6
 			 jmp waitLoop        // wait
  oneStep_a6: jz oneStep_a6_1
          pushi 0x06
 			 jmp oneStep_rtn
 			 halt
 // move to max
 oneStep_a6_1: pushi 0
 			 push servoHalfMin
 			 push servoCh0
 			 push servoAddr
 			 pushi oneStep_a7
 			 jmp wi2c4           // move ch0 to half min
 oneStep_a7: jz oneStep_a7_1
          pushi 0x07
 			 jmp oneStep_rtn
 //          halt
 // wait
 oneStep_a7_1: pushi 0x0200
 			 pushi oneStep_a8
 			 jmp waitLoop        // wait
 oneStep_a8: jz oneStep_end
          pushi 0x08
 			 jmp oneStep_rtn
 			 halt
 // move to center
 oneStep_end:  pushi 0
 oneStep_rtn:  0x0000	//return
 oneStep_jmp: 0x4000
 //
 oneStep_rcode: 0x0000
 //
 // move center and stop servos
 //
  stopServo: push stopServo_jmp
 			 bor
          pop stopServo_rtn
 stopServo_a0_1: pushi 0    
 			 push servoCen
 			 push servoCh0
 			 push servoAddr
 			 pushi stopServo_a1
 			 jmp wi2c4           // move ch0 to center
 stopServo_a1: jz stopServo_a1_1
 			 pushi 0x01
          jmp stopServo_rtn
 // wait
 stopServo_a1_1: pushi 0x0004
 			 pushi stopServo_a2
 			 jmp waitLoop        // wait
 stopServo_a2: jz stopServo_a2_1
          pushi 0x02
 			 jmp stopServo_rtn
 //          halt
 // move to min
 stopServo_a2_1: pushi 0  
 			 push servoCen
 			 push servoCh1
 			 push servoAddr
 			 pushi stopServo_a3
 			 jmp wi2c4           // move ch1 to center
 stopServo_a3: jz stopServo_a3_1
          pushi 0x03
 			 jmp stopServo_rtn
 //          halt
 // wait
 stopServo_a3_1: pushi 0x200
 			 pushi stopServo_a8
 			 jmp waitLoop        // wait
 stopServo_a8: jz stopServo_end
          pushi 0x08
 			 jmp stopServo_rtn
 stopServo_end:  pushi 0x00
 stopServo_rtn:  0x0000	//return
 stopServo_jmp: 0x4000
 //
 stopServo_rcode: 0x0000
 // move servo 0 to 100
 // move servo 1 to -100
 // wait
 // move servo 0 to -100
 // move servo 1 to 100
 //
 // initialize
 //   uint8_t oldmode = read8(PCA9685_MODE1);
 //   uint8_t newmode = (oldmode&0x7F) | 0x10; // sleep                             
 //   write8(PCA9685_MODE1, newmode); // go to sleep                                
 //   write8(PCA9685_PRESCALE, prescale); // set the prescaler                      
 //   write8(PCA9685_MODE1, oldmode);
 //   delay(5);
 //   write8(PCA9685_MODE1, oldmode | 0xa1);  //  This sets the MODE1 register to turn on auto  increment.
 //
 //   get current status
 //   sleep
 //   set new status
 //   set prescale
 // prescale = - 25000000/(4096*60*0.9) = 0xFF8F
 //
 //   wake up
 //
 // servoInit
 //    initialize the i2c PWM controller PCA9685 as the servo motor device.
 //    arg0 : return address
 //
  servoInit: push servoInit_jmp
 			 bor
          pop servoInit_rtn
 			 pushi 0x00
 			 push servoMode1
 			 push servoAddr
 			 pushi servoInit_a0
 			 jmp wi2c1
 servoInit_a0: pop servoInit_RtnCode
          push servoInit_RtnCode
			 jz servoInit_a0_1
			 push servoInit_RtnCode //error
			 out
			 halt
			 pushi 11
			 jmp servoInit_rtn
 servoInit_a0_1: pushi servoMode1Val
			 push servoMode1
			 push servoAddr
			 pushi servoInit_a1
			 jmp ri2c1                        // read current value of the mode-1 register
 servoInit_a1: pop servoInit_RtnCode
          push servoInit_RtnCode
          jz servoInit_a1_1
          push servoInit_RtnCode // error
			 out
			 halt
			 pushi 1
			 jmp servoInit_rtn
 servoInit_a1_1: push servoMode1Val
			 pushi 0x7f
			 band
			 pushi 0x10
			 bor
			 push servoMode1
			 push servoAddr
			 pushi servoInit_a2
			 jmp wi2c1                      // set the sleep mode on, restart disabled     40> 00+ 10+
 servoInit_a2: pop servoInit_RtnCode
          push servoInit_RtnCode
          jz servoInit_a2_1
          push servoInit_RtnCode // error
			 out
			 halt
			 pushi 2
			 jmp servoInit_rtn
 servoInit_a2_1: pushi 0x70
			 push servoPreScale
			 push servoAddr
			 pushi servoInit_a3
			 jmp wi2c1                    // set the pwm frequency prescale register   40> fe+ 70+
 servoInit_a3: pop servoInit_RtnCode
          push servoInit_RtnCode
          jz servoInit_a3_1
          push servoInit_RtnCode // error
			 out
			 halt
			 pushi 3
			 jmp servoInit_rtn
 servoInit_a3_1:  push servoMode1Val
			 push servoMode1
			 push servoAddr
			 pushi servoInit_a4
			 jmp wi2c1                   // recover the mode-1 register, .... wake up.  40> 00+ 00+ 
 servoInit_a4: pop servoInit_RtnCode
          push servoInit_RtnCode
          jz servoInit_a4_1
          push servoInit_RtnCode // error
			 out
			 halt
			 pushi 4
			 jmp servoInit_rtn
 servoInit_a4_1: pushi 0x000f
			 pushi servoInit_a5
			 jmp waitLoop
 servoInit_a5: pop servoInit_RtnCode
//          pushi 5
//			 out
//         halt
          push servoMode1Val
			 pushi 0x00a1
			 bor
			 push servoMode1
          push servoAddr
			 pushi servoInit_a6
			 jmp wi2c1               // set the mode-1 register to incremental mode.   40> 00+ a1+
 servoInit_a6: pop servoInit_RtnCode
         push servoInit_RtnCode
          jz servoInit_a6_1
          push servoInit_RtnCode // error
			 out
			 halt
			 pushi 6
			 jmp servoInit_rtn
 servoInit_a6_1:  pushi 0
 servoInit_rtn: 0x0000	//return
 servoInit_jmp: 0x4000
 servoAddr: 0x0040
 servoMode1: 0x0000
 servoMode1Val: 0x0000
 servoPreScale: 0x00fe 
 servoCh0: 0x0006
 servoCh1: 0x000a
 servoCh2: 0x000e
 servoCh3: 0x0012
 servoCh4: 0x0016
 servoCh5: 0x001a
 servoCh6: 0x001e
 servoCh7: 0x0022
 servoCh8: 0x0026
 servoCh9: 0x002a
 servoCh10: 0x002e
 servoCh11: 0x0032
 servoCh12: 0x0036
 servoCh13: 0x003a
 servoCh14: 0x003e
 servoCh15: 0x0042
 servoMin: 0x0096 // (150)10
 servoMax: 0x0258 // (600)10
 servoHalfMin: 0x0106 // (262)10
 servoHalfMax: 0x1e7  // (487)10
 servoCen: 0x0177 //(375)10
 servoInitPrescale: 0xff8f // prescale = - 25000000/(4096*60*0.9) = 0xFF8F
 servoInit_RtnCode: 0x0000
 //
 // getLight
 //   get light strength value from the i2c light sensor, grove
 //    arg 0: return address, arg 1: address for the received value
 getLight:  push getLight_jmp
 			  bor
           pop getLight_rtn
			  pop getLight_valAddr
			  //
           pushi 0x03   // power up
			  pushi 0x80   // command, register 0
			  push lightSensorAddr  //lightSensor
			  pushi getLight_a1  // push return addr
			  jmp wi2c1      // call wi2c1
 getLight_a1: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a1_1
			  pushi 1           // error to read the ack of the i2c address
			  jmp getLight_rtn
           //
 getLight_a1_1: pushi 0x00  // 
           pushi 0x81
			  push lightSensorAddr
			  pushi getLight_a2
			  jmp wi2c1
 getLight_a2: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a2_1
			  pushi 2           // error to read the ack of the i2c address
			  jmp getLight_rtn
 //
 getLight_a2_1: pushi 0x00  // scale
           pushi 0x86   // register to set the scale
			  push lightSensorAddr // lightSensor
			  pushi getLight_a3
			  jmp wi2c1
 getLight_a3: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a3_1
			  pushi 3           // error to read the ack of the i2c address
			  jmp getLight_rtn
 //
 getLight_a3_1:  pushi 0x00 // power down
           pushi 0x80
			  push lightSensorAddr
			  pushi getLight_a4
			  jmp wi2c1
 getLight_a4: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a4_1
			  pushi 4           // error to read the ack of the i2c address
			  jmp getLight_rtn
 //
 getLight_a4_1:  pushi 0x03 // power up again
           pushi 0x80
			  push lightSensorAddr
           pushi getLight_a5
			  jmp wi2c1
 getLight_a5: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a5_1
			  pushi 5           // error to read the ack of the i2c address
			  jmp getLight_rtn
 //        
 getLight_a5_1:  PUSHI lightSensorCh0l  // push arg1... the address for receiving the result(temprature)
           PUSHi 0x8c     // push the register no. 0
           push lightSensorAddr       // push the I2C light sensor address, 0x4b
           pushi getLight_a6          // push the return address
           JMP ri2c1    // call the ri2c1 ... read 1 byte data from the i2c device, 
 getLight_a6: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a6_1
			  pushi 6           // error to read the ack of the i2c address
			  jmp getLight_rtn
           //
 getLight_a6_1: PUSHI lightSensorCh0h  // push arg1... the address for receiving the result(temprature)
           PUSHi 0x8d     // push the register no. 0
           push lightSensorAddr       // push the I2C light sensor address, 0x4b
           pushi getLight_a7          // push the return address
           JMP ri2c1    // call the ri2c1 ... read 1 byte data from the i2c device, 
 getLight_a7: pop getLightRtnCode
           push getLightRtnCode
           jz getLight_a7_1
 			  pushi 7           // error to read the ack of the i2c address
			  jmp getLight_rtn
           //
 getLight_a7_1: push getLight_valAddr
           push lightSensorCh0h
           pushi 0x08
			  shr
			  push lightSensorCh0l
			  bor
			  st
			  pushi 0          
 getLight_rtn: jmp 0x0000
 getLight_err: 0x0000
 getLight_valAddr: 0x0000
 getLightRtnCode: 0x0000
 getLight_jmp: 0x4000
 getLight_rtnval: 0x0000
 getLight_valAddr: 0x0000 
 lightSensorCh0l: 0x0000
 lightSensorCh0h: 0x0000
 lightSensorRC0h: 0x008c   // read 1 byte from the register d, IR+visible
 lightSensorRC0l: 0x008d
 lightSensorRC1h: 0x008e
 lightSensorRC1l: 0x008f
 lightSensorAddr: 0x0029   //  grove i2c light sensor
 
 lightReadReg: 0x008d   // read 1 byte from the register d, IR+visible
 lightAddr: 0x0029   //  grove i2c light sensor
 //
 // waitLoop
 //   wait for the arg1 times
 //   arg0: return address, arg1: repeat times
 waitLoop: push waitLoop_jmp
           bor
 			  pop waitLoop_rtn
 			  pop waitLoop_times
 waitLoop_a0:  push waitLoop_times
 			  pushi 1
 			  sub
 			  pop waitLoop_times
 			  push waitLoop_times
 			  jnz waitLoop_a0
 			  pushi 0
 waitLoop_rtn:	 0x0000
 waitLoop_jmp: 0x4000
 waitLoop_times: 0x000
 //
 //
 //
 // wi2c1
 // Write 1 byte to an i2c device
 //   arg 0: return address, arg1:device address, arg2:register no, arg3:1 byte value
 //   return ... if 1: ok, 0: error
 //
 wi2c1:    PUSH wi2c1_jmp    // subroutine. the 1st step to make the return instruction
           BOR               // make the return instruction using arg1 and the previous instruction
           POP wi2c1_rtn     // save the return instruction
           POP wi2c1_addr    // save the arg1, the i2c slave address
           pop wi2c1_reg     // save the arg2, destination register address
           pop wi2c1_val     // save the value which will be assiinged to the destination register.
 //
            PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI wi2c1_a1    // push the return address
           JMP SubI2C1      // call the subroutine
 //
 wi2c1_a1: push wi2c1_addr
           pushi 1
           shl                   // make the i2c device address with the write flag
 //
           pushi wi2c1_a2
           jmp si2c1
 //
 wi2c1_a2: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c1_a3     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c1_a3: in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c1_a3_1
 			  pushi 1           // error to read the ack of the i2c address
 			  jmp wi2c1_err
 wi2c1_a3_1: push wi2c1_reg
           pushi wi2c1_a4
           jmp si2c1
 //
 wi2c1_a4: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c1_a5     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c1_a5: in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c1_a5_1
 			  pushi 2           // error to read the ack of the i2c register no.
 			  jmp wi2c1_err
 wi2c1_a5_1: push  wi2c1_val
           pushi wi2c1_a6
           jmp si2c1
 //
 wi2c1_a6: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c1_a7     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c1_a7: in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c1_a7_1
 			  pushi 3           // error to read the ack of the i2c register val.
 			  jmp wi2c1_err
 wi2c1_a7_1: PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c1_a8     // push the return address
           JMP SubI2C1    // call the subroutine
 //
 wi2c1_a8: pushI 0          
 wi2c1_rtn: jmp 0x000            // return
 wi2c1_err: pop wi2c1_ercode
           PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c1_a9     // push the return address
           JMP SubI2C1    // call the subroutine
 wi2c1_a9: push wi2c1_ercode
           jmp wi2c1_rtn
 wi2c1_jmp: 0x4000
 wi2c1_addr: 0x0000
 wi2c1_reg: 0x0000
 wi2c1_val: 0x0000
 wi2c1\ercode: 0x0000
 //
 // wi2c2
 // Write 2 byte to an i2c device
 //   arg 0: return address, arg1:device address, arg2:register no, arg3:two byte values
 //   return ... if 1: ok, 0: error
 //
 wi2c2:    PUSH wi2c2_jmp    // subroutine. the 1st step to make the return instruction
           BOR               // make the return instruction using arg1 and the previous instruction
           POP wi2c2_rtn     // save the return instruction
           POP wi2c2_addr    // save the arg1, the i2c slave address
           pop wi2c2_reg     // save the arg2, destination register address
           pop wi2c2_val     // save the value which will be assiinged to the destination register.
 //
           PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI wi2c2_a1    // push the return address
           JMP SubI2C1       // call the subroutine
 //
 wi2c2_a1: push wi2c2_addr
           pushi 1
           shl                   // make the i2c device address with the write flag
           pop wi2c2_waddr
 //
           pushi wi2c2_a2
           jmp si2c1
 //
 wi2c2_a2: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c2_a3     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c2_a3: in // input the ack
            pushi 0x01
 			  band
 			  jz wi2c2_a3_1
 			  pushi 1           // error to read the ack of the i2c address
 			  jmp wi2c2_err
 wi2c2_a3_1: push  wi2c2_reg
           pushi wi2c2_a4
           jmp si2c1
 //
 wi2c2_a4: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c2_a5     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c2_a5:  in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c2_a5_1
 			  pushi 2           // error to read the ack of the i2c register no.
 			  jmp wi2c2_err
 wi2c_a5_1: push  wi2c2_val
           pushi 0x00ff
           band
           pushi wi2c2_a6
           jmp si2c1
 //
 wi2c2_a6: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c2_a7     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c2_a7: in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c2_a7_1
 			  pushi 3           // error to read the ack of the i2c register no.
 			  jmp wi2c2_err
  wi2c2_a7_1: push  wi2c2_val
           pushi 8
           shr
           pushi wi2c2_a8
           jmp si2c1
 //
 wi2c2_a8: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c2_a9     //
           JMP SubI2C1    // call the subroutine
 //
 wi2c2_a9: in // input the ack
           pushi 0x01
 			  band
 			  jz wi2c2_a9_1
 			  pushi 4           // error to read the ack of the i2c register no.
 			  jmp wi2c2_err
 wi2c2_a9_1: PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c2_a10     // push the return address
           JMP SubI2C1    // call the subroutine
 //
 wi2c2_a10: pushI 0          
 wi2c2_rtn:  jmp  0x000           // return
 wi2c2_err: pop wi2c2_ercode
           PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c2_a11     // push the return address
           JMP SubI2C1    // call the subroutine
 wi2c2_a11: push wi2c2_ercode
           jmp wi2c2_rtn
 wi2c2_jmp:  0x4000
 wi2c2_addr: 0x0000
 wi2c2_reg:  0x0000
 wi2c2_val:  0x0000
 wi2c2_ercode: 0x0000
//
// wi2c4
// Write 4 byte to an i2c device
//   arg 0: return address, arg1:device address, arg2:register no, arg3:1st 2 byte, arg4: 2nd 2byte,
//   return ... if 1: ok, 0: error
//
 wi2c4:    PUSH wi2c4_jmp    // subroutine. the 1st step to make the return instruction
           BOR               // make the return instruction using arg1 and the previous instruction
           POP wi2c4_rtn     // save the return instruction
           POP wi2c4_addr    // save the arg1, the i2c slave address
           pop wi2c4_reg     // save the arg2, destination register address
           pop wi2c4_val2     // save the 1st value which will be assiinged to the destination registers.
           pop wi2c4_val1     // save the 2nd value which will be assiinged to the destination register2.
//
           PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI wi2c4_a1    // push the return address
           JMP SubI2C1       // call the subroutine
//
 wi2c4_a1: push wi2c4_addr
           pushi 1
           shl                   // make the i2c device address with the write flag
           pushi wi2c4_a2
           jmp si2c1
//
 wi2c4_a2: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a3     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a3: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a3_1
			  pushi 1           // error to read the ack of the i2c address
			  jmp wi2c4_err
 wi2c4_a3_1:  push  wi2c4_reg
           pushi wi2c4_a4
           jmp si2c1
//
 wi2c4_a4: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a5     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a5: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a5_1
			  pushi 2            // error to read the ack of the i2c register no.
			  jmp wi2c4_err
 wi2c4_a5_1:  push  wi2c4_val1
           pushi 0x00ff
           band
           pushi wi2c4_a6
           jmp si2c1
//
 wi2c4_a6: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a7     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a7: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a7_1
			  pushi 3           // error to read the ack of the lsb of the val1
			  jmp wi2c4_err
 wi2c4_a7_1: push  wi2c4_val1
           pushi 8
           shr
           pushi wi2c4_a8
           jmp si2c1
//
 wi2c4_a8: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a9     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a9: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a9_1
			  pushi 4            // error to read the ack of the msb of the val1
			  jmp wi2c4_err
 wi2c4_a9_1: push  wi2c4_val2
           pushi 0x00ff
           band
           pushi wi2c4_a10
           jmp si2c1
//
 wi2c4_a10: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a11     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a11: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a11_1
			  pushi 5            // error to read the ack of the lsb of the val1
			  jmp wi2c4_err
 wi2c4_a11_1:  push  wi2c4_val2
           pushi 8
           shr
           pushi wi2c4_a12
           jmp si2c1
//
 wi2c4_a12: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI wi2c4_a13     //
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a13: in // input the ack
           pushi 0x01
			  band
			  jz wi2c4_a13_1
			  pushi 6            // error to read the ack of the lsb of the val1
			  jmp wi2c4_err
 wi2c4_a13_1: PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c4_a14     // push the return address
           JMP SubI2C1    // call the subroutine
//
 wi2c4_a14: pushI 0          
 wi2c4_rtn: jmp 0x000            // return
 wi2c4_err: pop wi2c4_ercode
           PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI wi2c4_a15     // push the return address
           JMP SubI2C1    // call the subroutine
 wi2c4_a15: push wi2c4_ercode
           jmp wi2c4_rtn 
 wi2c4_jmp:  0x4000
 wi2c4_addr: 0x0000
 wi2c4_reg:  0x0000
 wi2c4_val1: 0x0000
 wi2c4_val2: 0x0000
 wi2c4_ercode: 0x0000
//
// si2c1
// Write 1 byte series to an i2c device
//   ... arg1 ... device address, arg1... register no. arg2... 1 byte value
//    return ... if 1: ok, 0: error
//
 si2c1:      PUSH si2c1_jmp    // subroutine. the 1st step to make the return instruction
             BOR               // make the return instruction using arg1 and the previous instruction
             POP si2c1_rtn     // save the return instruction
             POP si2c1_val
             PUSHI 8
             POP si2c1_i
 si2c1_a3:   push si2c1_val
             pushi 0x0080
             band
             JNZ si2c1_a1
             pushi 0x0000
             out
             pushi 0x0002
             out
             pushi 0x0000
             out
             jmp si2c1_a2
 si2c1_a1:   pushi 0x0001
             out
             pushi 0x0003
             out
             pushi 0x0001
             out
 si2c1_a2:   push si2c1_val
             pushi 1
             shl
             pop  si2c1_val
             push si2c1_i
             pushi 1
             sub
             pop si2c1_i
             push si2c1_i
             jnz si2c1_a3
 si2c1_rtn:  jmp 0x000     
 si2c1_jmp:  0x4000
 si2c1_val:  0x0000
 si2c1_i:    0x0000
 //
 // ri2c1
 // Read 1 byte from an i2c device
 //   ... arg1 ... device address, arg2 ... register number, arg3 .... the address for receiving the data 
 //     return ... if 1:ok, 0:error
 //
 ri2c1:    PUSH ri2c1_jmp    // subroutine. the 1st step to make the return instruction
           BOR               // make the return instruction using arg1 and the previous instruction
           POP ri2c1_rtn     // save the return instruction
           POP ri2c1_addr    // save the arg1, the i2c slave address
           pop ri2c1_reg     // save the arg2, destination register address
           pop ri2c1_raddr   // save the address which receives the value of the destination register.
 //
           PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI ri2c1_a1    // push the return address
           JMP SubI2C1       // call the subroutine
 //
 ri2c1_a1: push ri2c1_addr
           pushi 1
           shl                   // make the i2c device address with the write flag
           pushi ri2c1_a2
           jmp si2c1
 //
 ri2c1_a2: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c1_a3     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c1_a3: in // input the ack
           pushi 0x01
			  band
			  jz ri2c1_a3_1
			  pushi 1           // error to read the ack of the i2c address
			  jmp ri2c1_err
 ri2c1_a3_1: push ri2c1_reg
           pushi ri2c1_a4
           jmp si2c1
//
 ri2c1_a4: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c1_a5     //
           JMP SubI2C1    // call the subroutine
//
 ri2c1_a5: in // input the ack
           pushi 0x01
			  band
			  jz ri2c1_a5_1
			  pushi 2           // error to read the ack of the i2c register no.
			  jmp ri2c1_err
 ri2c1_a5_1: PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI ri2c1_a6    // push the return address
           JMP SubI2C1       // call the subroutine
//
 ri2c1_a6: push ri2c1_addr
           pushi 1
           shl                   // make the i2c device address with the read flag
           pushi 0x0001
           BOR
           pushi ri2c1_a7
           jmp si2c1
//
 ri2c1_a7: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c1_a8     //
           JMP SubI2C1    // call the subroutine
//
 ri2c1_a8: in // input the ack
           pushi 0x01
			  band
			  jz ri2c1_a8_1
			  pushi 3           // error to read the ack of the i2c address again.
			  jmp ri2c1_err
 ri2c1_a8_1: pushi i2cRead
           pushi ri2c1_a9
           jmp SubI2C1
//
 ri2c1_a9: push ri2c1_raddr
           in
           st 
//
           PUSHI i2cNAck // push arg1 .... Ack
           PUSHI ri2c1_a10     //
           JMP SubI2C1    // call the subroutine
//
 ri2c1_a10: PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI ri2c1_a11     // push the return address
           JMP SubI2C1    // call the subroutine
//
 ri2c1_a11: pushI 0          
 ri2c1_rtn:  jmp  0x000           // return
 ri2c1_err: pop ri2c1_ercode
           PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI ri2c1_a12     // push the return address
           JMP SubI2C1    // call the subroutine
 ri2c1_a12: push ri2c1_ercode
           jmp ri2c1_rtn 
 ri2c1_jmp:  0x4000
 ri2c1_addr: 0x0000
 ri2c1_reg: 0x0000
 ri2c1_raddr: 0x0000
 ri2c1_ercode: 0x0000
 
 //
 // ri2c2
 // Read 2 byte series from an i2c device
 //  ... arg1 ... device address, arg2 ... register number, arg3 ... the address for receiving the data
 //      return ... if 1: ok, 0:error
 //
 ri2c2:    PUSH ri2c2_jmp    // subroutine. the 1st step to make the return instruction
           BOR               // make the return instruction using arg1 and the previous instruction
           POP ri2c2_rtn     // save the return instruction
           POP ri2c2_addr    // save the arg1, the i2c slave address
           pop ri2c2_reg     // save the arg2, destination register address
           pop ri2c2_raddr   // save the address which receives the value of the destination register.
 //
           PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI ri2c2_a1    // push the return address
           JMP SubI2C1       // call the subroutine
 //
 ri2c2_a1: push ri2c2_addr
           pushi 1
           shl                   // make the i2c device address with the write flag
//
           pushi ri2c2_a2
           jmp si2c1
 //
 ri2c2_a2: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c2_a3     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a3: in // input the ack
           pushi 0x01
 			  band
 			  jz ri2c2_a3_1
 			  pushi 1           // error to read the ack of the i2c address
 			  jmp ri2c2_err
 ri2c2_a3_1: push ri2c2_reg
           pushi ri2c2_a4
           jmp si2c1
 //
 ri2c2_a4: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c2_a5     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a5: in // input the ack
           pushi 0x01
 			  band
 			  jz ri2c2_a5_1
 			  pushi 2           // error to read the ack of the i2c register no.
 			  jmp ri2c2_err
 ri2c2_a5_1: PUSHI i2cStart    // push arg1... the i2c slave Addr
           PUSHI ri2c2_a6    // push the return address
           JMP SubI2C1       // call the subroutine
 //
 ri2c2_a6: push ri2c2_addr
           pushi 1
           shl                   // make the i2c device address with the read flag
           pushi 0x0001
           BOR
           pushi ri2c2_a7
           jmp si2c1
 //
 ri2c2_a7: PUSHI i2cRAck // push arg1 .... read the ack
           PUSHI ri2c2_a8     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a8: in // input the ack
           pushi 0x01
			  band
			  jz ri2c2_a8_1
			  pushi 3           // error to read the ack of the i2c address again.
			  jmp ri2c2_err
 ri2c2_a8_1: pushi i2cRead
           pushi ri2c2_l9
           jmp SubI2C1
 //
 ri2c2_l9: in
			  pushi 8
			  shl
			  pop ri2c2_val1
 //
           PUSHI i2cWAck // push arg1 .... write the ack
           PUSHI ri2c2_a10     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a10: pushi i2cRead
           pushi ri2c2_a11
           jmp SubI2C1
 //
 ri2c2_a11: push ri2c2_raddr
           in
           push ri2c2_val1
 			  bor
           st 
 //
           PUSHI i2cNAck // push arg1 .... Ack
           PUSHI ri2c2_a12     //
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a12: PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI ri2c2_a13     // push the return address
           JMP SubI2C1    // call the subroutine
 //
 ri2c2_a13: pushI 0   // no error          
 ri2c2_rtn:  jmp  0x000           // return
 ri2c2_err: pop ri2c2_ercode
           PUSHI i2cStop  // push arg1 .... write the ack
           PUSHI ri2c2_a14     // push the return address
           JMP SubI2C1    // call the subroutine
 ri2c2_a14: push ri2c2_ercode
           jmp ri2c2_rtn  
 ri2c2_jmp:  0x4000
 ri2c2_addr: 0x0000
 ri2c2_reg: 0x0000
 ri2c2_raddr: 0x0000
 ri2c2_val1:  0x0000
 ri2c2_ercode: 0x0000
 //
 // SubI2C1 ... send the [arg1] steps of I2C [scl,sda] sequence after the address of [arg1 +1] to the i2c bus.
 //
 SubI2C1:  PUSH LblJMP    // subroutine. the 1st step to return instruction
           BOR            // make the return instruction using arg1 and the previous instruction
           POP RtnSub1    // save the return instruction
           POP Sub1Data2  // save the arg1
           PUSH Sub1Data2
           LD
           POP N
           PUSH Sub1Data2
           PUSHI 1
           ADD
           POP Sub1SA
           PUSHI 0
           POP i
 L1:       PUSH i
           PUSH Sub1SA
           ADD
           LD     //... Sub1S[i];
           OUT    //... print(Sub1S[i]) ;
           PUSH i
           PUSHI 1     
           ADD
           POP i
           PUSH i
           PUSH N
           SUB
           JNZ L1  //   if(i<n) goto L1;
 RtnSub1:  JMP 0x000           // return
 LblJMP:   0x4000
 Sub1Data2: 0x0000
 Sub1SA:   0x0000
 i:        0x0000
 N:        0x0000
 //
 // data for controlling i2c
 //  (MSB) ......    scl, sda (LSB)
 //
 // I2C start
 i2cStart:  3
            1 //01
            3 //11
            2 //10
            0 //00
 //
 // I2C AddrWrite
 i2cAddrW:  3
            0 // 00
            2 // 10 send 0 ... write
            0 // 00
 //
 // I2C AddrRead
 i2cAddrR:  3
            1   //   01
            3   //   11  ... read
            1   //   01
 //
 // I2C 
 i2cRAck:  3
           1   // 01
           3   // 11  read ack 
           1   // 01
 //
 // I2C Write Ack
 i2cWAck:  3
           0  // 00
           2  // 10  send 0 ... write
           0  // 00
 //
 // I2C NAck
 i2cNAck:  3
           1  //01
           3  //  ... read
           1  //
 //
 //
 //  stop
 i2cStop:  3
            2  // 10  
            3  // 11  stop the transfering
           3  // 11         
 //
 // I2C read 1byte
 i2cRead:  0x0011
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01
           3  // 11
           1  // 01 
 
 */
 
 mem[12'h000]=16'h1002 ; //main_start:  pushi main_a0 
 mem[12'h001]=16'h40a7 ; //             jmp servoInit    
 mem[12'h002]=16'h5007 ; //main_a0:  jz main_loop
 mem[12'h003]=16'h1003 ; //             pushi 0x03
 mem[12'h004]=16'he000 ; //             out
 mem[12'h005]=16'h0000 ; //             halt
 mem[12'h006]=16'h4000 ; //             jmp main_start
 mem[12'h007]=16'h103c ; //main_loop:  pushi main_lightVal
 mem[12'h008]=16'h100a ; //             pushi main_getLight
 mem[12'h009]=16'h4120 ; //             jmp getLight          
 mem[12'h00a]=16'h500f ; //main_getLight:  jz main_judge
 mem[12'h00b]=16'h1007 ; //             pushi 0x07
 mem[12'h00c]=16'he000 ; //             out
 mem[12'h00d]=16'h0000 ; //             halt
 mem[12'h00e]=16'h4007 ; //             jmp main_loop
 mem[12'h00f]=16'h203c ; //main_judge:  push main_lightVal
 mem[12'h010]=16'h2003 ; //             push 0x03
 mem[12'h011]=16'hf006 ; //             bor
 mem[12'h012]=16'he000 ; //             out
 mem[12'h013]=16'h1100 ; //             pushi 0x0100
 mem[12'h014]=16'h1016 ; //             pushi main_judge_1       
 mem[12'h015]=16'h4182 ; //             jmp waitLoop
 mem[12'h016]=16'h501b ; //main_judge_1:  jz main_judge_2
 mem[12'h017]=16'h1007 ; //             pushi 0x07
 mem[12'h018]=16'he000 ; //             out
 mem[12'h019]=16'h0000 ; //             halt
 mem[12'h01a]=16'h4007 ; //             jmp main_loop     
 mem[12'h01b]=16'hd000 ; //main_judge_2:  in        
 mem[12'h01c]=16'h1008 ; //             pushi 0x08
 mem[12'h01d]=16'hf004 ; //             shr
 mem[12'h01e]=16'h10ff ; //             pushi 0x00ff  
 mem[12'h01f]=16'hf005 ; //             band
 mem[12'h020]=16'h203c ; //             push main_lightVal
 mem[12'h021]=16'h10ff ; //             pushi 0x00ff
 mem[12'h022]=16'hf005 ; //             band
 mem[12'h023]=16'hf00E ; //             gt
 mem[12'h024]=16'h602c ; //             jnz main_move   
 mem[12'h025]=16'h1027 ; //main_stop:  pushi main_stop_1
 mem[12'h026]=16'h4082 ; //             jmp stopServo
 mem[12'h027]=16'h5033 ; //main_stop_1:  jz main_wait
 mem[12'h028]=16'h100b ; //             pushi 0x0b
 mem[12'h029]=16'he000 ; //             out
 mem[12'h02a]=16'h0000 ; //             halt
 mem[12'h02b]=16'h4007 ; //             jmp main_loop
 mem[12'h02c]=16'h102e ; //main_move:  pushi main_move_1 
 mem[12'h02d]=16'h403d ; //             jmp oneStep
 mem[12'h02e]=16'h5033 ; //main_move_1:  jz main_wait
 mem[12'h02f]=16'h100f ; //             pushi 0x0f
 mem[12'h030]=16'he000 ; //             out
 mem[12'h031]=16'h0000 ; //             halt
 mem[12'h032]=16'h4007 ; //             jmp main_loop
 mem[12'h033]=16'h1040 ; //main_wait:  pushi 0x0040
 mem[12'h034]=16'h1036 ; //             pushi main_loopEnd       
 mem[12'h035]=16'h4182 ; //             jmp waitLoop
 mem[12'h036]=16'h5007 ; //main_loopEnd:  jz main_loop
 mem[12'h037]=16'h1013 ; //             pushi 0x013
 mem[12'h038]=16'he000 ; //             out
 mem[12'h039]=16'h0000 ; //             halt
 mem[12'h03a]=16'h4007 ; //             jmp main_loop
 mem[12'h03b]=16'h0000 ; //main_error:  0x0000
 mem[12'h03c]=16'h0000 ; //main_lightVal:  0x0000
 mem[12'h03d]=16'h2080 ; //oneStep:  push oneStep_jmp
 mem[12'h03e]=16'hf006 ; //             bor
 mem[12'h03f]=16'h307f ; //             pop oneStep_rtn
 mem[12'h040]=16'h1000 ; //oneStep_a0_1:  pushi 0    
 mem[12'h041]=16'h211c ; //             push servoHalfMax
 mem[12'h042]=16'h210a ; //             push servoCh1
 mem[12'h043]=16'h2105 ; //             push servoAddr
 mem[12'h044]=16'h1046 ; //             pushi oneStep_a1
 mem[12'h045]=16'h421f ; //             jmp wi2c4           
 mem[12'h046]=16'h5049 ; //oneStep_a1:  jz oneStep_a1_1
 mem[12'h047]=16'h1001 ; //             pushi 0x01
 mem[12'h048]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h049]=16'h1200 ; //oneStep_a1_1:  pushi 0x0200
 mem[12'h04a]=16'h104c ; //             pushi oneStep_a2
 mem[12'h04b]=16'h4182 ; //             jmp waitLoop        
 mem[12'h04c]=16'h504f ; //oneStep_a2:  jz oneStep_a2_1
 mem[12'h04d]=16'h1002 ; //             pushi 0x02
 mem[12'h04e]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h04f]=16'h1000 ; //oneStep_a2_1:  pushi 0  
 mem[12'h050]=16'h211c ; //             push servoHalfMax
 mem[12'h051]=16'h2109 ; //             push servoCh0
 mem[12'h052]=16'h2105 ; //             push servoAddr
 mem[12'h053]=16'h1055 ; //             pushi oneStep_a3
 mem[12'h054]=16'h421f ; //             jmp wi2c4           
 mem[12'h055]=16'h5058 ; //oneStep_a3:  jz oneStep_a3_1
 mem[12'h056]=16'h1003 ; //             pushi 0x03
 mem[12'h057]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h058]=16'h1200 ; //oneStep_a3_1:  pushi 0x0200
 mem[12'h059]=16'h105b ; //             pushi oneStep_a4       
 mem[12'h05a]=16'h4182 ; //             jmp waitLoop
 mem[12'h05b]=16'h505e ; //oneStep_a4:  jz oneStep_a4_1
 mem[12'h05c]=16'h1004 ; //             pushi 0x04
 mem[12'h05d]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h05e]=16'h1000 ; //oneStep_a4_1:  pushi 0
 mem[12'h05f]=16'h211b ; //             push servoHalfMin
 mem[12'h060]=16'h210a ; //             push servoCh1
 mem[12'h061]=16'h2105 ; //             push servoAddr
 mem[12'h062]=16'h1064 ; //             pushi oneStep_a5
 mem[12'h063]=16'h421f ; //             jmp wi2c4          
 mem[12'h064]=16'h5067 ; //oneStep_a5:  jz oneStep_a5_1
 mem[12'h065]=16'h1005 ; //             pushi 0x05
 mem[12'h066]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h067]=16'h1200 ; //oneStep_a5_1:  pushi 0x0200
 mem[12'h068]=16'h106a ; //             pushi oneStep_a6
 mem[12'h069]=16'h4182 ; //             jmp waitLoop        
 mem[12'h06a]=16'h506e ; //oneStep_a6:  jz oneStep_a6_1
 mem[12'h06b]=16'h1006 ; //             pushi 0x06
 mem[12'h06c]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h06d]=16'h0000 ; //             halt
 mem[12'h06e]=16'h1000 ; //oneStep_a6_1:  pushi 0
 mem[12'h06f]=16'h211b ; //             push servoHalfMin
 mem[12'h070]=16'h2109 ; //             push servoCh0
 mem[12'h071]=16'h2105 ; //             push servoAddr
 mem[12'h072]=16'h1074 ; //             pushi oneStep_a7
 mem[12'h073]=16'h421f ; //             jmp wi2c4           
 mem[12'h074]=16'h5077 ; //oneStep_a7:  jz oneStep_a7_1
 mem[12'h075]=16'h1007 ; //             pushi 0x07
 mem[12'h076]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h077]=16'h1200 ; //oneStep_a7_1:  pushi 0x0200
 mem[12'h078]=16'h107a ; //             pushi oneStep_a8
 mem[12'h079]=16'h4182 ; //             jmp waitLoop        
 mem[12'h07a]=16'h507e ; //oneStep_a8:  jz oneStep_end
 mem[12'h07b]=16'h1008 ; //             pushi 0x08
 mem[12'h07c]=16'h407f ; //             jmp oneStep_rtn
 mem[12'h07d]=16'h0000 ; //             halt
 mem[12'h07e]=16'h1000 ; //oneStep_end:  pushi 0
 mem[12'h07f]=16'h0000 ; //oneStep_rtn:  0x0000 
 mem[12'h080]=16'h4000 ; //oneStep_jmp:  0x4000
 mem[12'h081]=16'h0000 ; //oneStep_rcode:  0x0000
 mem[12'h082]=16'h20a5 ; //stopServo:  push stopServo_jmp
 mem[12'h083]=16'hf006 ; //             bor
 mem[12'h084]=16'h30a4 ; //             pop stopServo_rtn
 mem[12'h085]=16'h1000 ; //stopServo_a0_1:  pushi 0    
 mem[12'h086]=16'h211d ; //             push servoCen
 mem[12'h087]=16'h2109 ; //             push servoCh0
 mem[12'h088]=16'h2105 ; //             push servoAddr
 mem[12'h089]=16'h108b ; //             pushi stopServo_a1
 mem[12'h08a]=16'h421f ; //             jmp wi2c4           
 mem[12'h08b]=16'h508e ; //stopServo_a1:  jz stopServo_a1_1
 mem[12'h08c]=16'h1001 ; //             pushi 0x01
 mem[12'h08d]=16'h40a4 ; //             jmp stopServo_rtn
 mem[12'h08e]=16'h1004 ; //stopServo_a1_1:  pushi 0x0004
 mem[12'h08f]=16'h1091 ; //             pushi stopServo_a2
 mem[12'h090]=16'h4182 ; //             jmp waitLoop        
 mem[12'h091]=16'h5094 ; //stopServo_a2:  jz stopServo_a2_1
 mem[12'h092]=16'h1002 ; //             pushi 0x02
 mem[12'h093]=16'h40a4 ; //             jmp stopServo_rtn
 mem[12'h094]=16'h1000 ; //stopServo_a2_1:  pushi 0  
 mem[12'h095]=16'h211d ; //             push servoCen
 mem[12'h096]=16'h210a ; //             push servoCh1
 mem[12'h097]=16'h2105 ; //             push servoAddr
 mem[12'h098]=16'h109a ; //             pushi stopServo_a3
 mem[12'h099]=16'h421f ; //             jmp wi2c4           
 mem[12'h09a]=16'h509d ; //stopServo_a3:  jz stopServo_a3_1
 mem[12'h09b]=16'h1003 ; //             pushi 0x03
 mem[12'h09c]=16'h40a4 ; //             jmp stopServo_rtn
 mem[12'h09d]=16'h1200 ; //stopServo_a3_1:  pushi 0x200
 mem[12'h09e]=16'h10a0 ; //             pushi stopServo_a8
 mem[12'h09f]=16'h4182 ; //             jmp waitLoop        
 mem[12'h0a0]=16'h50a3 ; //stopServo_a8:  jz stopServo_end
 mem[12'h0a1]=16'h1008 ; //             pushi 0x08
 mem[12'h0a2]=16'h40a4 ; //             jmp stopServo_rtn
 mem[12'h0a3]=16'h1000 ; //stopServo_end:  pushi 0x00
 mem[12'h0a4]=16'h0000 ; //stopServo_rtn:  0x0000 
 mem[12'h0a5]=16'h4000 ; //stopServo_jmp:  0x4000
 mem[12'h0a6]=16'h0000 ; //stopServo_rcode:  0x0000
 mem[12'h0a7]=16'h2104 ; //servoInit:  push servoInit_jmp
 mem[12'h0a8]=16'hf006 ; //             bor
 mem[12'h0a9]=16'h3103 ; //             pop servoInit_rtn
 mem[12'h0aa]=16'h1000 ; //             pushi 0x00
 mem[12'h0ab]=16'h2106 ; //             push servoMode1
 mem[12'h0ac]=16'h2105 ; //             push servoAddr
 mem[12'h0ad]=16'h10af ; //             pushi servoInit_a0
 mem[12'h0ae]=16'h4190 ; //             jmp wi2c1
 mem[12'h0af]=16'h311f ; //servoInit_a0:  pop servoInit_RtnCode
 mem[12'h0b0]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0b1]=16'h50b7 ; //             jz servoInit_a0_1
 mem[12'h0b2]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0b3]=16'he000 ; //             out
 mem[12'h0b4]=16'h0000 ; //             halt
 mem[12'h0b5]=16'h1011 ; //             pushi 11
 mem[12'h0b6]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h0b7]=16'h1107 ; //servoInit_a0_1:  pushi servoMode1Val
 mem[12'h0b8]=16'h2106 ; //             push servoMode1
 mem[12'h0b9]=16'h2105 ; //             push servoAddr
 mem[12'h0ba]=16'h10bc ; //             pushi servoInit_a1
 mem[12'h0bb]=16'h42b1 ; //             jmp ri2c1                        
 mem[12'h0bc]=16'h311f ; //servoInit_a1:  pop servoInit_RtnCode
 mem[12'h0bd]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0be]=16'h50c4 ; //             jz servoInit_a1_1
 mem[12'h0bf]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0c0]=16'he000 ; //             out
 mem[12'h0c1]=16'h0000 ; //             halt
 mem[12'h0c2]=16'h1001 ; //             pushi 1
 mem[12'h0c3]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h0c4]=16'h2107 ; //servoInit_a1_1:  push servoMode1Val
 mem[12'h0c5]=16'h107f ; //             pushi 0x7f
 mem[12'h0c6]=16'hf005 ; //             band
 mem[12'h0c7]=16'h1010 ; //             pushi 0x10
 mem[12'h0c8]=16'hf006 ; //             bor
 mem[12'h0c9]=16'h2106 ; //             push servoMode1
 mem[12'h0ca]=16'h2105 ; //             push servoAddr
 mem[12'h0cb]=16'h10cd ; //             pushi servoInit_a2
 mem[12'h0cc]=16'h4190 ; //             jmp wi2c1                      
 mem[12'h0cd]=16'h311f ; //servoInit_a2:  pop servoInit_RtnCode
 mem[12'h0ce]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0cf]=16'h50d5 ; //             jz servoInit_a2_1
 mem[12'h0d0]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0d1]=16'he000 ; //             out
 mem[12'h0d2]=16'h0000 ; //             halt
 mem[12'h0d3]=16'h1002 ; //             pushi 2
 mem[12'h0d4]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h0d5]=16'h1070 ; //servoInit_a2_1:  pushi 0x70
 mem[12'h0d6]=16'h2108 ; //             push servoPreScale
 mem[12'h0d7]=16'h2105 ; //             push servoAddr
 mem[12'h0d8]=16'h10da ; //             pushi servoInit_a3
 mem[12'h0d9]=16'h4190 ; //             jmp wi2c1                    
 mem[12'h0da]=16'h311f ; //servoInit_a3:  pop servoInit_RtnCode
 mem[12'h0db]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0dc]=16'h50e2 ; //             jz servoInit_a3_1
 mem[12'h0dd]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0de]=16'he000 ; //             out
 mem[12'h0df]=16'h0000 ; //             halt
 mem[12'h0e0]=16'h1003 ; //             pushi 3
 mem[12'h0e1]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h0e2]=16'h2107 ; //servoInit_a3_1:  push servoMode1Val
 mem[12'h0e3]=16'h2106 ; //             push servoMode1
 mem[12'h0e4]=16'h2105 ; //             push servoAddr
 mem[12'h0e5]=16'h10e7 ; //             pushi servoInit_a4
 mem[12'h0e6]=16'h4190 ; //             jmp wi2c1                   
 mem[12'h0e7]=16'h311f ; //servoInit_a4:  pop servoInit_RtnCode
 mem[12'h0e8]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0e9]=16'h50ef ; //             jz servoInit_a4_1
 mem[12'h0ea]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0eb]=16'he000 ; //             out
 mem[12'h0ec]=16'h0000 ; //             halt
 mem[12'h0ed]=16'h1004 ; //             pushi 4
 mem[12'h0ee]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h0ef]=16'h100f ; //servoInit_a4_1:  pushi 0x000f
 mem[12'h0f0]=16'h10f2 ; //             pushi servoInit_a5
 mem[12'h0f1]=16'h4182 ; //             jmp waitLoop
 mem[12'h0f2]=16'h311f ; //servoInit_a5:  pop servoInit_RtnCode
 mem[12'h0f3]=16'h2107 ; //             push servoMode1Val
 mem[12'h0f4]=16'h10a1 ; //             pushi 0x00a1
 mem[12'h0f5]=16'hf006 ; //             bor
 mem[12'h0f6]=16'h2106 ; //             push servoMode1
 mem[12'h0f7]=16'h2105 ; //             push servoAddr
 mem[12'h0f8]=16'h10fa ; //             pushi servoInit_a6
 mem[12'h0f9]=16'h4190 ; //             jmp wi2c1               
 mem[12'h0fa]=16'h311f ; //servoInit_a6:  pop servoInit_RtnCode
 mem[12'h0fb]=16'h211f ; //             push servoInit_RtnCode
 mem[12'h0fc]=16'h5102 ; //             jz servoInit_a6_1
 mem[12'h0fd]=16'h211f ; //             push servoInit_RtnCode 
 mem[12'h0fe]=16'he000 ; //             out
 mem[12'h0ff]=16'h0000 ; //             halt
 mem[12'h100]=16'h1006 ; //             pushi 6
 mem[12'h101]=16'h4103 ; //             jmp servoInit_rtn
 mem[12'h102]=16'h1000 ; //servoInit_a6_1:  pushi 0
 mem[12'h103]=16'h0000 ; //servoInit_rtn:  0x0000 
 mem[12'h104]=16'h4000 ; //servoInit_jmp:  0x4000
 mem[12'h105]=16'h0040 ; //servoAddr:  0x0040
 mem[12'h106]=16'h0000 ; //servoMode1:  0x0000
 mem[12'h107]=16'h0000 ; //servoMode1Val:  0x0000
 mem[12'h108]=16'h00fe ; //servoPreScale:  0x00fe 
 mem[12'h109]=16'h0006 ; //servoCh0:  0x0006
 mem[12'h10a]=16'h000a ; //servoCh1:  0x000a
 mem[12'h10b]=16'h000e ; //servoCh2:  0x000e
 mem[12'h10c]=16'h0012 ; //servoCh3:  0x0012
 mem[12'h10d]=16'h0016 ; //servoCh4:  0x0016
 mem[12'h10e]=16'h001a ; //servoCh5:  0x001a
 mem[12'h10f]=16'h001e ; //servoCh6:  0x001e
 mem[12'h110]=16'h0022 ; //servoCh7:  0x0022
 mem[12'h111]=16'h0026 ; //servoCh8:  0x0026
 mem[12'h112]=16'h002a ; //servoCh9:  0x002a
 mem[12'h113]=16'h002e ; //servoCh10:  0x002e
 mem[12'h114]=16'h0032 ; //servoCh11:  0x0032
 mem[12'h115]=16'h0036 ; //servoCh12:  0x0036
 mem[12'h116]=16'h003a ; //servoCh13:  0x003a
 mem[12'h117]=16'h003e ; //servoCh14:  0x003e
 mem[12'h118]=16'h0042 ; //servoCh15:  0x0042
 mem[12'h119]=16'h0096 ; //servoMin:  0x0096 
 mem[12'h11a]=16'h0258 ; //servoMax:  0x0258 
 mem[12'h11b]=16'h0106 ; //servoHalfMin:  0x0106 
 mem[12'h11c]=16'h01e7 ; //servoHalfMax:  0x1e7  
 mem[12'h11d]=16'h0177 ; //servoCen:  0x0177 
 mem[12'h11e]=16'hff8f ; //servoInitPrescale:  0xff8f 
 mem[12'h11f]=16'h0000 ; //servoInit_RtnCode:  0x0000
 mem[12'h120]=16'h2176 ; //getLight:  push getLight_jmp
 mem[12'h121]=16'hf006 ; //             bor
 mem[12'h122]=16'h3172 ; //             pop getLight_rtn
 mem[12'h123]=16'h3174 ; //             pop getLight_valAddr
 mem[12'h124]=16'h1003 ; //             pushi 0x03   
 mem[12'h125]=16'h1080 ; //             pushi 0x80   
 mem[12'h126]=16'h217f ; //             push lightSensorAddr  
 mem[12'h127]=16'h1129 ; //             pushi getLight_a1  
 mem[12'h128]=16'h4190 ; //             jmp wi2c1      
 mem[12'h129]=16'h3175 ; //getLight_a1:  pop getLightRtnCode
 mem[12'h12a]=16'h2175 ; //             push getLightRtnCode
 mem[12'h12b]=16'h512e ; //             jz getLight_a1_1
 mem[12'h12c]=16'h1001 ; //             pushi 1           
 mem[12'h12d]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h12e]=16'h1000 ; //getLight_a1_1:  pushi 0x00  
 mem[12'h12f]=16'h1081 ; //             pushi 0x81
 mem[12'h130]=16'h217f ; //             push lightSensorAddr
 mem[12'h131]=16'h1133 ; //             pushi getLight_a2
 mem[12'h132]=16'h4190 ; //             jmp wi2c1
 mem[12'h133]=16'h3175 ; //getLight_a2:  pop getLightRtnCode
 mem[12'h134]=16'h2175 ; //             push getLightRtnCode
 mem[12'h135]=16'h5138 ; //             jz getLight_a2_1
 mem[12'h136]=16'h1002 ; //             pushi 2           
 mem[12'h137]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h138]=16'h1000 ; //getLight_a2_1:  pushi 0x00  
 mem[12'h139]=16'h1086 ; //             pushi 0x86   
 mem[12'h13a]=16'h217f ; //             push lightSensorAddr 
 mem[12'h13b]=16'h113d ; //             pushi getLight_a3
 mem[12'h13c]=16'h4190 ; //             jmp wi2c1
 mem[12'h13d]=16'h3175 ; //getLight_a3:  pop getLightRtnCode
 mem[12'h13e]=16'h2175 ; //             push getLightRtnCode
 mem[12'h13f]=16'h5142 ; //             jz getLight_a3_1
 mem[12'h140]=16'h1003 ; //             pushi 3           
 mem[12'h141]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h142]=16'h1000 ; //getLight_a3_1:  pushi 0x00 
 mem[12'h143]=16'h1080 ; //             pushi 0x80
 mem[12'h144]=16'h217f ; //             push lightSensorAddr
 mem[12'h145]=16'h1147 ; //             pushi getLight_a4
 mem[12'h146]=16'h4190 ; //             jmp wi2c1
 mem[12'h147]=16'h3175 ; //getLight_a4:  pop getLightRtnCode
 mem[12'h148]=16'h2175 ; //             push getLightRtnCode
 mem[12'h149]=16'h514c ; //             jz getLight_a4_1
 mem[12'h14a]=16'h1004 ; //             pushi 4           
 mem[12'h14b]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h14c]=16'h1003 ; //getLight_a4_1:  pushi 0x03 
 mem[12'h14d]=16'h1080 ; //             pushi 0x80
 mem[12'h14e]=16'h217f ; //             push lightSensorAddr
 mem[12'h14f]=16'h1151 ; //             pushi getLight_a5
 mem[12'h150]=16'h4190 ; //             jmp wi2c1
 mem[12'h151]=16'h3175 ; //getLight_a5:  pop getLightRtnCode
 mem[12'h152]=16'h2175 ; //             push getLightRtnCode
 mem[12'h153]=16'h5156 ; //             jz getLight_a5_1
 mem[12'h154]=16'h1005 ; //             pushi 5           
 mem[12'h155]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h156]=16'h1179 ; //getLight_a5_1:  PUSHI lightSensorCh0l  
 mem[12'h157]=16'h108c ; //             PUSHi 0x8c     
 mem[12'h158]=16'h217f ; //             push lightSensorAddr       
 mem[12'h159]=16'h115b ; //             pushi getLight_a6          
 mem[12'h15a]=16'h42b1 ; //             JMP ri2c1    
 mem[12'h15b]=16'h3175 ; //getLight_a6:  pop getLightRtnCode
 mem[12'h15c]=16'h2175 ; //             push getLightRtnCode
 mem[12'h15d]=16'h5160 ; //             jz getLight_a6_1
 mem[12'h15e]=16'h1006 ; //             pushi 6           
 mem[12'h15f]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h160]=16'h117a ; //getLight_a6_1:  PUSHI lightSensorCh0h  
 mem[12'h161]=16'h108d ; //             PUSHi 0x8d     
 mem[12'h162]=16'h217f ; //             push lightSensorAddr       
 mem[12'h163]=16'h1165 ; //             pushi getLight_a7          
 mem[12'h164]=16'h42b1 ; //             JMP ri2c1    
 mem[12'h165]=16'h3175 ; //getLight_a7:  pop getLightRtnCode
 mem[12'h166]=16'h2175 ; //             push getLightRtnCode
 mem[12'h167]=16'h516a ; //             jz getLight_a7_1
 mem[12'h168]=16'h1007 ; //             pushi 7           
 mem[12'h169]=16'h4172 ; //             jmp getLight_rtn
 mem[12'h16a]=16'h2174 ; //getLight_a7_1:  push getLight_valAddr
 mem[12'h16b]=16'h217a ; //             push lightSensorCh0h
 mem[12'h16c]=16'h1008 ; //             pushi 0x08
 mem[12'h16d]=16'hf004 ; //             shr
 mem[12'h16e]=16'h2179 ; //             push lightSensorCh0l
 mem[12'h16f]=16'hf006 ; //             bor
 mem[12'h170]=16'h8000 ; //             st
 mem[12'h171]=16'h1000 ; //             pushi 0          
 mem[12'h172]=16'h4000 ; //getLight_rtn:  jmp 0x0000
 mem[12'h173]=16'h0000 ; //getLight_err:  0x0000
 mem[12'h174]=16'h0000 ; //getLight_valAddr:  0x0000
 mem[12'h175]=16'h0000 ; //getLightRtnCode:  0x0000
 mem[12'h176]=16'h4000 ; //getLight_jmp:  0x4000
 mem[12'h177]=16'h0000 ; //getLight_rtnval:  0x0000
 mem[12'h178]=16'h0000 ; //getLight_valAddr:  0x0000 
 mem[12'h179]=16'h0000 ; //lightSensorCh0l:  0x0000
 mem[12'h17a]=16'h0000 ; //lightSensorCh0h:  0x0000
 mem[12'h17b]=16'h008c ; //lightSensorRC0h:  0x008c   
 mem[12'h17c]=16'h008d ; //lightSensorRC0l:  0x008d
 mem[12'h17d]=16'h008e ; //lightSensorRC1h:  0x008e
 mem[12'h17e]=16'h008f ; //lightSensorRC1l:  0x008f
 mem[12'h17f]=16'h0029 ; //lightSensorAddr:  0x0029   
 mem[12'h180]=16'h008d ; //lightReadReg:  0x008d   
 mem[12'h181]=16'h0029 ; //lightAddr:  0x0029   
 mem[12'h182]=16'h218e ; //waitLoop:  push waitLoop_jmp
 mem[12'h183]=16'hf006 ; //             bor
 mem[12'h184]=16'h318d ; //             pop waitLoop_rtn
 mem[12'h185]=16'h318f ; //             pop waitLoop_times
 mem[12'h186]=16'h218f ; //waitLoop_a0:  push waitLoop_times
 mem[12'h187]=16'h1001 ; //             pushi 1
 mem[12'h188]=16'hf001 ; //             sub
 mem[12'h189]=16'h318f ; //             pop waitLoop_times
 mem[12'h18a]=16'h218f ; //             push waitLoop_times
 mem[12'h18b]=16'h6186 ; //             jnz waitLoop_a0
 mem[12'h18c]=16'h1000 ; //             pushi 0
 mem[12'h18d]=16'h0000 ; //waitLoop_rtn:  0x0000
 mem[12'h18e]=16'h4000 ; //waitLoop_jmp:  0x4000
 mem[12'h18f]=16'h0000 ; //waitLoop_times:  0x000
 mem[12'h190]=16'h21ca ; //wi2c1:  PUSH wi2c1_jmp    
 mem[12'h191]=16'hf006 ; //             BOR               
 mem[12'h192]=16'h31c3 ; //             POP wi2c1_rtn     
 mem[12'h193]=16'h31cb ; //             POP wi2c1_addr    
 mem[12'h194]=16'h31cc ; //             pop wi2c1_reg     
 mem[12'h195]=16'h31cd ; //             pop wi2c1_val     
 mem[12'h196]=16'h137c ; //             PUSHI i2cStart    
 mem[12'h197]=16'h1199 ; //             PUSHI wi2c1_a1    
 mem[12'h198]=16'h435c ; //             JMP SubI2C1      
 mem[12'h199]=16'h21cb ; //wi2c1_a1:  push wi2c1_addr
 mem[12'h19a]=16'h1001 ; //             pushi 1
 mem[12'h19b]=16'hf003 ; //             shl                   
 mem[12'h19c]=16'h119e ; //             pushi wi2c1_a2
 mem[12'h19d]=16'h428c ; //             jmp si2c1
 mem[12'h19e]=16'h1389 ; //wi2c1_a2:  PUSHI i2cRAck 
 mem[12'h19f]=16'h11a1 ; //             PUSHI wi2c1_a3     
 mem[12'h1a0]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1a1]=16'hd000 ; //wi2c1_a3:  in 
 mem[12'h1a2]=16'h1001 ; //             pushi 0x01
 mem[12'h1a3]=16'hf005 ; //             band
 mem[12'h1a4]=16'h51a7 ; //             jz wi2c1_a3_1
 mem[12'h1a5]=16'h1001 ; //             pushi 1           
 mem[12'h1a6]=16'h41c4 ; //             jmp wi2c1_err
 mem[12'h1a7]=16'h21cc ; //wi2c1_a3_1:  push wi2c1_reg
 mem[12'h1a8]=16'h11aa ; //             pushi wi2c1_a4
 mem[12'h1a9]=16'h428c ; //             jmp si2c1
 mem[12'h1aa]=16'h1389 ; //wi2c1_a4:  PUSHI i2cRAck 
 mem[12'h1ab]=16'h11ad ; //             PUSHI wi2c1_a5     
 mem[12'h1ac]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1ad]=16'hd000 ; //wi2c1_a5:  in 
 mem[12'h1ae]=16'h1001 ; //             pushi 0x01
 mem[12'h1af]=16'hf005 ; //             band
 mem[12'h1b0]=16'h51b3 ; //             jz wi2c1_a5_1
 mem[12'h1b1]=16'h1002 ; //             pushi 2           
 mem[12'h1b2]=16'h41c4 ; //             jmp wi2c1_err
 mem[12'h1b3]=16'h21cd ; //wi2c1_a5_1:  push  wi2c1_val
 mem[12'h1b4]=16'h11b6 ; //             pushi wi2c1_a6
 mem[12'h1b5]=16'h428c ; //             jmp si2c1
 mem[12'h1b6]=16'h1389 ; //wi2c1_a6:  PUSHI i2cRAck 
 mem[12'h1b7]=16'h11b9 ; //             PUSHI wi2c1_a7     
 mem[12'h1b8]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1b9]=16'hd000 ; //wi2c1_a7:  in 
 mem[12'h1ba]=16'h1001 ; //             pushi 0x01
 mem[12'h1bb]=16'hf005 ; //             band
 mem[12'h1bc]=16'h51bf ; //             jz wi2c1_a7_1
 mem[12'h1bd]=16'h1003 ; //             pushi 3           
 mem[12'h1be]=16'h41c4 ; //             jmp wi2c1_err
 mem[12'h1bf]=16'h1395 ; //wi2c1_a7_1:  PUSHI i2cStop  
 mem[12'h1c0]=16'h11c2 ; //             PUSHI wi2c1_a8     
 mem[12'h1c1]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1c2]=16'h1000 ; //wi2c1_a8:  pushI 0          
 mem[12'h1c3]=16'h4000 ; //wi2c1_rtn:  jmp 0x000            
 mem[12'h1c4]=16'h3000 ; //wi2c1_err:  pop wi2c1_ercode
 mem[12'h1c5]=16'h1395 ; //             PUSHI i2cStop  
 mem[12'h1c6]=16'h11c8 ; //             PUSHI wi2c1_a9     
 mem[12'h1c7]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1c8]=16'h2000 ; //wi2c1_a9:  push wi2c1_ercode
 mem[12'h1c9]=16'h41c3 ; //             jmp wi2c1_rtn
 mem[12'h1ca]=16'h4000 ; //wi2c1_jmp:  0x4000
 mem[12'h1cb]=16'h0000 ; //wi2c1_addr:  0x0000
 mem[12'h1cc]=16'h0000 ; //wi2c1_reg:  0x0000
 mem[12'h1cd]=16'h0000 ; //wi2c1_val:  0x0000
 mem[12'h1ce]=16'h0000 ; //wi2c1\ercode:  0x0000
 mem[12'h1cf]=16'h221a ; //wi2c2:  PUSH wi2c2_jmp    
 mem[12'h1d0]=16'hf006 ; //             BOR               
 mem[12'h1d1]=16'h3213 ; //             POP wi2c2_rtn     
 mem[12'h1d2]=16'h321b ; //             POP wi2c2_addr    
 mem[12'h1d3]=16'h321c ; //             pop wi2c2_reg     
 mem[12'h1d4]=16'h321d ; //             pop wi2c2_val     
 mem[12'h1d5]=16'h137c ; //             PUSHI i2cStart    
 mem[12'h1d6]=16'h11d8 ; //             PUSHI wi2c2_a1    
 mem[12'h1d7]=16'h435c ; //             JMP SubI2C1       
 mem[12'h1d8]=16'h221b ; //wi2c2_a1:  push wi2c2_addr
 mem[12'h1d9]=16'h1001 ; //             pushi 1
 mem[12'h1da]=16'hf003 ; //             shl                   
 mem[12'h1db]=16'h3000 ; //             pop wi2c2_waddr
 mem[12'h1dc]=16'h11de ; //             pushi wi2c2_a2
 mem[12'h1dd]=16'h428c ; //             jmp si2c1
 mem[12'h1de]=16'h1389 ; //wi2c2_a2:  PUSHI i2cRAck 
 mem[12'h1df]=16'h11e1 ; //             PUSHI wi2c2_a3     
 mem[12'h1e0]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1e1]=16'hd000 ; //wi2c2_a3:  in 
 mem[12'h1e2]=16'h1001 ; //             pushi 0x01
 mem[12'h1e3]=16'hf005 ; //             band
 mem[12'h1e4]=16'h51e7 ; //             jz wi2c2_a3_1
 mem[12'h1e5]=16'h1001 ; //             pushi 1           
 mem[12'h1e6]=16'h4214 ; //             jmp wi2c2_err
 mem[12'h1e7]=16'h221c ; //wi2c2_a3_1:  push  wi2c2_reg
 mem[12'h1e8]=16'h11ea ; //             pushi wi2c2_a4
 mem[12'h1e9]=16'h428c ; //             jmp si2c1
 mem[12'h1ea]=16'h1389 ; //wi2c2_a4:  PUSHI i2cRAck 
 mem[12'h1eb]=16'h11ed ; //             PUSHI wi2c2_a5     
 mem[12'h1ec]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1ed]=16'hd000 ; //wi2c2_a5:  in 
 mem[12'h1ee]=16'h1001 ; //             pushi 0x01
 mem[12'h1ef]=16'hf005 ; //             band
 mem[12'h1f0]=16'h5000 ; //             jz wi2c2_a5_1
 mem[12'h1f1]=16'h1002 ; //             pushi 2           
 mem[12'h1f2]=16'h4214 ; //             jmp wi2c2_err
 mem[12'h1f3]=16'h221d ; //wi2c_a5_1:  push  wi2c2_val
 mem[12'h1f4]=16'h10ff ; //             pushi 0x00ff
 mem[12'h1f5]=16'hf005 ; //             band
 mem[12'h1f6]=16'h11f8 ; //             pushi wi2c2_a6
 mem[12'h1f7]=16'h428c ; //             jmp si2c1
 mem[12'h1f8]=16'h1389 ; //wi2c2_a6:  PUSHI i2cRAck 
 mem[12'h1f9]=16'h11fb ; //             PUSHI wi2c2_a7     
 mem[12'h1fa]=16'h435c ; //             JMP SubI2C1    
 mem[12'h1fb]=16'hd000 ; //wi2c2_a7:  in 
 mem[12'h1fc]=16'h1001 ; //             pushi 0x01
 mem[12'h1fd]=16'hf005 ; //             band
 mem[12'h1fe]=16'h5201 ; //             jz wi2c2_a7_1
 mem[12'h1ff]=16'h1003 ; //             pushi 3           
 mem[12'h200]=16'h4214 ; //             jmp wi2c2_err
 mem[12'h201]=16'h221d ; //wi2c2_a7_1:  push  wi2c2_val
 mem[12'h202]=16'h1008 ; //             pushi 8
 mem[12'h203]=16'hf004 ; //             shr
 mem[12'h204]=16'h1206 ; //             pushi wi2c2_a8
 mem[12'h205]=16'h428c ; //             jmp si2c1
 mem[12'h206]=16'h1389 ; //wi2c2_a8:  PUSHI i2cRAck 
 mem[12'h207]=16'h1209 ; //             PUSHI wi2c2_a9     
 mem[12'h208]=16'h435c ; //             JMP SubI2C1    
 mem[12'h209]=16'hd000 ; //wi2c2_a9:  in 
 mem[12'h20a]=16'h1001 ; //             pushi 0x01
 mem[12'h20b]=16'hf005 ; //             band
 mem[12'h20c]=16'h520f ; //             jz wi2c2_a9_1
 mem[12'h20d]=16'h1004 ; //             pushi 4           
 mem[12'h20e]=16'h4214 ; //             jmp wi2c2_err
 mem[12'h20f]=16'h1395 ; //wi2c2_a9_1:  PUSHI i2cStop  
 mem[12'h210]=16'h1212 ; //             PUSHI wi2c2_a10     
 mem[12'h211]=16'h435c ; //             JMP SubI2C1    
 mem[12'h212]=16'h1000 ; //wi2c2_a10:  pushI 0          
 mem[12'h213]=16'h4000 ; //wi2c2_rtn:  jmp  0x000           
 mem[12'h214]=16'h321e ; //wi2c2_err:  pop wi2c2_ercode
 mem[12'h215]=16'h1395 ; //             PUSHI i2cStop  
 mem[12'h216]=16'h1218 ; //             PUSHI wi2c2_a11     
 mem[12'h217]=16'h435c ; //             JMP SubI2C1    
 mem[12'h218]=16'h221e ; //wi2c2_a11:  push wi2c2_ercode
 mem[12'h219]=16'h4213 ; //             jmp wi2c2_rtn
 mem[12'h21a]=16'h4000 ; //wi2c2_jmp:  0x4000
 mem[12'h21b]=16'h0000 ; //wi2c2_addr:  0x0000
 mem[12'h21c]=16'h0000 ; //wi2c2_reg:  0x0000
 mem[12'h21d]=16'h0000 ; //wi2c2_val:  0x0000
 mem[12'h21e]=16'h0000 ; //wi2c2_ercode:  0x0000
 mem[12'h21f]=16'h2286 ; //wi2c4:  PUSH wi2c4_jmp    
 mem[12'h220]=16'hf006 ; //             BOR               
 mem[12'h221]=16'h327f ; //             POP wi2c4_rtn     
 mem[12'h222]=16'h3287 ; //             POP wi2c4_addr    
 mem[12'h223]=16'h3288 ; //             pop wi2c4_reg     
 mem[12'h224]=16'h328a ; //             pop wi2c4_val2     
 mem[12'h225]=16'h3289 ; //             pop wi2c4_val1     
 mem[12'h226]=16'h137c ; //             PUSHI i2cStart    
 mem[12'h227]=16'h1229 ; //             PUSHI wi2c4_a1    
 mem[12'h228]=16'h435c ; //             JMP SubI2C1       
 mem[12'h229]=16'h2287 ; //wi2c4_a1:  push wi2c4_addr
 mem[12'h22a]=16'h1001 ; //             pushi 1
 mem[12'h22b]=16'hf003 ; //             shl                   
 mem[12'h22c]=16'h122e ; //             pushi wi2c4_a2
 mem[12'h22d]=16'h428c ; //             jmp si2c1
 mem[12'h22e]=16'h1389 ; //wi2c4_a2:  PUSHI i2cRAck 
 mem[12'h22f]=16'h1231 ; //             PUSHI wi2c4_a3     
 mem[12'h230]=16'h435c ; //             JMP SubI2C1    
 mem[12'h231]=16'hd000 ; //wi2c4_a3:  in 
 mem[12'h232]=16'h1001 ; //             pushi 0x01
 mem[12'h233]=16'hf005 ; //             band
 mem[12'h234]=16'h5237 ; //             jz wi2c4_a3_1
 mem[12'h235]=16'h1001 ; //             pushi 1           
 mem[12'h236]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h237]=16'h2288 ; //wi2c4_a3_1:  push  wi2c4_reg
 mem[12'h238]=16'h123a ; //             pushi wi2c4_a4
 mem[12'h239]=16'h428c ; //             jmp si2c1
 mem[12'h23a]=16'h1389 ; //wi2c4_a4:  PUSHI i2cRAck 
 mem[12'h23b]=16'h123d ; //             PUSHI wi2c4_a5     
 mem[12'h23c]=16'h435c ; //             JMP SubI2C1    
 mem[12'h23d]=16'hd000 ; //wi2c4_a5:  in 
 mem[12'h23e]=16'h1001 ; //             pushi 0x01
 mem[12'h23f]=16'hf005 ; //             band
 mem[12'h240]=16'h5243 ; //             jz wi2c4_a5_1
 mem[12'h241]=16'h1002 ; //             pushi 2            
 mem[12'h242]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h243]=16'h2289 ; //wi2c4_a5_1:  push  wi2c4_val1
 mem[12'h244]=16'h10ff ; //             pushi 0x00ff
 mem[12'h245]=16'hf005 ; //             band
 mem[12'h246]=16'h1248 ; //             pushi wi2c4_a6
 mem[12'h247]=16'h428c ; //             jmp si2c1
 mem[12'h248]=16'h1389 ; //wi2c4_a6:  PUSHI i2cRAck 
 mem[12'h249]=16'h124b ; //             PUSHI wi2c4_a7     
 mem[12'h24a]=16'h435c ; //             JMP SubI2C1    
 mem[12'h24b]=16'hd000 ; //wi2c4_a7:  in 
 mem[12'h24c]=16'h1001 ; //             pushi 0x01
 mem[12'h24d]=16'hf005 ; //             band
 mem[12'h24e]=16'h5251 ; //             jz wi2c4_a7_1
 mem[12'h24f]=16'h1003 ; //             pushi 3           
 mem[12'h250]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h251]=16'h2289 ; //wi2c4_a7_1:  push  wi2c4_val1
 mem[12'h252]=16'h1008 ; //             pushi 8
 mem[12'h253]=16'hf004 ; //             shr
 mem[12'h254]=16'h1256 ; //             pushi wi2c4_a8
 mem[12'h255]=16'h428c ; //             jmp si2c1
 mem[12'h256]=16'h1389 ; //wi2c4_a8:  PUSHI i2cRAck 
 mem[12'h257]=16'h1259 ; //             PUSHI wi2c4_a9     
 mem[12'h258]=16'h435c ; //             JMP SubI2C1    
 mem[12'h259]=16'hd000 ; //wi2c4_a9:  in 
 mem[12'h25a]=16'h1001 ; //             pushi 0x01
 mem[12'h25b]=16'hf005 ; //             band
 mem[12'h25c]=16'h525f ; //             jz wi2c4_a9_1
 mem[12'h25d]=16'h1004 ; //             pushi 4            
 mem[12'h25e]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h25f]=16'h228a ; //wi2c4_a9_1:  push  wi2c4_val2
 mem[12'h260]=16'h10ff ; //             pushi 0x00ff
 mem[12'h261]=16'hf005 ; //             band
 mem[12'h262]=16'h1264 ; //             pushi wi2c4_a10
 mem[12'h263]=16'h428c ; //             jmp si2c1
 mem[12'h264]=16'h1389 ; //wi2c4_a10:  PUSHI i2cRAck 
 mem[12'h265]=16'h1267 ; //             PUSHI wi2c4_a11     
 mem[12'h266]=16'h435c ; //             JMP SubI2C1    
 mem[12'h267]=16'hd000 ; //wi2c4_a11:  in 
 mem[12'h268]=16'h1001 ; //             pushi 0x01
 mem[12'h269]=16'hf005 ; //             band
 mem[12'h26a]=16'h526d ; //             jz wi2c4_a11_1
 mem[12'h26b]=16'h1005 ; //             pushi 5            
 mem[12'h26c]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h26d]=16'h228a ; //wi2c4_a11_1:  push  wi2c4_val2
 mem[12'h26e]=16'h1008 ; //             pushi 8
 mem[12'h26f]=16'hf004 ; //             shr
 mem[12'h270]=16'h1272 ; //             pushi wi2c4_a12
 mem[12'h271]=16'h428c ; //             jmp si2c1
 mem[12'h272]=16'h1389 ; //wi2c4_a12:  PUSHI i2cRAck 
 mem[12'h273]=16'h1275 ; //             PUSHI wi2c4_a13     
 mem[12'h274]=16'h435c ; //             JMP SubI2C1    
 mem[12'h275]=16'hd000 ; //wi2c4_a13:  in 
 mem[12'h276]=16'h1001 ; //             pushi 0x01
 mem[12'h277]=16'hf005 ; //             band
 mem[12'h278]=16'h527b ; //             jz wi2c4_a13_1
 mem[12'h279]=16'h1006 ; //             pushi 6            
 mem[12'h27a]=16'h4280 ; //             jmp wi2c4_err
 mem[12'h27b]=16'h1395 ; //wi2c4_a13_1:  PUSHI i2cStop  
 mem[12'h27c]=16'h127e ; //             PUSHI wi2c4_a14     
 mem[12'h27d]=16'h435c ; //             JMP SubI2C1    
 mem[12'h27e]=16'h1000 ; //wi2c4_a14:  pushI 0          
 mem[12'h27f]=16'h4000 ; //wi2c4_rtn:  jmp 0x000            
 mem[12'h280]=16'h328b ; //wi2c4_err:  pop wi2c4_ercode
 mem[12'h281]=16'h1395 ; //             PUSHI i2cStop  
 mem[12'h282]=16'h1284 ; //             PUSHI wi2c4_a15     
 mem[12'h283]=16'h435c ; //             JMP SubI2C1    
 mem[12'h284]=16'h228b ; //wi2c4_a15:  push wi2c4_ercode
 mem[12'h285]=16'h427f ; //             jmp wi2c4_rtn 
 mem[12'h286]=16'h4000 ; //wi2c4_jmp:  0x4000
 mem[12'h287]=16'h0000 ; //wi2c4_addr:  0x0000
 mem[12'h288]=16'h0000 ; //wi2c4_reg:  0x0000
 mem[12'h289]=16'h0000 ; //wi2c4_val1:  0x0000
 mem[12'h28a]=16'h0000 ; //wi2c4_val2:  0x0000
 mem[12'h28b]=16'h0000 ; //wi2c4_ercode:  0x0000
 mem[12'h28c]=16'h22ae ; //si2c1:  PUSH si2c1_jmp    
 mem[12'h28d]=16'hf006 ; //             BOR               
 mem[12'h28e]=16'h32ad ; //             POP si2c1_rtn     
 mem[12'h28f]=16'h32af ; //             POP si2c1_val
 mem[12'h290]=16'h1008 ; //             PUSHI 8
 mem[12'h291]=16'h32b0 ; //             POP si2c1_i
 mem[12'h292]=16'h22af ; //si2c1_a3:  push si2c1_val
 mem[12'h293]=16'h1080 ; //             pushi 0x0080
 mem[12'h294]=16'hf005 ; //             band
 mem[12'h295]=16'h629d ; //             JNZ si2c1_a1
 mem[12'h296]=16'h1000 ; //             pushi 0x0000
 mem[12'h297]=16'he000 ; //             out
 mem[12'h298]=16'h1002 ; //             pushi 0x0002
 mem[12'h299]=16'he000 ; //             out
 mem[12'h29a]=16'h1000 ; //             pushi 0x0000
 mem[12'h29b]=16'he000 ; //             out
 mem[12'h29c]=16'h42a3 ; //             jmp si2c1_a2
 mem[12'h29d]=16'h1001 ; //si2c1_a1:  pushi 0x0001
 mem[12'h29e]=16'he000 ; //             out
 mem[12'h29f]=16'h1003 ; //             pushi 0x0003
 mem[12'h2a0]=16'he000 ; //             out
 mem[12'h2a1]=16'h1001 ; //             pushi 0x0001
 mem[12'h2a2]=16'he000 ; //             out
 mem[12'h2a3]=16'h22af ; //si2c1_a2:  push si2c1_val
 mem[12'h2a4]=16'h1001 ; //             pushi 1
 mem[12'h2a5]=16'hf003 ; //             shl
 mem[12'h2a6]=16'h32af ; //             pop  si2c1_val
 mem[12'h2a7]=16'h22b0 ; //             push si2c1_i
 mem[12'h2a8]=16'h1001 ; //             pushi 1
 mem[12'h2a9]=16'hf001 ; //             sub
 mem[12'h2aa]=16'h32b0 ; //             pop si2c1_i
 mem[12'h2ab]=16'h22b0 ; //             push si2c1_i
 mem[12'h2ac]=16'h6292 ; //             jnz si2c1_a3
 mem[12'h2ad]=16'h4000 ; //si2c1_rtn:  jmp 0x000     
 mem[12'h2ae]=16'h4000 ; //si2c1_jmp:  0x4000
 mem[12'h2af]=16'h0000 ; //si2c1_val:  0x0000
 mem[12'h2b0]=16'h0000 ; //si2c1_i:  0x0000
 mem[12'h2b1]=16'h22fb ; //ri2c1:  PUSH ri2c1_jmp    
 mem[12'h2b2]=16'hf006 ; //             BOR               
 mem[12'h2b3]=16'h32f4 ; //             POP ri2c1_rtn     
 mem[12'h2b4]=16'h32fc ; //             POP ri2c1_addr    
 mem[12'h2b5]=16'h32fd ; //             pop ri2c1_reg     
 mem[12'h2b6]=16'h32fe ; //             pop ri2c1_raddr   
 mem[12'h2b7]=16'h137c ; //             PUSHI i2cStart    
 mem[12'h2b8]=16'h12ba ; //             PUSHI ri2c1_a1    
 mem[12'h2b9]=16'h435c ; //             JMP SubI2C1       
 mem[12'h2ba]=16'h22fc ; //ri2c1_a1:  push ri2c1_addr
 mem[12'h2bb]=16'h1001 ; //             pushi 1
 mem[12'h2bc]=16'hf003 ; //             shl                   
 mem[12'h2bd]=16'h12bf ; //             pushi ri2c1_a2
 mem[12'h2be]=16'h428c ; //             jmp si2c1
 mem[12'h2bf]=16'h1389 ; //ri2c1_a2:  PUSHI i2cRAck 
 mem[12'h2c0]=16'h12c2 ; //             PUSHI ri2c1_a3     
 mem[12'h2c1]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2c2]=16'hd000 ; //ri2c1_a3:  in 
 mem[12'h2c3]=16'h1001 ; //             pushi 0x01
 mem[12'h2c4]=16'hf005 ; //             band
 mem[12'h2c5]=16'h52c8 ; //             jz ri2c1_a3_1
 mem[12'h2c6]=16'h1001 ; //             pushi 1           
 mem[12'h2c7]=16'h42f5 ; //             jmp ri2c1_err
 mem[12'h2c8]=16'h22fd ; //ri2c1_a3_1:  push ri2c1_reg
 mem[12'h2c9]=16'h12cb ; //             pushi ri2c1_a4
 mem[12'h2ca]=16'h428c ; //             jmp si2c1
 mem[12'h2cb]=16'h1389 ; //ri2c1_a4:  PUSHI i2cRAck 
 mem[12'h2cc]=16'h12ce ; //             PUSHI ri2c1_a5     
 mem[12'h2cd]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2ce]=16'hd000 ; //ri2c1_a5:  in 
 mem[12'h2cf]=16'h1001 ; //             pushi 0x01
 mem[12'h2d0]=16'hf005 ; //             band
 mem[12'h2d1]=16'h52d4 ; //             jz ri2c1_a5_1
 mem[12'h2d2]=16'h1002 ; //             pushi 2           
 mem[12'h2d3]=16'h42f5 ; //             jmp ri2c1_err
 mem[12'h2d4]=16'h137c ; //ri2c1_a5_1:  PUSHI i2cStart    
 mem[12'h2d5]=16'h12d7 ; //             PUSHI ri2c1_a6    
 mem[12'h2d6]=16'h435c ; //             JMP SubI2C1       
 mem[12'h2d7]=16'h22fc ; //ri2c1_a6:  push ri2c1_addr
 mem[12'h2d8]=16'h1001 ; //             pushi 1
 mem[12'h2d9]=16'hf003 ; //             shl                   
 mem[12'h2da]=16'h1001 ; //             pushi 0x0001
 mem[12'h2db]=16'hf006 ; //             BOR
 mem[12'h2dc]=16'h12de ; //             pushi ri2c1_a7
 mem[12'h2dd]=16'h428c ; //             jmp si2c1
 mem[12'h2de]=16'h1389 ; //ri2c1_a7:  PUSHI i2cRAck 
 mem[12'h2df]=16'h12e1 ; //             PUSHI ri2c1_a8     
 mem[12'h2e0]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2e1]=16'hd000 ; //ri2c1_a8:  in 
 mem[12'h2e2]=16'h1001 ; //             pushi 0x01
 mem[12'h2e3]=16'hf005 ; //             band
 mem[12'h2e4]=16'h52e7 ; //             jz ri2c1_a8_1
 mem[12'h2e5]=16'h1003 ; //             pushi 3           
 mem[12'h2e6]=16'h42f5 ; //             jmp ri2c1_err
 mem[12'h2e7]=16'h1399 ; //ri2c1_a8_1:  pushi i2cRead
 mem[12'h2e8]=16'h12ea ; //             pushi ri2c1_a9
 mem[12'h2e9]=16'h435c ; //             jmp SubI2C1
 mem[12'h2ea]=16'h22fe ; //ri2c1_a9:  push ri2c1_raddr
 mem[12'h2eb]=16'hd000 ; //             in
 mem[12'h2ec]=16'h8000 ; //             st 
 mem[12'h2ed]=16'h1391 ; //             PUSHI i2cNAck 
 mem[12'h2ee]=16'h12f0 ; //             PUSHI ri2c1_a10     
 mem[12'h2ef]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2f0]=16'h1395 ; //ri2c1_a10:  PUSHI i2cStop  
 mem[12'h2f1]=16'h12f3 ; //             PUSHI ri2c1_a11     
 mem[12'h2f2]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2f3]=16'h1000 ; //ri2c1_a11:  pushI 0          
 mem[12'h2f4]=16'h4000 ; //ri2c1_rtn:  jmp  0x000           
 mem[12'h2f5]=16'h32ff ; //ri2c1_err:  pop ri2c1_ercode
 mem[12'h2f6]=16'h1395 ; //             PUSHI i2cStop  
 mem[12'h2f7]=16'h12f9 ; //             PUSHI ri2c1_a12     
 mem[12'h2f8]=16'h435c ; //             JMP SubI2C1    
 mem[12'h2f9]=16'h22ff ; //ri2c1_a12:  push ri2c1_ercode
 mem[12'h2fa]=16'h42f4 ; //             jmp ri2c1_rtn 
 mem[12'h2fb]=16'h4000 ; //ri2c1_jmp:  0x4000
 mem[12'h2fc]=16'h0000 ; //ri2c1_addr:  0x0000
 mem[12'h2fd]=16'h0000 ; //ri2c1_reg:  0x0000
 mem[12'h2fe]=16'h0000 ; //ri2c1_raddr:  0x0000
 mem[12'h2ff]=16'h0000 ; //ri2c1_ercode:  0x0000
 mem[12'h300]=16'h2356 ; //ri2c2:  PUSH ri2c2_jmp    
 mem[12'h301]=16'hf006 ; //             BOR               
 mem[12'h302]=16'h334f ; //             POP ri2c2_rtn     
 mem[12'h303]=16'h3357 ; //             POP ri2c2_addr    
 mem[12'h304]=16'h3358 ; //             pop ri2c2_reg     
 mem[12'h305]=16'h3359 ; //             pop ri2c2_raddr   
 mem[12'h306]=16'h137c ; //             PUSHI i2cStart    
 mem[12'h307]=16'h1309 ; //             PUSHI ri2c2_a1    
 mem[12'h308]=16'h435c ; //             JMP SubI2C1       
 mem[12'h309]=16'h2357 ; //ri2c2_a1:  push ri2c2_addr
 mem[12'h30a]=16'h1001 ; //             pushi 1
 mem[12'h30b]=16'hf003 ; //             shl                   
 mem[12'h30c]=16'h130e ; //             pushi ri2c2_a2
 mem[12'h30d]=16'h428c ; //             jmp si2c1
 mem[12'h30e]=16'h1389 ; //ri2c2_a2:  PUSHI i2cRAck 
 mem[12'h30f]=16'h1311 ; //             PUSHI ri2c2_a3     
 mem[12'h310]=16'h435c ; //             JMP SubI2C1    
 mem[12'h311]=16'hd000 ; //ri2c2_a3:  in 
 mem[12'h312]=16'h1001 ; //             pushi 0x01
 mem[12'h313]=16'hf005 ; //             band
 mem[12'h314]=16'h5317 ; //             jz ri2c2_a3_1
 mem[12'h315]=16'h1001 ; //             pushi 1           
 mem[12'h316]=16'h4350 ; //             jmp ri2c2_err
 mem[12'h317]=16'h2358 ; //ri2c2_a3_1:  push ri2c2_reg
 mem[12'h318]=16'h131a ; //             pushi ri2c2_a4
 mem[12'h319]=16'h428c ; //             jmp si2c1
 mem[12'h31a]=16'h1389 ; //ri2c2_a4:  PUSHI i2cRAck 
 mem[12'h31b]=16'h131d ; //             PUSHI ri2c2_a5     
 mem[12'h31c]=16'h435c ; //             JMP SubI2C1    
 mem[12'h31d]=16'hd000 ; //ri2c2_a5:  in 
 mem[12'h31e]=16'h1001 ; //             pushi 0x01
 mem[12'h31f]=16'hf005 ; //             band
 mem[12'h320]=16'h5323 ; //             jz ri2c2_a5_1
 mem[12'h321]=16'h1002 ; //             pushi 2           
 mem[12'h322]=16'h4350 ; //             jmp ri2c2_err
 mem[12'h323]=16'h137c ; //ri2c2_a5_1:  PUSHI i2cStart    
 mem[12'h324]=16'h1326 ; //             PUSHI ri2c2_a6    
 mem[12'h325]=16'h435c ; //             JMP SubI2C1       
 mem[12'h326]=16'h2357 ; //ri2c2_a6:  push ri2c2_addr
 mem[12'h327]=16'h1001 ; //             pushi 1
 mem[12'h328]=16'hf003 ; //             shl                   
 mem[12'h329]=16'h1001 ; //             pushi 0x0001
 mem[12'h32a]=16'hf006 ; //             BOR
 mem[12'h32b]=16'h132d ; //             pushi ri2c2_a7
 mem[12'h32c]=16'h428c ; //             jmp si2c1
 mem[12'h32d]=16'h1389 ; //ri2c2_a7:  PUSHI i2cRAck 
 mem[12'h32e]=16'h1330 ; //             PUSHI ri2c2_a8     
 mem[12'h32f]=16'h435c ; //             JMP SubI2C1    
 mem[12'h330]=16'hd000 ; //ri2c2_a8:  in 
 mem[12'h331]=16'h1001 ; //             pushi 0x01
 mem[12'h332]=16'hf005 ; //             band
 mem[12'h333]=16'h5336 ; //             jz ri2c2_a8_1
 mem[12'h334]=16'h1003 ; //             pushi 3           
 mem[12'h335]=16'h4350 ; //             jmp ri2c2_err
 mem[12'h336]=16'h1399 ; //ri2c2_a8_1:  pushi i2cRead
 mem[12'h337]=16'h1339 ; //             pushi ri2c2_l9
 mem[12'h338]=16'h435c ; //             jmp SubI2C1
 mem[12'h339]=16'hd000 ; //ri2c2_l9:  in
 mem[12'h33a]=16'h1008 ; //             pushi 8
 mem[12'h33b]=16'hf003 ; //             shl
 mem[12'h33c]=16'h335a ; //             pop ri2c2_val1
 mem[12'h33d]=16'h138d ; //             PUSHI i2cWAck 
 mem[12'h33e]=16'h1340 ; //             PUSHI ri2c2_a10     
 mem[12'h33f]=16'h435c ; //             JMP SubI2C1    
 mem[12'h340]=16'h1399 ; //ri2c2_a10:  pushi i2cRead
 mem[12'h341]=16'h1343 ; //             pushi ri2c2_a11
 mem[12'h342]=16'h435c ; //             jmp SubI2C1
 mem[12'h343]=16'h2359 ; //ri2c2_a11:  push ri2c2_raddr
 mem[12'h344]=16'hd000 ; //             in
 mem[12'h345]=16'h235a ; //             push ri2c2_val1
 mem[12'h346]=16'hf006 ; //             bor
 mem[12'h347]=16'h8000 ; //             st 
 mem[12'h348]=16'h1391 ; //             PUSHI i2cNAck 
 mem[12'h349]=16'h134b ; //             PUSHI ri2c2_a12     
 mem[12'h34a]=16'h435c ; //             JMP SubI2C1    
 mem[12'h34b]=16'h1395 ; //ri2c2_a12:  PUSHI i2cStop  
 mem[12'h34c]=16'h134e ; //             PUSHI ri2c2_a13     
 mem[12'h34d]=16'h435c ; //             JMP SubI2C1    
 mem[12'h34e]=16'h1000 ; //ri2c2_a13:  pushI 0   
 mem[12'h34f]=16'h4000 ; //ri2c2_rtn:  jmp  0x000           
 mem[12'h350]=16'h335b ; //ri2c2_err:  pop ri2c2_ercode
 mem[12'h351]=16'h1395 ; //             PUSHI i2cStop  
 mem[12'h352]=16'h1354 ; //             PUSHI ri2c2_a14     
 mem[12'h353]=16'h435c ; //             JMP SubI2C1    
 mem[12'h354]=16'h235b ; //ri2c2_a14:  push ri2c2_ercode
 mem[12'h355]=16'h434f ; //             jmp ri2c2_rtn  
 mem[12'h356]=16'h4000 ; //ri2c2_jmp:  0x4000
 mem[12'h357]=16'h0000 ; //ri2c2_addr:  0x0000
 mem[12'h358]=16'h0000 ; //ri2c2_reg:  0x0000
 mem[12'h359]=16'h0000 ; //ri2c2_raddr:  0x0000
 mem[12'h35a]=16'h0000 ; //ri2c2_val1:  0x0000
 mem[12'h35b]=16'h0000 ; //ri2c2_ercode:  0x0000
 mem[12'h35c]=16'h2377 ; //SubI2C1:  PUSH LblJMP    
 mem[12'h35d]=16'hf006 ; //             BOR            
 mem[12'h35e]=16'h3376 ; //             POP RtnSub1    
 mem[12'h35f]=16'h3378 ; //             POP Sub1Data2  
 mem[12'h360]=16'h2378 ; //             PUSH Sub1Data2
 mem[12'h361]=16'h7000 ; //             LD
 mem[12'h362]=16'h337b ; //             POP N
 mem[12'h363]=16'h2378 ; //             PUSH Sub1Data2
 mem[12'h364]=16'h1001 ; //             PUSHI 1
 mem[12'h365]=16'hf000 ; //             ADD
 mem[12'h366]=16'h3379 ; //             POP Sub1SA
 mem[12'h367]=16'h1000 ; //             PUSHI 0
 mem[12'h368]=16'h337a ; //             POP i
 mem[12'h369]=16'h237a ; //L1:  PUSH i
 mem[12'h36a]=16'h2379 ; //             PUSH Sub1SA
 mem[12'h36b]=16'hf000 ; //             ADD
 mem[12'h36c]=16'h7000 ; //             LD     
 mem[12'h36d]=16'he000 ; //             OUT    
 mem[12'h36e]=16'h237a ; //             PUSH i
 mem[12'h36f]=16'h1001 ; //             PUSHI 1     
 mem[12'h370]=16'hf000 ; //             ADD
 mem[12'h371]=16'h337a ; //             POP i
 mem[12'h372]=16'h237a ; //             PUSH i
 mem[12'h373]=16'h237b ; //             PUSH N
 mem[12'h374]=16'hf001 ; //             SUB
 mem[12'h375]=16'h6369 ; //             JNZ L1  
 mem[12'h376]=16'h4000 ; //RtnSub1:  JMP 0x000           
 mem[12'h377]=16'h4000 ; //LblJMP:  0x4000
 mem[12'h378]=16'h0000 ; //Sub1Data2:  0x0000
 mem[12'h379]=16'h0000 ; //Sub1SA:  0x0000
 mem[12'h37a]=16'h0000 ; //i:  0x0000
 mem[12'h37b]=16'h0000 ; //N:  0x0000
 mem[12'h37c]=16'h0003 ; //i2cStart:  3
 mem[12'h37d]=16'h0001 ; //             1 
 mem[12'h37e]=16'h0003 ; //             3 
 mem[12'h37f]=16'h0002 ; //             2 
 mem[12'h380]=16'h0000 ; //             0 
 mem[12'h381]=16'h0003 ; //i2cAddrW:  3
 mem[12'h382]=16'h0000 ; //             0 
 mem[12'h383]=16'h0002 ; //             2 
 mem[12'h384]=16'h0000 ; //             0 
 mem[12'h385]=16'h0003 ; //i2cAddrR:  3
 mem[12'h386]=16'h0001 ; //             1   
 mem[12'h387]=16'h0003 ; //             3   
 mem[12'h388]=16'h0001 ; //             1   
 mem[12'h389]=16'h0003 ; //i2cRAck:  3
 mem[12'h38a]=16'h0001 ; //             1   
 mem[12'h38b]=16'h0003 ; //             3   
 mem[12'h38c]=16'h0001 ; //             1   
 mem[12'h38d]=16'h0003 ; //i2cWAck:  3
 mem[12'h38e]=16'h0000 ; //             0  
 mem[12'h38f]=16'h0002 ; //             2  
 mem[12'h390]=16'h0000 ; //             0  
 mem[12'h391]=16'h0003 ; //i2cNAck:  3
 mem[12'h392]=16'h0001 ; //             1  
 mem[12'h393]=16'h0003 ; //             3  
 mem[12'h394]=16'h0001 ; //             1  
 mem[12'h395]=16'h0003 ; //i2cStop:  3
 mem[12'h396]=16'h0002 ; //             2  
 mem[12'h397]=16'h0003 ; //             3  
 mem[12'h398]=16'h0003 ; //             3  
 mem[12'h399]=16'h0011 ; //i2cRead:  0x0011
 mem[12'h39a]=16'h0001 ; //             1  
 mem[12'h39b]=16'h0003 ; //             3  
 mem[12'h39c]=16'h0001 ; //             1  
 mem[12'h39d]=16'h0003 ; //             3  
 mem[12'h39e]=16'h0001 ; //             1  
 mem[12'h39f]=16'h0003 ; //             3  
 mem[12'h3a0]=16'h0001 ; //             1  
 mem[12'h3a1]=16'h0003 ; //             3  
 mem[12'h3a2]=16'h0001 ; //             1  
 mem[12'h3a3]=16'h0003 ; //             3  
 mem[12'h3a4]=16'h0001 ; //             1  
 mem[12'h3a5]=16'h0003 ; //             3  
 mem[12'h3a6]=16'h0001 ; //             1  
 mem[12'h3a7]=16'h0003 ; //             3  
 mem[12'h3a8]=16'h0001 ; //             1  
 mem[12'h3a9]=16'h0003 ; //             3  
 mem[12'h3aa]=16'h0001 ; //             1  
 
 
 end
 endmodule
----
#counter

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS