label begin_of_program
              //WAIT 500ms
              mov.w #0x1F4,r1
label L_sys_1002
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1003
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1003
              mov.w r1,r1
              bne L_sys_1002
              // @0XFD8E = 255
              mov.w #0xFF,r6
              mov.w r6,@0xFD8E
label begin_of_task_0
              //make room for stack variables
              mov.w #0x2,r0
              sub.w r0,r7
              
              //clear user memory
              mov.w #0xcc40,r0
              mov.w #0xF000,r1
              jsr @0x436
              
              //start initialization
              jsr sys_init_segment_arrays
              
              //define array
              //segment_address_array
              //define array
              //segment_bit_array
              //define array
              //TEXT
              //define array
              //sa_waveforms
              //define array
              //task_state
              //define array
              //task_addresses
              jsr init_task_address_list
              //fix stack-base
              mov.w #0xCBFE,r7
              jsr init_RCX
              //disable
              orc #0x80
              
              //disable OCIA-interrupt
              //(needed when background-handler is active)
              mov.b @0xFF90,r0L
              and #0xF7,r0L
              mov.b r0L,@0xFF90
              //new RUN-button handler
              mov.w sys_IRQ0_run_handler,r6
              mov.w r6,@0xfd94
              //enable
              andc #0x7F
              
              //WAIT 100ms
              mov.w #0x64,r1
label L_sys_1004
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1005
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1005
              mov.w r1,r1
              bne L_sys_1004
              //ROM_CALL
              jsr @0x27AC
              //ROM_CALL
              jsr @0x27C8
              mov.w #0x3006,r6
              jsr @0x1b62
              //ROM_CALL
              jsr @0x27C8
              //write LEGO
              // SV_DISPLAY_POINTER = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              //Initialize array
              //TEXT
              mov.b #0x0,r6L
              mov.b r6L,@0xCC86
              mov.b #0x56,r6L
              mov.b r6L,@0xCC87
              mov.b #0x77,r6L
              mov.b r6L,@0xCC88
              mov.b #0x67,r6L
              mov.b r6L,@0xCC89
              mov.b #0x64,r6L
              mov.b r6L,@0xCC8A
              jsr sys_write_ASCII
              //ROM_CALL
              jsr @0x27C8
              mov.w sys_disable_enable_reboot_entry_point,r0
              mov.w #0x0,r6
              mov.w r6,@r0 
              mov.w sys_disable_enable_entry_point,r0
              mov.w #0x0,r6
              mov.w r6,@r0 
              mov.b @0xFFC7,r6L
              or #0x1,r6L
              mov.b r6L,@0xFFC7
label beginloop_1006
              //IF SV_RUNNING = @0XFD8E
              mov.w @0xFD8E,r5
              mov.b @0xCD2C,r6L
              cmp.b r5L,r6L
              beq loopdo_1006
              jmp endloop_1006
label loopdo_1006
              jsr sys_check_on_off
              jmp beginloop_1006
label endloop_1006
              mov.w #0x1,r6
              jsr sys_wait_ms_new
              // SV_RUNNING = 255
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD2C
              
              // @0XFD8E = 0
              mov.w #0x0,r6
              mov.w r6,@0xFD8E
              
              //write 
              // SV_DISPLAY_POINTER = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              //Initialize array
              //TEXT
              mov.b #0x0,r6L
              mov.b r6L,@0xCC86
              mov.b #0x0,r6L
              mov.b r6L,@0xCC87
              mov.b #0x0,r6L
              mov.b r6L,@0xCC88
              mov.b #0x0,r6L
              mov.b r6L,@0xCC89
              mov.b #0x0,r6L
              mov.b r6L,@0xCC8A
              jsr sys_write_ASCII
              //ROM_CALL
              jsr @0x27C8
              //define array
              //RX_data
              // RX_DATA_LENGTH = 6,097400E+4
              mov.w #0xEE2E,r6
              mov.w r6,@0xCD40
              
              // ^RX_DATA_LENGTH = 0
              mov.b #0x0,r6L
              mov.w @0xCD40,r0
              mov.b r6L,@r0
              
              // TRANSMITTING = 6,133100E+4
              mov.w #0xEF93,r6
              mov.w r6,@0xCD42
              
              // VALID = 6,136600E+4
              mov.w #0xEFB6,r6
              mov.w r6,@0xCD44
              
              // @0XEFB8 = 6,103200E+4
              mov.w #0xEE68,r6
              mov.w r6,@0xEFB8
              
              // ^0XEFB8 = 0
              mov.b #0x0,r6L
              mov.w @0xEFB8,r0
              mov.b r6L,@r0
              
              // RX_POINTER = 5,252800E+4
              mov.w #0xCD30,r6
              mov.w r6,@0xCD46
              
              // MOTOR0_P = 6,097800E+4
              mov.w #0xEE32,r6
              mov.w r6,@0xCD48
              
              // MOTOR1_P = 6,098400E+4
              mov.w #0xEE38,r6
              mov.w r6,@0xCD4A
              
              // MOTOR2_P = 6,099000E+4
              mov.w #0xEE3E,r6
              mov.w r6,@0xCD4C
              
              // MOTOR0_C = 6,097900E+4
              mov.w #0xEE33,r6
              mov.w r6,@0xCD4E
              
              // MOTOR1_C = 6,098500E+4
              mov.w #0xEE39,r6
              mov.w r6,@0xCD50
              
              // MOTOR2_C = 6,099100E+4
              mov.w #0xEE3F,r6
              mov.w r6,@0xCD52
              
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              // SV_VIEW = 255
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD55
              
              //define array
              //sub_addresses
              jsr init_sub_address_list
              //Start task 1
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 1
              mov.w #0x1,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 0
              mov.b #0x0,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //disable
              orc #0x80
              mov.b @0xFF90,r0L
              or #0x8,r0L
              mov.b r0L,@0xFF90
              // BATTERY_SAMPLES = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD6C
              
              // BATTERY_LEVEL = 9000
              mov.w #0x2328,r6
              mov.w r6,@0xCD6E
              
              // BATTERY_SUM = 0
              mov.w #0x0,r5
              mov.w #0x0,r6
              mov.w r5,@0xCD70
              mov.w r6,@0xCD72
              
              // RUNNING_MAN = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD74
              
              // RX_INDEX = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD76
              
              // OPCODE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD78
              
              // CLEARED_OPCODE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD79
              mov.w #0xCD30,r0
              mov.w #0x0,r2
label sys_clear_memory1007
              mov.w #0xCD40,r1
              mov.w r2,@r0
              adds #0x2,r0
              sub.w r0,r1
              bne sys_clear_memory1007
              // F7_MESSAGE = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD7A
              
              // D2_REMOTE_COMMAND = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD7C
              
              // SV_DISPL_COUNTER_N = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD7E
              
              // MAX_LOG_SIZE = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD80
              
              // DATALOG_READY = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD82
              
              // QUARTER_REFRESH_DELAY = 25
              mov.b #0x19,r6L
              mov.b r6L,@0xCD83
              
              // STARTED_LOGGING_CYCLE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD84
              
              //enable
              andc #0x7F
              
              //WAIT 50ms
              mov.w #0x32,r1
label L_sys_1009
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1010
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1010
              mov.w r1,r1
              bne L_sys_1009
label lab_0_1008
              //IF @0XEE64 >= 128
              mov.w #0x80,r5
              mov.w @0xEE64,r6
              cmp.w r5,r6
              //  >=
              bcc true_1011
              jmp false_1011
label true_1011
              //ReadSensor
              mov.w #0xA,r0
              sub.w r0,r7
              mov.w r7,@(0x8,r7)
              mov.w #0xEE44,r5
              mov.b #0x7,r4L
              mov.w r7,r6
              eepmov 0
              //ROM_CALL
              mov.w @(0x8,r7),r6
              mov.w r6,@-r7
               mov.w #0x1000,r6
              jsr @0x14C0
              adds #0x2,r7
              mov.w r7,r5
              mov.b #0x7,r4L
              mov.w #0xEE44,r6
              eepmov 0
              mov.w #0xA,r0
              add.w r0,r7
              //ReadSensor
              mov.w #0xA,r0
              sub.w r0,r7
              mov.w r7,@(0x8,r7)
              mov.w #0xEE4C,r5
              mov.b #0x7,r4L
              mov.w r7,r6
              eepmov 0
              //ROM_CALL
              mov.w @(0x8,r7),r6
              mov.w r6,@-r7
               mov.w #0x1001,r6
              jsr @0x14C0
              adds #0x2,r7
              mov.w r7,r5
              mov.b #0x7,r4L
              mov.w #0xEE4C,r6
              eepmov 0
              mov.w #0xA,r0
              add.w r0,r7
              //ReadSensor
              mov.w #0xA,r0
              sub.w r0,r7
              mov.w r7,@(0x8,r7)
              mov.w #0xEE54,r5
              mov.b #0x7,r4L
              mov.w r7,r6
              eepmov 0
              //ROM_CALL
              mov.w @(0x8,r7),r6
              mov.w r6,@-r7
               mov.w #0x1002,r6
              jsr @0x14C0
              adds #0x2,r7
              mov.w r7,r5
              mov.b #0x7,r4L
              mov.w #0xEE54,r6
              eepmov 0
              mov.w #0xA,r0
              add.w r0,r7
              //@0XEE64 =@0XEE64 AND 127
              mov.w #0x7F,r5
              mov.w @0xEE64,r6
              and r5L,r6L
              and r5H,r6H
              mov.w r6,@0xEE64
              jmp endif_1011
label false_1011
Label endif_1011
              jsr sys_check_on_off
              //IF @0XEE28 = SV_VIEW_LAST_STATE
              mov.b @0xCD85,r5L
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1012
              jmp false_1012
label true_1012
              //SV_VIEW_UPDATE =SV_VIEW_UPDATE + 1
              mov.w #0x1,r5
              mov.w @0xCD86,r6
              add.w r5,r6
              mov.w r6,@0xCD86
              
              //IF SV_VIEW_UPDATE > 400
              mov.w #0x190,r5
              mov.w @0xCD86,r6
              cmp.w r5,r6
              bhi true_1013
              jmp false_1013
label true_1013
              //IF @0XEE28 = 2
              mov.w #0x2,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1014
              jmp false_1014
label true_1014
              // SV_VIEW_READY = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD88
              jmp endif_1014
label false_1014
              
              //IF @0XEE28 <> 0
              mov.w #0x0,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  <>
              bne true_1015
              jmp false_1015
label true_1015
              jmp endif_1015
label false_1015
              
              //IF SV_VIEW_READY = 1
              mov.b #0x1,r5L
              mov.b @0xCD88,r6L
              cmp.b r5L,r6L
              beq true_1016
              jmp false_1016
label true_1016
              // SV_VIEW_READY = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD88
              
              //SV_VIEW =SV_VIEW + 1
              mov.b #0x1,r5L
              mov.b @0xCD55,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCD55
              
              //IF SV_VIEW > 7
              mov.b #0x7,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bhi true_1017
              jmp false_1017
label true_1017
              // SV_VIEW = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD55
              jmp endif_1017
label false_1017
Label endif_1017
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
              
              // SV_POINTER_X_L_0 = SV_VIEW
              mov.b @0xCD55,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCD8A
              
              //SV_POINTER_X_L_0 =SV_POINTER_X_L_0 * 8
              mov.w #0x8,r5
              mov.w @0xCD8A,r6
              jsr @0x0130
              mov.w r6,@0xCD8A
              
              //SV_POINTER_X_L_0 =SV_POINTER_X_L_0 + 6,099600E+4
              mov.w #0xEE44,r5
              mov.w @0xCD8A,r6
              add.w r5,r6
              mov.w r6,@0xCD8A
              
              //IF ^SV_POINTER_X_L_0 = 2
              mov.b #0x2,r5L
              mov.w @0xCD8A,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq true_1018
              jmp false_1018
label true_1018
              //SV_POINTER_X_L_0 =SV_POINTER_X_L_0 + 1
              mov.w #0x1,r5
              mov.w @0xCD8A,r6
              add.w r5,r6
              mov.w r6,@0xCD8A
              
              //IF ^SV_POINTER_X_L_0 >= 160
              mov.b #0xA0,r5L
              mov.w @0xCD8A,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bcc true_1019
              jmp false_1019
label true_1019
              //IF ^SV_POINTER_X_L_0 <= 223
              mov.b #0xDF,r5L
              mov.w @0xCD8A,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bls true_1020
              jmp false_1020
label true_1020
              // SV_DISPLAY_SCALE = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD89
              jmp endif_1020
label false_1020
Label endif_1020
              jmp endif_1019
label false_1019
Label endif_1019
              jmp endif_1018
label false_1018
Label endif_1018
              //IF SV_VIEW <> 0
              mov.b #0x0,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1021
              jmp false_1021
label true_1021
              //IF SV_VIEW <> 1
              mov.b #0x1,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1022
              jmp false_1022
label true_1022
              //IF SV_VIEW <> 2
              mov.b #0x2,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1023
              jmp false_1023
label true_1023
              //IF SV_VIEW <> 3
              mov.b #0x3,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1024
              jmp false_1024
label true_1024
              //IF SV_VIEW <> 4
              mov.b #0x4,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1025
              jmp false_1025
label true_1025
              //IF SV_VIEW <> 5
              mov.b #0x5,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1026
              jmp false_1026
label true_1026
              //IF SV_VIEW <> 6
              mov.b #0x6,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1027
              jmp false_1027
label true_1027
              //IF SV_VIEW <> 7
              mov.b #0x7,r5L
              mov.b @0xCD55,r6L
              cmp.b r5L,r6L
              bne true_1028
              jmp false_1028
label true_1028
              //default
              jmp endif_1028
label false_1028
              
              //case 7 : VIEW mail
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              jsr @0x27AC
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x301c,r6
              jsr @0x1b62
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 5,260200E+4
              mov.w #0xCD7A,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
Label endif_1028
              jmp endif_1027
label false_1027
              
              //case 6 : VIEW battery
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              jsr @0x27AC
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x301b,r6
              jsr @0x1b62
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 5,259000E+4
              mov.w #0xCD6E,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 3
              mov.b #0x3,r6L
              mov.b r6L,@0xCD89
Label endif_1027
              jmp endif_1026
label false_1026
              
              //case 5 : VIEW motor C
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x3014,r6
              jsr @0x1b62
              // SV_DISPLAY_UPDATE_MOTOR = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD54
              
              // SV_DISPLAY_TYPE = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,099000E+4
              mov.w #0xEE3E,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
Label endif_1026
              jmp endif_1025
label false_1025
              
              //case 4 : VIEW motor B
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x3011,r6
              jsr @0x1b62
              // SV_DISPLAY_UPDATE_MOTOR = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD54
              
              // SV_DISPLAY_TYPE = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,098400E+4
              mov.w #0xEE38,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
Label endif_1025
              jmp endif_1024
label false_1024
              
              //case 3 : VIEW motor A
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x300e,r6
              jsr @0x1b62
              // SV_DISPLAY_UPDATE_MOTOR = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD54
              
              // SV_DISPLAY_TYPE = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,097800E+4
              mov.w #0xEE32,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
Label endif_1024
              jmp endif_1023
label false_1023
              
              //case 2 : VIEW sensor 2
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x300c,r6
              jsr @0x1b62
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,101600E+4
              mov.w #0xEE58,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = SV_DISPLAY_SCALE
              mov.b @0xCD89,r6L
              mov.b r6L,@0xCD89
Label endif_1023
              jmp endif_1022
label false_1022
              
              //case 1 : VIEW sensor 1
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x300a,r6
              jsr @0x1b62
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = SV_DISPLAY_SCALE
              mov.b @0xCD89,r6L
              mov.b r6L,@0xCD89
Label endif_1022
              jmp endif_1021
label false_1021
              
              //case 0 : VIEW sensor 0
              // SV_DISPLAY_UPDATE_MOTOR = -1
              mov.b #0xFF,r6L
              mov.b r6L,@0xCD54
              
              //ROM_CALL
              jsr @0x27AC
              mov.w #0x3008,r6
              jsr @0x1b62
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = SV_DISPLAY_SCALE
              mov.b @0xCD89,r6L
              mov.b r6L,@0xCD89
Label endif_1021
              jmp endif_1016
label false_1016
Label endif_1016
Label endif_1015
Label endif_1014
              jmp endif_1013
label false_1013
Label endif_1013
              jmp endif_1012
label false_1012
              
              // SV_VIEW_UPDATE = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD86
Label endif_1012
              // SV_VIEW_LAST_STATE = @0XEE28
              mov.w @0xEE28,r6
              mov.b r6L,@0xCD85
              
              //IF @0XEFD2 >= 10
              mov.w #0xA,r5
              mov.w @0xEFD2,r6
              cmp.w r5,r6
              //  >=
              bcc true_1029
              jmp false_1029
label true_1029
               MOV.B   @0xEFF6, R6L
               BEQ     0x4
               JMP     slab11030
               MOV.B   @0xC8, R6L
               AND     #0xFC, R6L
               MOV.B   R6L, @0xC8
               BCLR    #0x0, @0xC3
               MOV.B   @0xEFFE, R6L
               CMP.B   #0x01, R6L
               BNE     0x52
               MOV.W   @0xEFF8, R6
               ADDS    #0x1, R6
               MOV.W   R6, @0xEFF8
               MOV.B   @R6, R5L
               CMP.B   #0x01, R5L
               BNE     0x8
               SUB.B   R6L, R6L
               MOV.B   R6L, @0xEFFE
               BRA     0x3a
               MOV.W   @0xEFFA, R6
               ADDS    #0x1, R6
               MOV.W   @0xEFFC, R5
               ADDS    #0x1, R5
               MOV.W   @0xEFF8, R4
               MOV.B   @R4, R3L
               MOV.B   R3L, @0xCA
               MOV.W   R6, @0xEFFA
               MOV.B   @R6, R4L
               MOV.B   R4L, @0xEFF6
               MOV.W   R5, @0xEFFC
               MOV.B   @R5, R6L
               AND     #0x01, R6L
               MOV.B   @0xC3, R5L
               OR      R6L, R5L
               MOV.B   R5L, @0xC3
               MOV.W   @0xEFFC, R6
               MOV.B   @R6, R5L
               SHLR    R5L
               MOV.B   @0xC8, R6L
               OR      R5L, R6L
               MOV.B   R6L, @0xC8
               MOV.B   @0xEFFE, R6L
               BEQ     0x4
               JMP     slab21030
               MOV.B   @0xEFD7, R6L
               SUB.B   R6H, R6H
               ADDS    #0x1, R6
               MOV.W   #0x000A, R5
               JSR     @@0x50
               MOV.W   R6, R1
               MOV.B   @0xEFD6, R6L
               SUB.B   R6H, R6H
               CMP.W   R6, R1
               BNE     0x4
               JMP     slab31030
               MOV.B   R1L, R6L
               MOV.B   R1L, @0xEFD7
               MOV.B   @(0xEFD8,R6), R5L
               CMP.B   R6H, R5L
               BNE     0xe
               MOV.B   R1L, R6L
               MOV.B   @(0xEFE2,R6), R5L
               MOV.B   R5L, @0xEFF6
               JMP     slab41030
               CMP.B   #0x01, R5L
               BEQ     0x4
               JMP     slab51030
               MOV.B   #0x01, R6L
               MOV.B   R6L, @0xEFFE
               MOV.B   R1L, R6L
               MOV.B   @(0xEFE2,R6), R5L
               CMP.B   R6H, R5L
               BNE     0x1c
               MOV.W   #0x3F46, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F4A, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3F4C, R6
               MOV.W   R6, @0xEFFC
               JMP     slab61030
               CMP.B   #0x01, R5L
               BNE     0x1c
               MOV.W   #0x3F4E, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F54, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3F58, R6
               MOV.W   R6, @0xEFFC
               JMP     slab61030
               CMP.B   #0x02, R5L
               BNE     0x1a
               MOV.W   #0x3F5C, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F68, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3F72, R6
               MOV.W   R6, @0xEFFC
               BRA     0x72
               CMP.B   #0x03, R5L
               BNE     0x1a
               MOV.W   #0x3F7C, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F88, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3F92, R6
               MOV.W   R6, @0xEFFC
               BRA     0x54
               CMP.B   #0x04, R5L
               BNE     0x1a
               MOV.W   #0x3F9C, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F9E, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3FA0, R6
               MOV.W   R6, @0xEFFC
               BRA     0x36
               CMP.B   #0x05, R5L
               BNE     0x1a
               MOV.W   #0x3FA2, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3FAE, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3FB8, R6
               MOV.W   R6, @0xEFFC
               BRA     0x18
               MOV.W   #0x3F9C, R6
               MOV.W   R6, @0xEFF8
               MOV.W   #0x3F9E, R6
               MOV.W   R6, @0xEFFA
               MOV.W   #0x3FA0, R6
               MOV.W   R6, @0xEFFC
label slab61030
               MOV.W   @0xEFF8, R6
               MOV.B   @R6, R5L
               MOV.B   R5L, @0xCA
               MOV.W   @0xEFFA, R6
               MOV.B   @R6, R5L
               MOV.B   R5L, @0xEFF6
               MOV.W   @0xEFFC, R6
               MOV.B   @R6, R5L
               AND     #0x01, R5L
               MOV.B   @0xC3, R6L
               OR      R5L, R6L
               MOV.B   R6L, @0xC3
               MOV.W   @0xEFFC, R6
               MOV.B   @R6, R5L
               SHLR    R5L
               MOV.B   @0xC8, R6L
               OR      R5L, R6L
               MOV.B   R6L, @0xC8
               BRA     0x2e
label slab51030
               MOV.B   R1L, R6L
               MOV.B   @(0xEFE2,R6), R5L
               MOV.B   R5L, @0xEFF6
               MOV.B   R1L, R6L
               MOV.B   @(0xEFD8,R6), R5L
               MOV.B   R5L, @0xCA
               MOV.B   R1L, R6L
               MOV.B   @(0xEFEC,R6), R5L
               AND     #0x01, R5L
               MOV.B   @0xC3, R6L
               OR      R5L, R6L
               MOV.B   R6L, @0xC3
               MOV.B   R1L, R6L
               MOV.B   @(0xEFEC,R6), R5L
               SHLR    R5L
               MOV.B   @0xC8, R6L
               OR      R5L, R6L
               MOV.B   R6L, @0xC8
label slab41030
               BRA     0x10
label slab31030
               SUB.B   R6L, R6L
               MOV.B   R6L, @0xEFFF
               MOV.B   @0xC8, R6L
               AND     #0xFC, R6L
               MOV.B   R6L, @0xC8
               BCLR    #0x0, @0xC3
label slab21030
               BRA     0x6
label slab11030
               DEC   R6L
               MOV.B   R6L, @0xEFF6
              //SV_DISPL_COUNTER_N =SV_DISPL_COUNTER_N + 1
              mov.b #0x1,r5L
              mov.b @0xCD7E,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCD7E
              
              //IF SV_DISPL_COUNTER_N >= 10
              mov.b #0xA,r5L
              mov.b @0xCD7E,r6L
              cmp.b r5L,r6L
              bcc true_1031
              jmp false_1031
label true_1031
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0xEE18,r6
              mov.w r6,@-r7
              mov.w #0x4001,r6
              jsr @0x29F2
              adds #0x2,r7
              //BATTERY_SUM =BATTERY_SUM + @0XEE18
              mov.w @0xEE18,r4
              mov.w #0x0,r3
              mov.w @0xCD70,r5
              mov.w @0xCD72,r6
              add.w r4,r6
              addx r3L,r5L
              addx r3H,r5H
              mov.w r5,@0xCD70
              mov.w r6,@0xCD72
              
              //BATTERY_SAMPLES =BATTERY_SAMPLES + 1
              mov.b #0x1,r5L
              mov.b @0xCD6C,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCD6C
              
              //IF BATTERY_SAMPLES >= 20
              mov.b #0x14,r5L
              mov.b @0xCD6C,r6L
              cmp.b r5L,r6L
              bcc true_1032
              jmp false_1032
label true_1032
              //BATTERY_SUM =BATTERY_SUM * 4,398800E+4
              mov.w #0x0,r3
              mov.w #0xABD4,r4
              mov.w @0xCD70,r5
              mov.w @0xCD72,r6
              jsr @0x01fe
              mov.w r5,@0xCD70
              mov.w r6,@0xCD72
              
              //BATTERY_SUM =BATTERY_SUM / 31200
              mov.w #0x0,r3
              mov.w #0x79E0,r4
              mov.w @0xCD70,r5
              mov.w @0xCD72,r6
              jsr @0x0306
              mov.w r5,@0xCD70
              mov.w r6,@0xCD72
              
              //IF BATTERY_SUM <= 9999
              mov.w #0x0,r3
              mov.w #0x270F,r4
              mov.w @0xCD70,r5
              mov.w @0xCD72,r6
              sub.w r4,r6
              subx r3L,r5L
              subx r3H,r5H
              bls true_1033
              jmp false_1033
label true_1033
              // BATTERY_LEVEL = BATTERY_SUM
              mov.w @0xCD70,r5
              mov.w @0xCD72,r6
              jsr sys_type_cast_U32_to_I32
              mov.w r6,@0xCD6E
              jmp endif_1033
label false_1033
Label endif_1033
              // BATTERY_SAMPLES = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD6C
              
              // BATTERY_SUM = 0
              mov.w #0x0,r5
              mov.w #0x0,r6
              mov.w r5,@0xCD70
              mov.w r6,@0xCD72
              
              //IF BATTERY_LEVEL < 7000
              mov.w #0x1B58,r5
              mov.w @0xCD6E,r6
              cmp.w r5,r6
              blt true_1034
              jmp false_1034
label true_1034
              mov.w #0x301b,r6
              jsr @0x1b62
              jmp endif_1034
label false_1034
              mov.w #0x301b,r6
              jsr @0x1e4a
Label endif_1034
              jmp endif_1032
label false_1032
Label endif_1032
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //SLOW_DISPLAY_UPDATE_TIME =SLOW_DISPLAY_UPDATE_TIME + 1
              mov.b #0x1,r5L
              mov.b @0xCD96,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCD96
              
              //IF SLOW_DISPLAY_UPDATE_TIME >= QUARTER_REFRESH_DELAY
              mov.b @0xCD83,r5L
              mov.b @0xCD96,r6L
              cmp.b r5L,r6L
              bcc true_1035
              jmp false_1035
label true_1035
              // SLOW_DISPLAY_UPDATE_TIME = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD96
              mov.w #0x301a,r6
              jsr @0x1e4a
              //IF MAX_LOG_SIZE <> 0
              mov.w #0x0,r5
              mov.w @0xCD80,r6
              cmp.w r5,r6
              bne true_1036
              jmp false_1036
label true_1036
              // DATALOG_QUARTERS_STATE = LOG_SIZE
              mov.w @0xCD9C,r6
              jsr sys_type_cast_U16_to_U32
              mov.w r5,@0xCD98
              mov.w r6,@0xCD9A
              
              //DATALOG_QUARTERS_STATE =DATALOG_QUARTERS_STATE * 4
              mov.w #0x0,r3
              mov.w #0x4,r4
              mov.w @0xCD98,r5
              mov.w @0xCD9A,r6
              jsr @0x01fe
              mov.w r5,@0xCD98
              mov.w r6,@0xCD9A
              
              //DATALOG_QUARTERS_STATE =DATALOG_QUARTERS_STATE / MAX_LOG_SIZE
              mov.w @0xCD80,r6
              jsr sys_type_cast_U16_to_U32
              mov.w r5,r3
              mov.w r6,r4
              mov.w @0xCD98,r5
              mov.w @0xCD9A,r6
              jsr @0x0306
              mov.w r5,@0xCD98
              mov.w r6,@0xCD9A
              
              //IF DATALOG_QUARTERS_STATE <= 3
              mov.w #0x0,r3
              mov.w #0x3,r4
              mov.w @0xCD98,r5
              mov.w @0xCD9A,r6
              sub.w r4,r6
              subx r3L,r5L
              subx r3H,r5H
              bls true_1038
              // DATALOG_QUARTERS_STATE = 3
              mov.w #0x0,r5
              mov.w #0x3,r6
              mov.w r5,@0xCD98
              mov.w r6,@0xCD9A
label true_1038
              //DATALOG_QUARTERS_STATE =DATALOG_QUARTERS_STATE + 1
              mov.w #0x0,r3
              mov.w #0x1,r4
              mov.w @0xCD98,r5
              mov.w @0xCD9A,r6
              add.w r4,r6
              addx r3L,r5L
              addx r3H,r5H
              mov.w r5,@0xCD98
              mov.w r6,@0xCD9A
              mov.w #0x3018,r6
              jsr @0x1e4a
              // QUARTERS_INDEX_L_0 = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD9E
label beginloop_1039
              //IF QUARTERS_INDEX_L_0 < DATALOG_QUARTERS_STATE
              mov.w @0xCD98,r3
              mov.w @0xCD9A,r5
              mov.b @0xCD9E,r6L
              cmp.b r5L,r6L
              bcs fordo_1039
              jmp endloop_1039
label fordo_1039
              inc r6L
              mov.b r6L,@0xCD9E
              mov.w #0x3018,r6
              jsr @0x1b62
              jmp beginloop_1039
label endloop_1039
              jmp endif_1036
label false_1036
              
              //IF DATALOG_READY = 0
              mov.b #0x0,r5L
              mov.b @0xCD82,r6L
              cmp.b r5L,r6L
              beq true_1037
              jmp false_1037
label true_1037
              mov.w #0x3018,r6
              jsr @0x1e4a
              jmp endif_1037
label false_1037
              mov.w #0x3018,r6
              jsr @0x1b62
Label endif_1037
Label endif_1036
              jmp endif_1035
label false_1035
Label endif_1035
              //IF RUNNING_MAN = 0
              mov.b #0x0,r5L
              mov.b @0xCD74,r6L
              cmp.b r5L,r6L
              beq true_1040
              jmp false_1040
label true_1040
              mov.w #0x3006,r6
              jsr @0x1b62
              //IF ^TRANSMITTING = 19
              mov.b #0x13,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq true_1041
              jmp false_1041
label true_1041
              //IF IR_RANGE = 1
              mov.b #0x1,r5L
              mov.b @0xCD9F,r6L
              cmp.b r5L,r6L
              beq true_1042
              jmp false_1042
label true_1042
              mov.w #0x301d,r6
              jsr @0x1b62
              jmp endif_1042
label false_1042
              mov.w #0x301c,r6
              jsr @0x1b62
Label endif_1042
              //IF CLEARED_OPCODE = 164
              mov.b #0xA4,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1043
              jmp false_1043
label true_1043
              mov.w #0x301a,r6
              jsr @0x1b62
              jmp endif_1043
label false_1043
Label endif_1043
              jmp endif_1041
label false_1041
Label endif_1041
              jmp endif_1040
label false_1040
              mov.w #0x3007,r6
              jsr @0x1b62
              mov.w #0x301c,r6
              jsr @0x1e4a
              mov.w #0x301d,r6
              jsr @0x1e4a
Label endif_1040
              //RUNNING_MAN =NOT(RUNNING_MAN)
              mov.b @0xCD74,r6L
              not r6L
              mov.b r6L,@0xCD74
              
              //IF SV_DISPLAY_POINTER <> 0
              mov.w #0x0,r5
              mov.w @0xCD2A,r6
              cmp.w r5,r6
              bne true_1044
              jmp false_1044
label true_1044
              //IF SV_DISPLAY_TYPE = 1
              mov.b #0x1,r5L
              mov.b @0xCD8C,r6L
              cmp.b r5L,r6L
              beq true_1045
              jmp false_1045
label true_1045
              mov.b @0xCD89,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              
              //display  value in r6
              mov.w #0x3002,r5
              add.w r5,r6
              mov.w r6,@-r7
              mov.w @0xCD2A,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              mov.w r6,@-r7
              mov.w #0x3001,r6
              jsr @0x1ff2
              mov.w @r7+,r6
              adds #0x2,r7
              jmp endif_1045
label false_1045
              mov.b @0xCD89,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              
              //display  value in r6
              mov.w #0x3002,r5
              add.w r5,r6
              mov.w r6,@-r7
              mov.w @0xCD2A,r0
              mov.w @r0,r6
              mov.w r6,@-r7
              mov.w #0x3001,r6
              jsr @0x1ff2
              mov.w @r7+,r6
              adds #0x2,r7
Label endif_1045
              jmp endif_1044
label false_1044
Label endif_1044
              //IF SV_DISPLAY_UPDATE_MOTOR >= 0
              mov.b #0x0,r5L
              mov.b @0xCD54,r6L
              cmp.b r5L,r6L
              bge true_1046
              jmp false_1046
label true_1046
              //IF SV_DISPLAY_UPDATE_MOTOR <> 0
              mov.b #0x0,r5L
              mov.b @0xCD54,r6L
              cmp.b r5L,r6L
              bne true_1047
              jmp false_1047
label true_1047
              //IF SV_DISPLAY_UPDATE_MOTOR <> 1
              mov.b #0x1,r5L
              mov.b @0xCD54,r6L
              cmp.b r5L,r6L
              bne true_1048
              jmp false_1048
label true_1048
              //IF SV_DISPLAY_UPDATE_MOTOR <> 2
              mov.b #0x2,r5L
              mov.b @0xCD54,r6L
              cmp.b r5L,r6L
              bne true_1049
              jmp false_1049
label true_1049
              //default
              jmp endif_1049
label false_1049
              
              //case 2 :check motor C
              //IF ^MOTOR2_C <> 1
              mov.b #0x1,r5L
              mov.w @0xCD52,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1058
              jmp false_1058
label true_1058
              //IF ^MOTOR2_C <> 2
              mov.b #0x2,r5L
              mov.w @0xCD52,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1059
              jmp false_1059
label true_1059
              //IF ^MOTOR2_C <> 3
              mov.b #0x3,r5L
              mov.w @0xCD52,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1060
              jmp false_1060
label true_1060
              //IF ^MOTOR2_C <> 4
              mov.b #0x4,r5L
              mov.w @0xCD52,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1061
              jmp false_1061
label true_1061
              //default
              jmp endif_1061
label false_1061
              
              //case 3: motorC-command is float
              mov.w #0x3016,r6
              jsr @0x1e4a
              mov.w #0x3015,r6
              jsr @0x1e4a
Label endif_1061
              jmp endif_1060
label false_1060
              
              //case 2: motorC-command is brake
              mov.w #0x3016,r6
              jsr @0x1b62
              mov.w #0x3015,r6
              jsr @0x1b62
Label endif_1060
              jmp endif_1059
label false_1059
              
              //case 1: motorC-command is rev
              mov.w #0x3015,r6
              jsr @0x1b62
              mov.w #0x3016,r6
              jsr @0x1e4a
Label endif_1059
              jmp endif_1058
label false_1058
              
              //case 0: motorC-command is fwd
              mov.w #0x3016,r6
              jsr @0x1b62
              mov.w #0x3015,r6
              jsr @0x1e4a
Label endif_1058
Label endif_1049
              jmp endif_1048
label false_1048
              
              //case 1 :check motor B
              //IF ^MOTOR1_C <> 1
              mov.b #0x1,r5L
              mov.w @0xCD50,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1054
              jmp false_1054
label true_1054
              //IF ^MOTOR1_C <> 2
              mov.b #0x2,r5L
              mov.w @0xCD50,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1055
              jmp false_1055
label true_1055
              //IF ^MOTOR1_C <> 3
              mov.b #0x3,r5L
              mov.w @0xCD50,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1056
              jmp false_1056
label true_1056
              //IF ^MOTOR1_C <> 4
              mov.b #0x4,r5L
              mov.w @0xCD50,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1057
              jmp false_1057
label true_1057
              //default
              jmp endif_1057
label false_1057
              
              //case 3: motorB-command is float
              mov.w #0x3013,r6
              jsr @0x1e4a
              mov.w #0x3012,r6
              jsr @0x1e4a
Label endif_1057
              jmp endif_1056
label false_1056
              
              //case 2: motorB-command is brake
              mov.w #0x3013,r6
              jsr @0x1b62
              mov.w #0x3012,r6
              jsr @0x1b62
Label endif_1056
              jmp endif_1055
label false_1055
              
              //case 1: motorB-command is rev
              mov.w #0x3012,r6
              jsr @0x1b62
              mov.w #0x3013,r6
              jsr @0x1e4a
Label endif_1055
              jmp endif_1054
label false_1054
              
              //case 0: motorB-command is fwd
              mov.w #0x3013,r6
              jsr @0x1b62
              mov.w #0x3012,r6
              jsr @0x1e4a
Label endif_1054
Label endif_1048
              jmp endif_1047
label false_1047
              
              //case 0 :check motor A
              //IF ^MOTOR0_C <> 1
              mov.b #0x1,r5L
              mov.w @0xCD4E,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1050
              jmp false_1050
label true_1050
              //IF ^MOTOR0_C <> 2
              mov.b #0x2,r5L
              mov.w @0xCD4E,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1051
              jmp false_1051
label true_1051
              //IF ^MOTOR0_C <> 3
              mov.b #0x3,r5L
              mov.w @0xCD4E,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1052
              jmp false_1052
label true_1052
              //IF ^MOTOR0_C <> 4
              mov.b #0x4,r5L
              mov.w @0xCD4E,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1053
              jmp false_1053
label true_1053
              //default
              jmp endif_1053
label false_1053
              
              //case 3: motorA-command is float
              mov.w #0x3010,r6
              jsr @0x1e4a
              mov.w #0x300f,r6
              jsr @0x1e4a
Label endif_1053
              jmp endif_1052
label false_1052
              
              //case 2: motorA-command is brake
              mov.w #0x3010,r6
              jsr @0x1b62
              mov.w #0x300f,r6
              jsr @0x1b62
Label endif_1052
              jmp endif_1051
label false_1051
              
              //case 1: motorA-command is rev
              mov.w #0x300f,r6
              jsr @0x1b62
              mov.w #0x3010,r6
              jsr @0x1e4a
Label endif_1051
              jmp endif_1050
label false_1050
              
              //case 0: motorA-command is fwd
              mov.w #0x3010,r6
              jsr @0x1b62
              mov.w #0x300f,r6
              jsr @0x1e4a
Label endif_1050
Label endif_1047
              jmp endif_1046
label false_1046
Label endif_1046
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              // SV_DISPL_COUNTER_N = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD7E
              jmp endif_1031
label false_1031
Label endif_1031
              // @0XEFD2 = 0
              mov.w #0x0,r6
              mov.w r6,@0xEFD2
              jmp endif_1029
label false_1029
Label endif_1029
              //IF ^VALID = 0
              mov.b #0x0,r5L
              mov.w @0xCD44,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq true_1062
              jmp false_1062
label true_1062
              jmp endif_1062
label false_1062
              
              // ^RX_DATA_LENGTH = 0
              mov.b #0x0,r6L
              mov.w @0xCD40,r0
              mov.b r6L,@r0
              
              //ROM_CALL
              mov.w #0xEE2E,r6
              mov.w r6,@-r7
              mov.w #0x10,r6
              mov.w r6,@-r7
              mov.w #0xCD30,r6
              jsr @0x33B0
              adds #0x2,r7
              adds #0x2,r7
              // OPCODE = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              mov.b r6L,@0xCD78
              
              // CLEARED_OPCODE = OPCODE
              mov.b @0xCD78,r6L
              mov.b r6L,@0xCD79
              
              //CLEARED_OPCODE =CLEARED_OPCODE AND 247
              mov.b #0xF7,r5L
              mov.b @0xCD79,r6L
              and r5L,r6L
              mov.b r6L,@0xCD79
              
              //IF CLEARED_OPCODE = 247
              mov.b #0xF7,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1063
              jmp false_1063
label true_1063
              //RX_INDEX =RX_INDEX + 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // F7_MESSAGE = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              mov.w r6,@0xCD7A
              jmp endif_1063
label false_1063
Label endif_1063
              //IF OPCODE = 210
              mov.b #0xD2,r5L
              mov.b @0xCD78,r6L
              cmp.b r5L,r6L
              beq true_1064
              jmp false_1064
label true_1064
              //RX_INDEX =RX_INDEX + 2
              mov.w #0x2,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // D2_REMOTE_COMMAND_L_0 = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDA0
              mov.w @0xCDA0,r6
              mov.b r6L,r1H
              mov.b r6H,r6L
              mov.b r1H,r6H
              mov.w r6,@0xCDA0
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              //D2_REMOTE_COMMAND_L_0 =D2_REMOTE_COMMAND_L_0 + RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,r5
              mov.w @0xCDA0,r6
              add.w r5,r6
              mov.w r6,@0xCDA0
              
              // D2_REMOTE_COMMAND = D2_REMOTE_COMMAND_L_0
              mov.w @0xCDA0,r6
              mov.w r6,@0xCD7C
              
              // D2_WDT_ST_0 = 0
              mov.w #0x0,r6
              mov.w r6,@(0x0,r7)
              jmp endif_1064
label false_1064
Label endif_1064
              //IF CLEARED_OPCODE = 99
              mov.b #0x63,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1065
              jmp false_1065
label true_1065
              //RX_INDEX =RX_INDEX + 3
              mov.w #0x3,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // UPLOAD_BYTES = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDA2
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              // UPLOAD_ADDRESS = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDA4
              
              //UPLOAD_ADDRESS =UPLOAD_ADDRESS * 256
              mov.w #0x100,r5
              mov.w @0xCDA4,r6
              jsr @0x0130
              mov.w r6,@0xCDA4
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              //UPLOAD_ADDRESS =UPLOAD_ADDRESS + RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,r5
              mov.w @0xCDA4,r6
              add.w r5,r6
              mov.w r6,@0xCDA4
label beginloop_1066
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1066
              jmp endloop_1066
label loopdo_1066
              jmp beginloop_1066
label endloop_1066
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w @0xCDA2,r6
              mov.w r6,@-r7
              mov.w @0xCDA4,r6
              mov.w r6,@-r7
              mov.b @0xCD78,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jmp endif_1065
label false_1065
Label endif_1065
              //IF CLEARED_OPCODE = 164
              mov.b #0xA4,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1067
              jmp false_1067
label true_1067
              //RX_INDEX =RX_INDEX + 4
              mov.w #0x4,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // DATALOG_SIZE = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDA6
              
              //DATALOG_SIZE =DATALOG_SIZE * 256
              mov.w #0x100,r5
              mov.w @0xCDA6,r6
              jsr @0x0130
              mov.w r6,@0xCDA6
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              //DATALOG_SIZE =DATALOG_SIZE + RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,r5
              mov.w @0xCDA6,r6
              add.w r5,r6
              mov.w r6,@0xCDA6
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              // DATALOG_START = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDA8
              
              //DATALOG_START =DATALOG_START * 256
              mov.w #0x100,r5
              mov.w @0xCDA8,r6
              jsr @0x0130
              mov.w r6,@0xCDA8
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              //DATALOG_START =DATALOG_START + RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,r5
              mov.w @0xCDA8,r6
              add.w r5,r6
              mov.w r6,@0xCDA8
              
              //DATALOG_START =DATALOG_START * 3
              mov.w #0x3,r5
              mov.w @0xCDA8,r6
              jsr @0x0130
              mov.w r6,@0xCDA8
              
              //DATALOG_START =DATALOG_START + LOG_START_ADDRESS
              mov.w @0xCDAA,r5
              mov.w @0xCDA8,r6
              add.w r5,r6
              mov.w r6,@0xCDA8
              
              //DATALOG_SIZE =DATALOG_SIZE * 3
              mov.w #0x3,r5
              mov.w @0xCDA6,r6
              jsr @0x0130
              mov.w r6,@0xCDA6
label beginloop_1068
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1068
              jmp endloop_1068
label loopdo_1068
              jmp beginloop_1068
label endloop_1068
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w @0xCDA6,r6
              mov.w r6,@-r7
              mov.w @0xCDA8,r6
              mov.w r6,@-r7
              mov.b @0xCD78,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              // QUARTER_REFRESH_DELAY = 25
              mov.b #0x19,r6L
              mov.b r6L,@0xCD83
              jmp endif_1067
label false_1067
Label endif_1067
              //IF CLEARED_OPCODE = 18
              mov.b #0x12,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1069
              jmp false_1069
label true_1069
              //RX_INDEX =RX_INDEX + 2
              mov.w #0x2,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // POLL_INDEX = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDAC
              
              //POLL_INDEX =POLL_INDEX AND 31
              mov.w #0x1F,r5
              mov.w @0xCDAC,r6
              and r5L,r6L
              and r5H,r6H
              mov.w r6,@0xCDAC
              
              // TMP_POLL_VALUE = SYS_STANDARD[POLL_INDEX]
              mov.w @0xCDAC,r0
              shll r0L
              rotxl r0H
              mov.w #0xCC00,r1
              add.w r1,r0
              mov.w @r0,r6
              mov.w r6,@0xCDAE
              mov.w @0xCDAE,r6
              mov.b r6L,r1H
              mov.b r6H,r6L
              mov.b r1H,r6H
              mov.w r6,@0xCDAE
label beginloop_1070
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1070
              jmp endloop_1070
label loopdo_1070
              jmp beginloop_1070
label endloop_1070
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x2,r6
              mov.w r6,@-r7
              mov.w #0xCDAE,r6
              mov.w r6,@-r7
              mov.b @0xCD78,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jmp endif_1069
label false_1069
Label endif_1069
              //IF CLEARED_OPCODE = 16
              mov.b #0x10,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1071
              jmp false_1071
label true_1071
label beginloop_1072
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1072
              jmp endloop_1072
label loopdo_1072
              jmp beginloop_1072
label endloop_1072
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.b @0xCD78,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jmp endif_1071
label false_1071
Label endif_1071
              //IF CLEARED_OPCODE = 20
              mov.b #0x14,r5L
              mov.b @0xCD79,r6L
              cmp.b r5L,r6L
              beq true_1073
              jmp false_1073
label true_1073
              //RX_INDEX =RX_INDEX + 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // SETVAR_INDEX = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDB0
              
              //SETVAR_INDEX =SETVAR_INDEX AND 31
              mov.w #0x1F,r5
              mov.w @0xCDB0,r6
              and r5L,r6L
              and r5H,r6H
              mov.w r6,@0xCDB0
              
              //RX_INDEX =RX_INDEX + 3
              mov.w #0x3,r5
              mov.w @0xCD76,r6
              add.w r5,r6
              mov.w r6,@0xCD76
              
              // TMP_SETVAR_VALUE = RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              mov.w r6,@0xCDB2
              mov.w @0xCDB2,r6
              mov.b r6L,r1H
              mov.b r6H,r6L
              mov.b r1H,r6H
              mov.w r6,@0xCDB2
              
              //RX_INDEX =RX_INDEX - 1
              mov.w #0x1,r5
              mov.w @0xCD76,r6
              sub.w r5,r6
              mov.w r6,@0xCD76
              
              //TMP_SETVAR_VALUE =TMP_SETVAR_VALUE + RX_DATA[RX_INDEX]
              mov.w @0xCD76,r0
              mov.w #0xCD30,r1
              add.w r1,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              mov.w r6,r5
              mov.w @0xCDB2,r6
              add.w r5,r6
              mov.w r6,@0xCDB2
              
              // SYS_STANDARD[SETVAR_INDEX] = TMP_SETVAR_VALUE
              mov.w @0xCDB2,r6
              mov.w @0xCDB0,r0
              shll r0L
              rotxl r0H
              mov.w #0xCC00,r1
              add.w r1,r0
              mov.w r6,@r0
label beginloop_1074
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1074
              jmp endloop_1074
label loopdo_1074
              jmp beginloop_1074
label endloop_1074
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.b @0xCD78,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jmp endif_1073
label false_1073
Label endif_1073
              // RX_INDEX = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD76
              
              // OPCODE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD78
              mov.w #0xCD30,r0
              mov.w #0x0,r2
label sys_clear_memory1075
              mov.w #0xCD40,r1
              mov.w r2,@r0
              adds #0x2,r0
              sub.w r0,r1
              bne sys_clear_memory1075
Label endif_1062
              //D2_WDT_ST_0 =D2_WDT_ST_0 + 1
              mov.w #0x1,r5
              mov.w @(0x0,r7),r6
              add.w r5,r6
              mov.w r6,@(0x0,r7)
              
              //IF D2_WDT_ST_0 > 750
              mov.w #0x2EE,r5
              mov.w @(0x0,r7),r6
              cmp.w r5,r6
              bhi true_1076
              jmp false_1076
label true_1076
              // D2_REMOTE_COMMAND = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD7C
              
              // D2_WDT_ST_0 = 0
              mov.w #0x0,r6
              mov.w r6,@(0x0,r7)
              jmp endif_1076
label false_1076
Label endif_1076
              //CALL SUB watch
              jsr begin_of_sub_watch
              jmp lab_0_1008
              //free stack variable space
              mov.w #0x2,r0
              add.w r0,r7
label end_of_task_0
              //if we ever came here
              jmp end_of_task_0
              
              //sub self_test_error
label begin_of_sub_self_test_error
              //make room for stack variables
              mov.w #0x0,r0
              sub.w r0,r7
              
              //write err
              // SV_DISPLAY_POINTER = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              //Initialize array
              //TEXT
              mov.b #0x0,r6L
              mov.b r6L,@0xCC86
              mov.b #0x42,r6L
              mov.b r6L,@0xCC87
              mov.b #0x42,r6L
              mov.b r6L,@0xCC88
              mov.b #0x67,r6L
              mov.b r6L,@0xCC89
              mov.b #0x0,r6L
              mov.b r6L,@0xCC8A
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jsr sys_write_ASCII
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              MOV.W @(0X4,R7),R6
              jsr sys_type_cast_U8_to_U16
              jsr sys_type_cast_U16_to_I16
              
              //display  last digit
              mov.w #0x0,r5
              mov.w r5,@-r7
              mov.w r6,@-r7
              mov.w #0x3017,r6
              jsr @0x1ff2
              mov.w @r7+,r6
              adds #0x2,r7
label lab_100_0
              //SetSensorActive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x1946
              //Set motor_C to power 255
              mov.b #0xFF,r6L
              mov.w #0x7003,r5
              jsr sys_set_motor_power
              
              //Set motor_C to Fwd
              mov.w #0x1,r6
              mov.w #0x7003,r5
              jsr sys_set_motor
              mov.w #0x0,r5
              mov.w #0x32,r6
              jsr sys_wait_hundredth_new
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x19C4
              //Set motor_C to power 255
              mov.b #0xFF,r6L
              mov.w #0x7003,r5
              jsr sys_set_motor_power
              
              //Set motor_C to Brake
              mov.w #0x3,r6
              mov.w #0x7003,r5
              jsr sys_set_motor
              
              //ROM_CALL
              mov.w #0x4,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              jmp lab_100_0
              
              //free stack variable space
              mov.w #0x0,r0
              add.w r0,r7
              //end_of_sub_self_test_error
              rts 0
              
              //sub send_setv
label begin_of_sub_send_setv
              //make room for stack variables
              mov.w #0x0,r0
              sub.w r0,r7
              
              MOV.W @(0X4,R7),R6
              mov.w @0xCDBC,r0
              //with displacement
              MOV.B R6L,@(0x0,R0)
              MOV.W @(0X6,R7),R6
              mov.b r6L,r1H
              mov.b r6H,r6L
              mov.b r1H,r6H
              MOV.W R6,@(0X6,R7)
              MOV.W @(0X6,R7),R6
              mov.w @0xCDBC,r0
              //with displacement
              MOV.W R6,@(0x2,R0)
label beginloop_1082
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1082
              jmp endloop_1082
label loopdo_1082
              jmp beginloop_1082
label endloop_1082
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x4,r6
              mov.w r6,@-r7
              mov.w @0xCDBC,r6
              mov.w r6,@-r7
              mov.w #0xEB,r6
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x0,r5
              mov.w #0x32,r6
              jsr sys_wait_hundredth_new
              
              //free stack variable space
              mov.w #0x0,r0
              add.w r0,r7
              //end_of_sub_send_setv
              rts 0
              
              //sub sample
label begin_of_sub_sample
              
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x0,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x1,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x2,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x3,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x4,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xCDC2,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x5,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xEE48,r6
              jsr sys_type_cast_I16_to_U16
              mov.w r6,@-r7
              //push container
              mov.b #0x6,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xEE50,r6
              jsr sys_type_cast_I16_to_U16
              mov.w r6,@-r7
              //push container
              mov.b #0x7,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xEE32,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x8,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xEE38,r6
              mov.w r6,@-r7
              //push container
              mov.b #0x9,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w @0xCD6E,r6
              jsr sys_type_cast_I16_to_U16
              mov.w r6,@-r7
              //push container
              mov.b #0xA,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              //push container
              mov.w #0xA0D,r6
              mov.w r6,@-r7
              //push container
              mov.b #0xB,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB send_setv
              jsr begin_of_sub_send_setv
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x4,r0
              add.w r0,r7
              // SV_MAILOUT_L_102 = 1
              mov.b #0x1,r6L
              mov.b r6L,@0xCDC4
              
              //IF SV_MAILOUT_L_102 = 0
              mov.b #0x0,r5L
              mov.b @0xCDC4,r6L
              cmp.b r5L,r6L
              beq true_1083
label beginloop_1084
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1084
              jmp endloop_1084
label loopdo_1084
              jmp beginloop_1084
label endloop_1084
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0xCDC4,r6
              mov.w r6,@-r7
              mov.w #0x8,r6
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label true_1083
              mov.w #0x0,r5
              mov.w #0xC8,r6
              jsr sys_wait_hundredth_new
              //end_of_sub_sample
              rts 0
              
              //sub watch
label begin_of_sub_watch
              //make room for stack variables
              mov.w #0x4,r0
              sub.w r0,r7
              
              // SECONDS_ST_103 = Timer (0)
              mov.w @0xEE76,r6
              mov.w r6,@(0x0,r7)
              
              //SECONDS_ST_103 =SECONDS_ST_103 / 100
              mov.w #0x64,r5
              mov.w @(0x0,r7),r6
              jsr @0x01be
              mov.w r6,@(0x0,r7)
              
              //IF Timer (0) >= 6000
              mov.w #0x1770,r5
              mov.w @0xEE76,r6
              cmp.w r5,r6
              //  >=
              bcc true_1085
              jmp false_1085
label true_1085
              //SetTimerValue
              //disable
              orc #0x80
              
              // TIMER0 = 6,104600E+4
              mov.w #0xEE76,r6
              mov.w r6,@0xCDC6
              
              // ^TIMER0 = 0
              mov.w #0x0,r6
              mov.w @0xCDC6,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              //MIN_SINCE_START = MIN_SINCE_START + 1
              mov.w @0xCDC8,r6
              adds #0x1,r6
              mov.w r6,@0xCDC8
              jmp endif_1085
label false_1085
Label endif_1085
              // TMP_ST_103 = MIN_SINCE_START
              mov.w @0xCDC8,r6
              mov.w r6,@(0x2,r7)
              
              //TMP_ST_103 =TMP_ST_103 * 60
              mov.w #0x3C,r5
              mov.w @(0x2,r7),r6
              jsr @0x0130
              mov.w r6,@(0x2,r7)
              
              //TMP_ST_103 =TMP_ST_103 + SECONDS_ST_103
              mov.w @(0x0,r7),r5
              mov.w @(0x2,r7),r6
              add.w r5,r6
              mov.w r6,@(0x2,r7)
              
              // SEC_SINCE_START = TMP_ST_103
              mov.w @(0x2,r7),r6
              mov.w r6,@0xCDC2
              
              //free stack variable space
              mov.w #0x4,r0
              add.w r0,r7
              //end_of_sub_watch
              rts 0
              
              //sub sing_a_song_
label begin_of_sub_sing_a_song_
              //make room for stack variables
              mov.w #0x8,r0
              sub.w r0,r7
              
              mov.w r6,@(0x0,r7)
              mov.w r5,@(0x2,r7)
              mov.w r4,@(0x4,r7)
label beginloop_1086
              //IF TONES_POINTER_ST_104 < MAX_TONES_POINTER_ST_104
              mov.w @(0x4,r7),r5
              mov.w @(0x0,r7),r6
              cmp.w r5,r6
              bcs loopdo_1086
              jmp endloop_1086
label loopdo_1086
              //IF ^TONES_POINTER_ST_104 <> -1
              mov.w #0xFFFF,r5
              mov.w @(0x0,r7),r0
              mov.w @r0,r6
              cmp.w r5,r6
              bne true_1087
              jmp false_1087
label true_1087
              //ROM_CALL
              mov.w @(0x2,r7),r0
              mov.w @r0,r6
              mov.w r6,@-r7
              mov.w @(0x2,r7),r0
              mov.w @r0,r6
              jsr sys_type_cast_I16_to_U16
              mov.w r6,@-r7
              mov.w #0x1773,r6
              jsr @0x327C
              adds #0x2,r7
              adds #0x2,r7
              // SV_TONE_DURATION_ST_104 = ^DURATIONS_POINTER_ST_104
              mov.w @(0x2,r7),r0
              mov.w @r0,r6
              mov.w r6,@(0x6,r7)
              
              //SV_TONE_DURATION_ST_104 =SV_TONE_DURATION_ST_104 * 10
              mov.w #0xA,r5
              mov.w @(0x6,r7),r6
              jsr @0x0130
              mov.w r6,@(0x6,r7)
              
              //SV_TONE_DURATION_ST_104 =SV_TONE_DURATION_ST_104 / 9
              mov.w #0x9,r5
              mov.w @(0x6,r7),r6
              jsr @0x01be
              mov.w r6,@(0x6,r7)
              jmp endif_1087
label false_1087
              mov.w @(0x2,r7),r0
              mov.w @r0,r6
              jsr sys_type_cast_U16_to_U32
              jsr sys_type_cast_U32_to_I32
              jsr sys_wait_hundredth_new
Label endif_1087
              //TONES_POINTER_ST_104 =TONES_POINTER_ST_104 + 2
              mov.w #0x2,r5
              mov.w @(0x0,r7),r6
              add.w r5,r6
              mov.w r6,@(0x0,r7)
              
              //DURATIONS_POINTER_ST_104 =DURATIONS_POINTER_ST_104 + 2
              mov.w #0x2,r5
              mov.w @(0x2,r7),r6
              add.w r5,r6
              mov.w r6,@(0x2,r7)
              jmp beginloop_1086
label endloop_1086
              //free stack variable space
              mov.w #0x8,r0
              add.w r0,r7
              //end_of_sub_sing_a_song_
              rts 0
              
              //task sample_task
label begin_of_task_3
label lab_3_0
              //CALL SUB sample
              jsr begin_of_sub_sample
              jmp lab_3_0
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task 3
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 3
              mov.w #0x3,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1098
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1098
              jmp endloop_1098
label loopdo_1098
              jmp beginloop_1098
label endloop_1098
label end_of_task_3
              //if we ever came here
              jmp end_of_task_3
              
              //task heater_task
label begin_of_task_2
              
              //Start task 3
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 3
              mov.w #0x3,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 0
              mov.b #0x0,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label lab_2_0
              //IF Battery level (0) > 6950
              mov.w #0x1B26,r5
              mov.w @0xCD6E,r6
              cmp.w r5,r6
              bgt true_1095
              jmp false_1095
label true_1095
              //IF Sensor value (0) > 100
              mov.w #0x64,r5
              mov.w @0xEE48,r6
              cmp.w r5,r6
              bgt true_1097
              jmp false_1097
label true_1097
              //IF Variable  (0) >= 2
              mov.w #0x2,r5
              mov.w @0xCC00,r6
              cmp.w r5,r6
              bge true_1100
              jmp false_1100
label true_1100
              //Variable  (0) = Variable  (0) - 2
              mov.w @0xCC00,r6
              subs #0x2,r6
              mov.w r6,@0xCC00
              jmp endif_1100
label false_1100
              
              // Variable  (0) = 0
              mov.w #0x0,r6
              mov.w r6,@0xCC00
Label endif_1100
              jmp endif_1097
label false_1097
              
              //IF Variable  (0) <= 251
              mov.w #0xFB,r5
              mov.w @0xCC00,r6
              cmp.w r5,r6
              ble true_1099
              jmp false_1099
label true_1099
              //Variable  (0) = Variable  (0) + 4
              mov.w @0xCC00,r6
              adds #0x2,r6
              adds #0x2,r6
              mov.w r6,@0xCC00
              jmp endif_1099
label false_1099
              
              // Variable  (0) = 255
              mov.w #0xFF,r6
              mov.w r6,@0xCC00
Label endif_1099
Label endif_1097
              //Set motor_A to power Variable  (0)
              mov.w @0xCC00,r6
              jsr sys_type_cast_I16_to_U16
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Fwd
              mov.w #0x1,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //IF Sensor value (1) > 100
              mov.w #0x64,r5
              mov.w @0xEE50,r6
              cmp.w r5,r6
              bgt true_1102
              jmp false_1102
label true_1102
              //IF Variable  (1) >= 2
              mov.w #0x2,r5
              mov.w @0xCC02,r6
              cmp.w r5,r6
              bge true_1105
              jmp false_1105
label true_1105
              //Variable  (1) = Variable  (1) - 2
              mov.w @0xCC02,r6
              subs #0x2,r6
              mov.w r6,@0xCC02
              jmp endif_1105
label false_1105
              
              // Variable  (1) = 0
              mov.w #0x0,r6
              mov.w r6,@0xCC02
Label endif_1105
              jmp endif_1102
label false_1102
              
              //IF Variable  (1) <= 251
              mov.w #0xFB,r5
              mov.w @0xCC02,r6
              cmp.w r5,r6
              ble true_1103
              jmp false_1103
label true_1103
              //Variable  (1) = Variable  (1) + 4
              mov.w @0xCC02,r6
              adds #0x2,r6
              adds #0x2,r6
              mov.w r6,@0xCC02
              jmp endif_1103
label false_1103
              
              // Variable  (1) = 255
              mov.w #0xFF,r6
              mov.w r6,@0xCC02
Label endif_1103
Label endif_1102
              //Set motor_B to power Variable  (1)
              mov.w @0xCC02,r6
              jsr sys_type_cast_I16_to_U16
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_B to Fwd
              mov.w #0x1,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
              jmp endif_1095
label false_1095
              
              //Set motor_A to power 255
              mov.b #0xFF,r6L
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_B to power 255
              mov.b #0xFF,r6L
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Brake
              mov.w #0x3,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //Set motor_B to Brake
              mov.w #0x3,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
Label endif_1095
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              jmp lab_2_0
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task 2
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1109
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1109
              jmp endloop_1109
label loopdo_1109
              jmp beginloop_1109
label endloop_1109
label end_of_task_2
              //if we ever came here
              jmp end_of_task_2
label begin_of_task_1
              //make room for stack variables
              mov.w #0x2,r0
              sub.w r0,r7
              
              mov.b @0xFFC7,r6L
              and #0xFE,r6L
              mov.b r6L,@0xFFC7
              //Set motor_C to power 255
              mov.b #0xFF,r6L
              mov.w #0x7003,r5
              jsr sys_set_motor_power
              
              //Set motor_C to Fwd
              mov.w #0x1,r6
              mov.w #0x7003,r5
              jsr sys_set_motor
              
              //SetSensorMode
              //disable
              orc #0x80
              
              // SENSOR1 = 6,100500E+4
              mov.w #0xEE4D,r6
              mov.w r6,@0xCDB6
              
              // ^SENSOR1 = 160
              mov.b #0xA0,r6L
              mov.w @0xCDB6,r0
              mov.b r6L,@r0
              
              // SENSOR1 = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCDB6
              
              //enable
              andc #0x7F
              
              //SetSensorType
              //disable
              orc #0x80
              
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1001,r6
              jsr @0x19C4
              // SENSOR1 = 6,100400E+4
              mov.w #0xEE4C,r6
              mov.w r6,@0xCDB6
              
              // ^SENSOR1 = 2
              mov.b #0x2,r6L
              mov.w @0xCDB6,r0
              mov.b r6L,@r0
              
              // SENSOR1 = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCDB6
              
              //enable
              andc #0x7F
              
              //SetSensorMode
              //disable
              orc #0x80
              
              // SENSOR0 = 6,099700E+4
              mov.w #0xEE45,r6
              mov.w r6,@0xCDB8
              
              // ^SENSOR0 = 160
              mov.b #0xA0,r6L
              mov.w @0xCDB8,r0
              mov.b r6L,@r0
              
              // SENSOR0 = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCDB8
              
              //enable
              andc #0x7F
              
              //SetSensorType
              //disable
              orc #0x80
              
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1000,r6
              jsr @0x19C4
              // SENSOR0 = 6,099600E+4
              mov.w #0xEE44,r6
              mov.w r6,@0xCDB8
              
              // ^SENSOR0 = 2
              mov.b #0x2,r6L
              mov.w @0xCDB8,r0
              mov.b r6L,@r0
              
              // SENSOR0 = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCDB8
              
              //enable
              andc #0x7F
              
              //write LXPAK
              // SV_DISPLAY_POINTER = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              //Initialize array
              //TEXT
              mov.b #0x7A,r6L
              mov.b r6L,@0xCC86
              mov.b #0x7B,r6L
              mov.b r6L,@0xCC87
              mov.b #0x6B,r6L
              mov.b r6L,@0xCC88
              mov.b #0x7A,r6L
              mov.b r6L,@0xCC89
              mov.b #0x64,r6L
              mov.b r6L,@0xCC8A
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jsr sys_write_ASCII
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              mov.w #0x0,r5
              mov.w #0xC8,r6
              jsr sys_wait_hundredth_new
              //IF RCX Button states(0) <> 0
              mov.w #0x0,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  <>
              bne true_1077
              jmp false_1077
label true_1077
              //push container
              mov.b #0x1,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB self_test_error
              jsr begin_of_sub_self_test_error
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x2,r0
              add.w r0,r7
              jmp endif_1077
label false_1077
Label endif_1077
              //IF Sensor value (2) > 325
              mov.w #0x145,r5
              mov.w @0xEE58,r6
              cmp.w r5,r6
              bgt true_1078
              jmp false_1078
label true_1078
              //push container
              mov.b #0x2,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB self_test_error
              jsr begin_of_sub_self_test_error
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x2,r0
              add.w r0,r7
              jmp endif_1078
label false_1078
Label endif_1078
              //IF Sensor value (1) > 2000
              mov.w #0x7D0,r5
              mov.w @0xEE50,r6
              cmp.w r5,r6
              bgt true_1079
              jmp false_1079
label true_1079
              //push container
              mov.b #0x3,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB self_test_error
              jsr begin_of_sub_self_test_error
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x2,r0
              add.w r0,r7
              jmp endif_1079
label false_1079
Label endif_1079
              //IF Sensor value (0) > 2000
              mov.w #0x7D0,r5
              mov.w @0xEE48,r6
              cmp.w r5,r6
              bgt true_1080
              jmp false_1080
label true_1080
              //push container
              mov.b #0x4,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB self_test_error
              jsr begin_of_sub_self_test_error
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x2,r0
              add.w r0,r7
              jmp endif_1080
label false_1080
Label endif_1080
              //define array
              //comm_14
              mov.w #0xCDBE,r0
              mov.w #0x0,r2
label sys_clear_memory1081
              mov.w #0xCDC2,r1
              mov.w r2,@r0
              adds #0x2,r0
              sub.w r0,r1
              bne sys_clear_memory1081
              // PTR_COMM_14 = 5,267000E+4
              mov.w #0xCDBE,r6
              mov.w r6,@0xCDBC
              
              //SetTimerValue
              //disable
              orc #0x80
              
              // TIMER0 = 6,104600E+4
              mov.w #0xEE76,r6
              mov.w r6,@0xCDC6
              
              // ^TIMER0 = 0
              mov.w #0x0,r6
              mov.w @0xCDC6,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              // SEC_SINCE_START = 0
              mov.w #0x0,r6
              mov.w r6,@0xCDC2
              
              // MIN_SINCE_START = 0
              mov.w #0x0,r6
              mov.w r6,@0xCDC8
              jmp skip_tones_0
Label tones_0
              dc.w 0xFFFF
              dc.w 0x1372
              dc.w 0xFFFF
              dc.w 0xF6F
              dc.w 0xFFFF
              dc.w 0x1153
              dc.w 0xFFFF
              dc.w 0x1153
              dc.w 0xFFFF
              dc.w 0x1153
              dc.w 0xFFFF
              dc.w 0xFFFF
Label skip_tones_0
              jmp skip_durations_0
Label durations_0
              dc.w 0x1E
              dc.w 0x6
              dc.w 0x8
              dc.w 0x6
              dc.w 0x8
              dc.w 0x6
              dc.w 0x8
              dc.w 0x6
              dc.w 0x8
              dc.w 0x8
              dc.w 0x8
              dc.w 0x8
Label skip_durations_0
              //ROM_CALL
              mov.w #0x2,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
label beginloop_1088
              //IF Sensor value (2) < 175
              mov.w #0xAF,r5
              mov.w @0xEE58,r6
              cmp.w r5,r6
              blt loopdo_1088
              jmp endloop_1088
label loopdo_1088
              //IF RCX Button states(0) = 1
              mov.w #0x1,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1089
              jmp false_1089
label true_1089
              jmp fail_safe_RUN_1
              jmp endif_1089
label false_1089
              
              //IF RCX Button states(0) = 4
              mov.w #0x4,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1090
              jmp false_1090
label true_1090
              // SV_MAILOUT_L_1 = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCDCA
              
              //IF SV_MAILOUT_L_1 = 0
              mov.b #0x0,r5L
              mov.b @0xCDCA,r6L
              cmp.b r5L,r6L
              beq true_1091
label beginloop_1092
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1092
              jmp endloop_1092
label loopdo_1092
              jmp beginloop_1092
label endloop_1092
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0xCDCA,r6
              mov.w r6,@-r7
              mov.w #0x8,r6
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label true_1091
              //ROM_CALL
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              jmp endif_1090
label false_1090
Label endif_1090
Label endif_1089
              jmp beginloop_1088
label endloop_1088
label fail_safe_RUN_1
              //SetSensorActive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x1946
              //SetTimerValue
              //disable
              orc #0x80
              
              // TIMER0 = 6,104600E+4
              mov.w #0xEE76,r6
              mov.w r6,@0xCDC6
              
              // ^TIMER0 = 0
              mov.w #0x0,r6
              mov.w @0xCDC6,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              // SEC_SINCE_START = 0
              mov.w #0x0,r6
              mov.w r6,@0xCDC2
              
              // MIN_SINCE_START = 0
              mov.w #0x0,r6
              mov.w r6,@0xCDC8
              mov.w tones_0,r6
              mov.w durations_0,r5
              mov.w skip_tones_0,r4
              //CALL SUB sing_a_song_
              jsr begin_of_sub_sing_a_song_
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 5,267400E+4
              mov.w #0xCDC2,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
              
              //Start task 2
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 0
              mov.b #0x0,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label lab_1_0
              //IF RCX Button states(0) = 4
              mov.w #0x4,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1093
              jmp false_1093
label true_1093
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task sample_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 3
              mov.w #0x3,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1096
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1096
              jmp endloop_1096
label loopdo_1096
              jmp beginloop_1096
label endloop_1096
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task heater_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1106
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1106
              jmp endloop_1106
label loopdo_1106
              jmp beginloop_1106
label endloop_1106
              //Set motor_A to power 255
              mov.b #0xFF,r6L
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_B to power 255
              mov.b #0xFF,r6L
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Brake
              mov.w #0x3,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //Set motor_B to Brake
              mov.w #0x3,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
              
              // SV_MAILOUT_L_1 = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCDCA
              
              //IF SV_MAILOUT_L_1 = 0
              mov.b #0x0,r5L
              mov.b @0xCDCA,r6L
              cmp.b r5L,r6L
              beq true_1110
label beginloop_1111
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1111
              jmp endloop_1111
label loopdo_1111
              jmp beginloop_1111
label endloop_1111
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0xCDCA,r6
              mov.w r6,@-r7
              mov.w #0x8,r6
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label true_1110
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x19C4
              //ROM_CALL
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 0,000000E+0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
              
              //write LXPAK
              // SV_DISPLAY_POINTER = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD2A
              
              //Initialize array
              //TEXT
              mov.b #0x7A,r6L
              mov.b r6L,@0xCC86
              mov.b #0x7B,r6L
              mov.b r6L,@0xCC87
              mov.b #0x6B,r6L
              mov.b r6L,@0xCC88
              mov.b #0x7A,r6L
              mov.b r6L,@0xCC89
              mov.b #0x64,r6L
              mov.b r6L,@0xCC8A
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              jsr sys_write_ASCII
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              // DEBOUNCE_COUNTER_ST_1 = 0
              mov.b #0x0,r6L
              mov.w r6,@(0x0,r7)
label beginloop_1113
              //IF DEBOUNCE_COUNTER_ST_1 < 10
              mov.b #0xA,r5L
              mov.w @(0x0,r7),r6
              cmp.b r5L,r6L
              bcs fordo_1113
              jmp endloop_1113
label fordo_1113
              inc r6L
              mov.w r6,@(0x0,r7)
label beginloop_1114
              //IF RCX Button states(0) <> 1
              mov.w #0x1,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  <>
              bne loopdo_1114
              jmp endloop_1114
label loopdo_1114
              // DEBOUNCE_COUNTER_ST_1 = 0
              mov.b #0x0,r6L
              mov.w r6,@(0x0,r7)
              jmp beginloop_1114
label endloop_1114
              mov.w #0x3,r6
              jsr sys_wait_ms_new
              jmp beginloop_1113
label endloop_1113
              // DEBOUNCE_COUNTER_ST_1 = 0
              mov.b #0x0,r6L
              mov.w r6,@(0x0,r7)
label beginloop_1115
              //IF DEBOUNCE_COUNTER_ST_1 < 10
              mov.b #0xA,r5L
              mov.w @(0x0,r7),r6
              cmp.b r5L,r6L
              bcs fordo_1115
              jmp endloop_1115
label fordo_1115
              inc r6L
              mov.w r6,@(0x0,r7)
label beginloop_1116
              //IF RCX Button states(0) = 1
              mov.w #0x1,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq loopdo_1116
              jmp endloop_1116
label loopdo_1116
              // DEBOUNCE_COUNTER_ST_1 = 0
              mov.b #0x0,r6L
              mov.w r6,@(0x0,r7)
              jmp beginloop_1116
label endloop_1116
              mov.w #0x3,r6
              jsr sys_wait_ms_new
              jmp beginloop_1115
label endloop_1115
              //SetSensorActive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x1946
              mov.w tones_0,r6
              mov.w durations_0,r5
              mov.w skip_tones_0,r4
              //CALL SUB sing_a_song_
              jsr begin_of_sub_sing_a_song_
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS + 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              add.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //start task sample_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 3
              mov.w #0x3,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 0
              mov.b #0x0,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS + 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              add.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //start task heater_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 0
              mov.b #0x0,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              // SV_DISPLAY_TYPE = 2
              mov.b #0x2,r6L
              mov.b r6L,@0xCD8C
              
              // SV_DISPLAY_POINTER = 5,267400E+4
              mov.w #0xCDC2,r6
              mov.w r6,@0xCD2A
              
              // SV_DISPLAY_SCALE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD89
              jmp endif_1093
label false_1093
              
              //IF RCX Button states(0) = 5
              mov.w #0x5,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1094
              jmp false_1094
label true_1094
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task sample_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 3
              mov.w #0x3,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1101
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1101
              jmp endloop_1101
label loopdo_1101
              jmp beginloop_1101
label endloop_1101
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x19C4
              //ROM_CALL
              mov.w #0x4,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              mov.w #0x0,r5
              mov.w #0x190,r6
              jsr sys_wait_hundredth_new
              // I = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCDCE
label beginloop_1104
              //IF I < 5
              mov.b #0x5,r5L
              mov.b @0xCDCE,r6L
              cmp.b r5L,r6L
              bcs fordo_1104
              jmp endloop_1104
label fordo_1104
              inc r6L
              mov.b r6L,@0xCDCE
              
              // SV_MAILOUT_L_1 = 57
              mov.b #0x39,r6L
              mov.b r6L,@0xCDCA
              
              //IF SV_MAILOUT_L_1 = 0
              mov.b #0x0,r5L
              mov.b @0xCDCA,r6L
              cmp.b r5L,r6L
              beq true_1107
label beginloop_1108
              //IF ^TRANSMITTING <> 79
              mov.b #0x4F,r5L
              mov.w @0xCD42,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne loopdo_1108
              jmp endloop_1108
label loopdo_1108
              jmp beginloop_1108
label endloop_1108
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0xCDCA,r6
              mov.w r6,@-r7
              mov.w #0x8,r6
              mov.w r6,@-r7
              mov.w #0x1776,r6
              jsr @0x343E
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label true_1107
              mov.w #0x0,r5
              mov.w #0xC8,r6
              jsr sys_wait_hundredth_new
              //ROM_CALL
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              jmp beginloop_1104
label endloop_1104
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0x4004,r6
              jsr @0x299A
              adds #0x2,r7
              mov.w #0x0,r5
              mov.w #0x96,r6
              jsr sys_wait_hundredth_new
              mov.w #0x0,r5
              mov.w #0x64,r6
              jsr sys_wait_hundredth_new
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task heater_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1112
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1112
              jmp endloop_1112
label loopdo_1112
              jmp beginloop_1112
label endloop_1112
              //Set motor_A to power 255
              mov.b #0xFF,r6L
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_B to power 255
              mov.b #0xFF,r6L
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Brake
              mov.w #0x3,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //Set motor_B to Brake
              mov.w #0x3,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
              
              //push container
              mov.b #0x5,r6L
              mov.b #0x0,r6H
              mov.w r6,@-r7
              //push container
              mov.w #0x0,r6
              mov.w r6,@-r7
              //CALL SUB self_test_error
              jsr begin_of_sub_self_test_error
              //pop container
              mov.w @r7+,r6
              mov.w r6,@0xCDBA
              mov.w #0x2,r0
              add.w r0,r7
              jmp endif_1094
label false_1094
Label endif_1094
Label endif_1093
              //IF SEC_SINCE_START > 7200
              mov.w #0x1C20,r5
              mov.w @0xCDC2,r6
              cmp.w r5,r6
              bhi true_1117
              jmp false_1117
label true_1117
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task heater_task
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 2
              mov.w #0x2,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1118
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1118
              jmp endloop_1118
label loopdo_1118
              jmp beginloop_1118
label endloop_1118
              //Set motor_A to power 255
              mov.b #0xFF,r6L
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_B to power 255
              mov.b #0xFF,r6L
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Brake
              mov.w #0x3,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //Set motor_B to Brake
              mov.w #0x3,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
              jmp endif_1117
label false_1117
Label endif_1117
              jmp lab_1_0
              //disable
              orc #0x80
              
              //NUMBER_OF_NON_BGH_TASKS =NUMBER_OF_NON_BGH_TASKS - 1
              mov.w #0x1,r5
              mov.w @0xCDCC,r6
              sub.w r5,r6
              mov.w r6,@0xCDCC
              jsr sys_recalculate_sys_ticks
              //stop task 1
              //disable
              orc #0x80
              
              // SV_TASK_INDEX = 1
              mov.w #0x1,r6
              mov.w r6,@0xCD6A
              
              // TASK_STATE[SV_TASK_INDEX] = 2
              mov.b #0x2,r6L
              mov.w @0xCD6A,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
label beginloop_1119
              //IF TASK_STATE[SV_TASK] = 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq loopdo_1119
              jmp endloop_1119
label loopdo_1119
              jmp beginloop_1119
label endloop_1119
              //free stack variable space
              mov.w #0x2,r0
              add.w r0,r7
label end_of_task_1
              //if we ever came here
              jmp end_of_task_1
label init_RCX
              //Initialize array
              //sa_waveforms
              mov.w #0x0,r6
              mov.w r6,@0xCC8C
              mov.w #0x1,r6
              mov.w r6,@0xCC8E
              mov.w #0x1,r6
              mov.w r6,@0xCC90
              mov.w #0x1,r6
              mov.w r6,@0xCC92
              mov.w #0x20,r6
              mov.w r6,@0xCC94
              mov.w #0x401,r6
              mov.w r6,@0xCC96
              mov.w #0x101,r6
              mov.w r6,@0xCC98
              mov.w #0x101,r6
              mov.w r6,@0xCC9A
              mov.w #0x204,r6
              mov.w r6,@0xCC9C
              mov.w #0x1041,r6
              mov.w r6,@0xCC9E
              mov.w #0x410,r6
              mov.w r6,@0xCCA0
              mov.w #0x8421,r6
              mov.w r6,@0xCCA2
              mov.w #0x844,r6
              mov.w r6,@0xCCA4
              mov.w #0x2211,r6
              mov.w r6,@0xCCA6
              mov.w #0x1111,r6
              mov.w r6,@0xCCA8
              mov.w #0x1111,r6
              mov.w r6,@0xCCAA
              mov.w #0x1122,r6
              mov.w r6,@0xCCAC
              mov.w #0x4489,r6
              mov.w r6,@0xCCAE
              mov.w #0x2491,r6
              mov.w r6,@0xCCB0
              mov.w #0x2489,r6
              mov.w r6,@0xCCB2
              mov.w #0x2492,r6
              mov.w r6,@0xCCB4
              mov.w #0x5249,r6
              mov.w r6,@0xCCB6
              mov.w #0x24A5,r6
              mov.w r6,@0xCCB8
              mov.w #0x2525,r6
              mov.w r6,@0xCCBA
              mov.w #0x24A9,r6
              mov.w r6,@0xCCBC
              mov.w #0x4A95,r6
              mov.w r6,@0xCCBE
              mov.w #0x2A54,r6
              mov.w r6,@0xCCC0
              mov.w #0xAA55,r6
              mov.w r6,@0xCCC2
              mov.w #0x554A,r6
              mov.w r6,@0xCCC4
              mov.w #0xA955,r6
              mov.w r6,@0xCCC6
              mov.w #0x5555,r6
              mov.w r6,@0xCCC8
              mov.w #0x5555,r6
              mov.w r6,@0xCCCA
              mov.w #0xAAB5,r6
              mov.w r6,@0xCCCC
              mov.w #0x56AA,r6
              mov.w r6,@0xCCCE
              mov.w #0xD5AB,r6
              mov.w r6,@0xCCD0
              mov.w #0x55AA,r6
              mov.w r6,@0xCCD2
              mov.w #0xDB56,r6
              mov.w r6,@0xCCD4
              mov.w #0xB56A,r6
              mov.w r6,@0xCCD6
              mov.w #0xDB5A,r6
              mov.w r6,@0xCCD8
              mov.w #0xDADA,r6
              mov.w r6,@0xCCDA
              mov.w #0xDB6D,r6
              mov.w r6,@0xCCDC
              mov.w #0xADB6,r6
              mov.w r6,@0xCCDE
              mov.w #0xDB6E,r6
              mov.w r6,@0xCCE0
              mov.w #0xDB76,r6
              mov.w r6,@0xCCE2
              mov.w #0xEEDD,r6
              mov.w r6,@0xCCE4
              mov.w #0xBB76,r6
              mov.w r6,@0xCCE6
              mov.w #0xEEEE,r6
              mov.w r6,@0xCCE8
              mov.w #0xEEEE,r6
              mov.w r6,@0xCCEA
              mov.w #0xF7BB,r6
              mov.w r6,@0xCCEC
              mov.w #0xDDEE,r6
              mov.w r6,@0xCCEE
              mov.w #0xFBEF,r6
              mov.w r6,@0xCCF0
              mov.w #0x7BDE,r6
              mov.w r6,@0xCCF2
              mov.w #0xFDFB,r6
              mov.w r6,@0xCCF4
              mov.w #0xEFBE,r6
              mov.w r6,@0xCCF6
              mov.w #0xFEFE,r6
              mov.w r6,@0xCCF8
              mov.w #0xFEFE,r6
              mov.w r6,@0xCCFA
              mov.w #0xFFDF,r6
              mov.w r6,@0xCCFC
              mov.w #0xFBFE,r6
              mov.w r6,@0xCCFE
              mov.w #0xFFFE,r6
              mov.w r6,@0xCD00
              mov.w #0xFFFE,r6
              mov.w r6,@0xCD02
              mov.w #0xFFFF,r6
              mov.w r6,@0xCD04
              mov.w #0xFFFE,r6
              mov.w r6,@0xCD06
              mov.w #0xFFFF,r6
              mov.w r6,@0xCD08
              mov.w #0xFFFF,r6
              mov.w r6,@0xCD0A
              //WAIT 200ms
              mov.w #0xC8,r1
label L_sys_1120
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1121
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1121
              mov.w r1,r1
              bne L_sys_1120
              //Initialize RCX
              //disable
              orc #0x80
              
              //Initialize timers
              //ROM_CALL
              mov.w #0xEE64,r6
              mov.w r6,@-r7
              mov.w #0xEE74,r6
              jsr @0x3B9A
              adds #0x2,r7
              //Initialize sensors
              //ROM_CALL
              jsr @0x1498
              //SetSensorType
              //disable
              orc #0x80
              
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1000,r6
              jsr @0x19C4
              // SENSOR0 = 6,099600E+4
              mov.w #0xEE44,r6
              mov.w r6,@0xCDB8
              
              // ^SENSOR0 = 0
              mov.b #0x0,r6L
              mov.w @0xCDB8,r0
              mov.b r6L,@r0
              
              // SENSOR0 = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCDB8
              
              //enable
              andc #0x7F
              
              //SetSensorMode
              //disable
              orc #0x80
              
              // SENSOR0 = 6,099700E+4
              mov.w #0xEE45,r6
              mov.w r6,@0xCDB8
              
              // ^SENSOR0 = 0
              mov.b #0x0,r6L
              mov.w @0xCDB8,r0
              mov.b r6L,@r0
              
              // SENSOR0 = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCDB8
              
              //enable
              andc #0x7F
              
              //SetSensorValue
              //disable
              orc #0x80
              
              // SENSOR0 = 6,100000E+4
              mov.w #0xEE48,r6
              mov.w r6,@0xCDB8
              
              // ^SENSOR0 = 0
              mov.w #0x0,r6
              mov.w @0xCDB8,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              //SetSensorType
              //disable
              orc #0x80
              
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1001,r6
              jsr @0x19C4
              // SENSOR1 = 6,100400E+4
              mov.w #0xEE4C,r6
              mov.w r6,@0xCDB6
              
              // ^SENSOR1 = 0
              mov.b #0x0,r6L
              mov.w @0xCDB6,r0
              mov.b r6L,@r0
              
              // SENSOR1 = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCDB6
              
              //enable
              andc #0x7F
              
              //SetSensorMode
              //disable
              orc #0x80
              
              // SENSOR1 = 6,100500E+4
              mov.w #0xEE4D,r6
              mov.w r6,@0xCDB6
              
              // ^SENSOR1 = 0
              mov.b #0x0,r6L
              mov.w @0xCDB6,r0
              mov.b r6L,@r0
              
              // SENSOR1 = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCDB6
              
              //enable
              andc #0x7F
              
              //SetSensorValue
              //disable
              orc #0x80
              
              // SENSOR1 = 6,100800E+4
              mov.w #0xEE50,r6
              mov.w r6,@0xCDB6
              
              // ^SENSOR1 = 0
              mov.w #0x0,r6
              mov.w @0xCDB6,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              //SetSensorType
              //disable
              orc #0x80
              
              //SetSensorPassive
              //ROM_CALL
              mov.w #0x1002,r6
              jsr @0x19C4
              // SENSOR2 = 6,101200E+4
              mov.w #0xEE54,r6
              mov.w r6,@0xCDD0
              
              // ^SENSOR2 = 0
              mov.b #0x0,r6L
              mov.w @0xCDD0,r0
              mov.b r6L,@r0
              
              // SENSOR2 = 6,101600E+4
              mov.w #0xEE58,r6
              mov.w r6,@0xCDD0
              
              //enable
              andc #0x7F
              
              //SetSensorMode
              //disable
              orc #0x80
              
              // SENSOR2 = 6,101300E+4
              mov.w #0xEE55,r6
              mov.w r6,@0xCDD0
              
              // ^SENSOR2 = 0
              mov.b #0x0,r6L
              mov.w @0xCDD0,r0
              mov.b r6L,@r0
              
              // SENSOR2 = 6,101600E+4
              mov.w #0xEE58,r6
              mov.w r6,@0xCDD0
              
              //enable
              andc #0x7F
              
              //SetSensorValue
              //disable
              orc #0x80
              
              // SENSOR2 = 6,101600E+4
              mov.w #0xEE58,r6
              mov.w r6,@0xCDD0
              
              // ^SENSOR2 = 0
              mov.w #0x0,r6
              mov.w @0xCDD0,r0
              mov.w r6,@r0
              
              //enable
              andc #0x7F
              
              //Set motor_A to power 255
              mov.b #0xFF,r6L
              mov.w #0x7001,r5
              jsr sys_set_motor_power
              
              //Set motor_B to power 255
              mov.b #0xFF,r6L
              mov.w #0x7002,r5
              jsr sys_set_motor_power
              
              //Set motor_C to power 255
              mov.b #0xFF,r6L
              mov.w #0x7003,r5
              jsr sys_set_motor_power
              
              //Set motor_A to Float
              mov.w #0x4,r6
              mov.w #0x7001,r5
              jsr sys_set_motor
              
              //Set motor_B to Float
              mov.w #0x4,r6
              mov.w #0x7002,r5
              jsr sys_set_motor
              
              //Set motor_C to Float
              mov.w #0x4,r6
              mov.w #0x7003,r5
              jsr sys_set_motor
              
              //Initialize buttons
              //ROM_CALL
              jsr @0x1ABA
              //Initialize power
              //ROM_CALL
              jsr @0x2964
              //Initialize timers
              //ROM_CALL
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0x1,r6
              mov.w r6,@-r7
              mov.w #0xEE74,r6
              mov.w r6,@-r7
              mov.w #0xEE64,r6
              jsr @0x30D0
              adds #0x2,r7
              adds #0x2,r7
              adds #0x2,r7
              //ROM_CALL
              mov.w #0x1770,r6
              jsr @0x3266
              // IR_RANGE = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCD9F
              
              //Initialize port6,<3>
              //ROM_CALL
              jsr @0x3692
              //disable
              orc #0x80
              mov.b #0x3,r6L
              mov.b r6L,@0xee5B
              mov.b #0x1E,r6L
              mov.b r6L,@0xee53
              mov.b #0x8,r6L
              mov.b r6L,@0xFFC8
              mov.b #0x3,r6L
              mov.b r6L,@0xFFC9
              mov.b @0xFFC3,r6L
              and #0xFE,r6L
              mov.b r6L,@0xFFC3
              mov.w sys_fast_OCIA_handler, r6
              mov.w r6,@0xfda2
              // SV_POINTER1 = 6,542800E+4
              mov.w #0xFF94,r6
              mov.w r6,@0xCDD2
              
              // ^SV_POINTER1 = 500
              mov.w #0x1F4,r6
              mov.w @0xCDD2,r0
              mov.w r6,@r0
              
              // SV_POINTER1 = 6,542600E+4
              mov.w #0xFF92,r6
              mov.w r6,@0xCDD2
              
              // ^SV_POINTER1 = 0
              mov.w #0x0,r6
              mov.w @0xCDD2,r0
              mov.w r6,@r0
              
              //disable
              orc #0x80
              
              //Initialize array
              //task_state
              mov.b #0x0,r6L
              mov.b r6L,@0xCD0C
              mov.b #0x2,r6L
              mov.b r6L,@0xCD0D
              mov.b #0x2,r6L
              mov.b r6L,@0xCD0E
              mov.b #0x2,r6L
              mov.b r6L,@0xCD0F
              //define array
              //stack_pointer
              //Initialize array
              //stack_pointer
              mov.w #0xCBFE,r6
              mov.w r6,@0xCDD4
              mov.w #0xCB8E,r6
              mov.w r6,@0xCDD6
              mov.w #0xCB1E,r6
              mov.w r6,@0xCDD8
              mov.w #0xCAAE,r6
              mov.w r6,@0xCDDA
              // SV_NUMBER_OF_TASKS_ = 4
              mov.w #0x4,r6
              mov.w r6,@0xCDDC
              
              // SV_TASK = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD8E
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w r7,@r0
              
              //sp=stack_pointer base
              //(only for tasks>0)
              // SV_TASK = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD8E
label beginloop_1122
              //IF SV_TASK < 3
              mov.w #0x3,r5
              mov.w @0xCD8E,r6
              cmp.w r5,r6
              bcs fordo_1122
              jmp endloop_1122
label fordo_1122
              adds #0x1,r6
              mov.w r6,@0xCD8E
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w @r0,r7
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCD16,r1
              add.w r1,r0
              mov.w @r0,r6
              
              //push task address
              mov.w r6,@-r7
              mov.w #0x0,r6
              mov.w r6,@-r7
              mov.w r6,@-r7
              //push OCIA dispatch address
              mov.w #0x4d4,r6
              mov.w r6,@-r7
              mov.w #0xc,r1
              sub.w r1,r7
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w r7,@r0
              jmp beginloop_1122
label endloop_1122
              //restore sp
              // SV_TASK = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD8E
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w @r0,r7
              
              //enable
              andc #0x7F
              rts 0
              //fast OCIA-handler
              //MULTI-TASKING VERSION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              //must be initiated correctly
label sys_fast_OCIA_handler
              //push context
              mov.w r0,@-r7
              mov.w r1,@-r7
              mov.w r2,@-r7
              mov.w r3,@-r7
              mov.w r4,@-r7
              mov.w r5,@-r7
              //clear output compare flag (bit 3 of ff91)
              mov.b @0xff91,r6L
              and #0xf7,r6L
              mov.b r6L,@0xff91
              //set port 6 bits 0..2 to low for a short moment
              //if ms_counter_0 (efcf) mod sensor_power_time(ee5B) =0
              mov.b @0xefcf,r6L
              mov.b #0x0,r6H
              mov.b @0xee5B,r5L
              divxu r5L,r6
              mov.b r6H,r6L
              //verify remainder
              bne sys_skip_portpassive
              mov.b @0xffbb,r6L
              and #0xf8,r6L
              mov.b r6L,@0xffbb
label sys_skip_portpassive
              
              //update motor output (f000) from motorstatus (ee5C)
              mov.b @0xee5C,r6L
              mov.b r6L,@0xf000
              
              //compute new states
              mov.b #0x0,r6L
              mov.b r6L,@0xee5c
              
              //rotate waveform A
              mov.w @0xee34,r5
              mov.w @0xee36,r6
              bld #0,r6L
              jsr sys_ROTXR32
              bcc sys_skip_motorA_update
              //get motor_commands
              mov.b @0xefca,r2L
              //Amask
              and #0xc0,r2L
              mov.b @0xee5C,r2H
              or r2H,r2L
              mov.b r2L,@0xee5c
label sys_skip_motorA_update
              mov.w r5,@0xee34
              mov.w r6,@0xee36
              
              //rotate waveform B
              mov.w @0xee3a,r5
              mov.w @0xee3c,r6
              bld #0,r6L
              jsr sys_ROTXR32
              bcc sys_skip_motorB_update
              //get motor_commands
              mov.b @0xefca,r2L
              //Bmask
              and #0x0c,r2L
              mov.b @0xee5C,r2H
              or r2H,r2L
              mov.b r2L,@0xee5c
label sys_skip_motorB_update
              mov.w r5,@0xee3a
              mov.w r6,@0xee3c
              
              //rotate waveform C
              mov.w @0xee40,r5
              mov.w @0xee42,r6
              bld #0,r6L
              jsr sys_ROTXR32
              bcc sys_skip_motorC_update
              //get motor_commands
              mov.b @0xefca,r2L
              //Cmask
              and #0x03,r2L
              mov.b @0xee5C,r2H
              or r2H,r2L
              mov.b r2L,@0xee5c
label sys_skip_motorC_update
              mov.w r5,@0xee40
              mov.w r6,@0xee42
              
              //if ms_counter_0 mod sensor power-time (ee5B) = 0
              //then start a/d conversion
              //with enabling a/d interrupt
              mov.b @0xefcf,r6L
              mov.b #0x0,r6H
              mov.b @0xee5B,r5L
              divxu r5L,r6
              mov.b r6H,r6L
              bne sys_skip_enable_a/d
              mov.b @0xffe8,r6L
              or #0x60,r6L
              mov.b r6L,@0xffe8
label sys_skip_enable_a/d
              
              //if ++ms_counter_0 > ms_counter_reset_time (ee53) then
              //ms_counter_0 reset
              mov.b @0xefcf,r6L
              inc r6L
              mov.b r6L,@0xefcf
              mov.b @0xee53,r6H
              cmp.b r6H,r6L
              bls sys_skip_ms_counter_0_reset
              mov.b #0x1,r6L
              mov.b r6L,@0xefcf
label sys_skip_ms_counter_0_reset
              
              //++ms_counter_2       <-------------------------
              mov.w @0xefd2,r6
              adds #0x1,r6
              mov.w r6,@0xefd2
              
              //if ++ms_counter_1 >= 10 then
              //reset ms_counter_1 and increment timers
              //we have three 1/100 sec timers
              mov.b @0xefd0,r6L
              inc r6L
              mov.b r6L,@0xefd0
              cmp.b #0xa,r6L
              bcs sys_skip_timer_update
              
              //reset ms_counter_1
              mov.b #0x0,r6L
              mov.b r6L,@0xefd0
              
              //update cs_timer0
              mov.w @0xee76,r6
              adds #0x1,r6
              mov.w r6, @0xee76
              
              //update cs_timer1
              mov.w @0xee78,r6
              adds #0x1,r6
              mov.w r6, @0xee78
              
              //update cs_timer2
              mov.w @0xee7a,r6
              adds #0x1,r6
              mov.w r6, @0xee7a
              
              //update cs_timer3
              mov.w @0xee7c,r6
              adds #0x1,r6
              mov.w r6, @0xee7c
label sys_skip_timer_update
              //IF TASK_STATE[SV_TASK] <> 1
              mov.b #0x1,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1124
              jmp false_1124
label true_1124
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w r7,@r0
              
              //IF BACK_GROUND = 0
              mov.b #0x0,r5L
              mov.b @0xCDDE,r6L
              cmp.b r5L,r6L
              beq true_1125
              jmp false_1125
label true_1125
              // SV_TMP_TASK = SV_TASK
              mov.w @0xCD8E,r6
              mov.w r6,@0xCDE0
              
              // SV_TASK = 0
              mov.w #0x0,r6
              mov.w r6,@0xCD8E
              jmp endif_1125
label false_1125
              
              // SV_TASK = SV_TMP_TASK
              mov.w @0xCDE0,r6
              mov.w r6,@0xCD8E
              
              // SV_SECURITY = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCDE2
label lab_0_1123
              //SV_SECURITY =SV_SECURITY + 1
              mov.b #0x1,r5L
              mov.b @0xCDE2,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCDE2
              
              //SV_TASK =SV_TASK + 1
              mov.w #0x1,r5
              mov.w @0xCD8E,r6
              add.w r5,r6
              mov.w r6,@0xCD8E
              
              //IF SV_TASK < 4
              mov.w #0x4,r5
              mov.w @0xCD8E,r6
              cmp.w r5,r6
              bcs true_1126
              // SV_TASK = 1
              mov.w #0x1,r6
              mov.w r6,@0xCD8E
label true_1126
              //IF SV_SECURITY < 255
              mov.b #0xFF,r5L
              mov.b @0xCDE2,r6L
              cmp.b r5L,r6L
              bcs true_1127
              //disable
              orc #0x80
              jsr sys_IRQ0_run_handler
label true_1127
              //IF TASK_STATE[SV_TASK] <> 2
              mov.b #0x2,r5L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              bne true_1128
              jmp lab_0_1123
label true_1128
Label endif_1125
              //BACK_GROUND =BACK_GROUND + 1
              mov.b #0x1,r5L
              mov.b @0xCDDE,r6L
              add.b r5L,r6L
              mov.b r6L,@0xCDDE
              
              //IF BACK_GROUND <= 1
              mov.b #0x1,r5L
              mov.b @0xCDDE,r6L
              cmp.b r5L,r6L
              bls true_1129
              // BACK_GROUND = 0
              mov.b #0x0,r6L
              mov.b r6L,@0xCDDE
label true_1129
              mov.w @0xCD8E,r0
              shll r0L
              rotxl r0H
              mov.w #0xCDD4,r1
              add.w r1,r0
              mov.w @r0,r7
              jmp endif_1124
label false_1124
Label endif_1124
              //pop context
              mov.w @r7+,r5
              mov.w @r7+,r4
              mov.w @r7+,r3
              mov.w @r7+,r2
              mov.w @r7+,r1
              mov.w @r7+,r0
              rts 0
label sys_IRQ0_run_handler
              //push context
              mov.w r0,@-r7
              mov.w r1,@-r7
              mov.w r2,@-r7
              mov.w r3,@-r7
              mov.w r4,@-r7
              mov.w r5,@-r7
              //SV_RUNNING =NOT(SV_RUNNING)
              mov.b @0xCD2C,r6L
              not r6L
              mov.b r6L,@0xCD2C
              
              //IF SV_RUNNING <> 0
              mov.b #0x0,r5L
              mov.b @0xCD2C,r6L
              cmp.b r5L,r6L
              bne true_1130
              //Shut down RCX
              //disable
              orc #0x80
              
              //ROM_CALL
              jsr @0x36AA
              //ROM_CALL
              jsr @0x3636
              //ROM_CALL
              jsr @0x27F4
              //ROM_CALL
              jsr @0x1A22
              //ROM_CALL
              jsr @0x3ED4
              //WAIT 250ms
              mov.w #0xFA,r1
label L_sys_1131
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1132
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1132
              mov.w r1,r1
              bne L_sys_1131
              jmp begin_of_task_0
label true_1130
              //pop context
              mov.w @r7+,r5
              mov.w @r7+,r4
              mov.w @r7+,r3
              mov.w @r7+,r2
              mov.w @r7+,r1
              mov.w @r7+,r0
              rts 0
label sys_check_on_off
              //ROM_CALL
              mov.w #0xEE30,r6
              mov.w r6,@-r7
              mov.w #0x4000,r6
              jsr @0x29F2
              adds #0x2,r7
              // @0XEE2C = @0XEE30
              mov.w @0xEE30,r6
              mov.w r6,@0xEE2C
              
              //ROM_CALL
              mov.w #0xEE2A,r6
              mov.w r6,@-r7
              mov.w #0x3000,r6
              jsr @0x1FB6
              adds #0x2,r7
              mov.w @0xEE2C,r6
              shlr r6L
              xor #0x1,r6L
              shll r6L
              shll r6L
              shll r6L
              mov.w @0xEE2A,r4
              or r4L,r6L
              mov.w r6,@0xEE2C
              
              // @0XEE28 = @0XEE2C
              mov.w @0xEE2C,r6
              mov.w r6,@0xEE28
label sys_disable_enable_entry_point
              nop 0
              //IF @0XEE30 = 0
              mov.w #0x0,r5
              mov.w @0xEE30,r6
              cmp.w r5,r6
              //  =
              beq true_1133
              jmp false_1133
label true_1133
              //IF @0XEE28 = 12
              mov.w #0xC,r5
              mov.w @0xEE28,r6
              cmp.w r5,r6
              //  =
              beq true_1134
              jmp false_1134
label true_1134
label sys_disable_enable_reboot_entry_point
              nop 0
              //WAIT 120ms
              mov.w #0x78,r1
label L_sys_1135
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1136
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1136
              mov.w r1,r1
              bne L_sys_1135
              //Shut down RCX
              //disable
              orc #0x80
              
              //ROM_CALL
              jsr @0x36AA
              //ROM_CALL
              jsr @0x3636
              //ROM_CALL
              jsr @0x27F4
              //ROM_CALL
              jsr @0x1A22
              //ROM_CALL
              jsr @0x3ED4
              //disable
              orc #0x80
              
              //WAIT 500ms
              mov.w #0x1F4,r1
label L_sys_1137
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1138
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1138
              mov.w r1,r1
              bne L_sys_1137
              //reset RCX
              jsr @@0x0
              jmp endif_1134
label false_1134
              
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 1
              mov.b #0x1,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              //ROM_CALL
              jsr @0x27AC
              //ROM_CALL
              jsr @0x27C8
              //disable
              orc #0x80
              
              // TASK_STATE[SV_TASK] = 0
              mov.b #0x0,r6L
              mov.w @0xCD8E,r0
              mov.w #0xCD0C,r1
              add.w r1,r0
              mov.b r6L,@r0
              
              //enable
              andc #0x7F
              
              // @0XFD8E = 255
              mov.w #0xFF,r6
              mov.w r6,@0xFD8E
              
              //WAIT 50ms
              mov.w #0x32,r1
label L_sys_1139
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1140
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1140
              mov.w r1,r1
              bne L_sys_1139
              //Shut down RCX
              //disable
              orc #0x80
              
              //ROM_CALL
              jsr @0x36AA
              //ROM_CALL
              jsr @0x3636
              //ROM_CALL
              jsr @0x27F4
              //ROM_CALL
              jsr @0x1A22
              //ROM_CALL
              jsr @0x3ED4
              //WAIT 120ms
              mov.w #0x78,r1
label L_sys_1141
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1142
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1142
              mov.w r1,r1
              bne L_sys_1141
              //RCX power_off
              mov.w #0xff7e,r7
              mov.w #0x36ba,r6
              mov.w r6,@0xfda2
              //ROM_CALL
              jsr @0x2964
              //WAIT 100ms
              mov.w #0x64,r1
label L_sys_1143
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1144
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1144
              mov.w r1,r1
              bne L_sys_1143
              //enable
              andc #0x7F
              
              //ROM_CALL
              jsr @0x2A62
              // @0XEE30 = 1
              mov.w #0x1,r6
              mov.w r6,@0xEE30
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              //enable
              andc #0x7F
              
              // @0XEE30 = 1
              mov.w #0x1,r6
              mov.w r6,@0xEE30
              
              //when coming back from sleep
              //restart after H8 recovery-time
              //Initialize timers
              //ROM_CALL
              mov.w #0xEE64,r6
              mov.w r6,@-r7
              mov.w #0xEE74,r6
              jsr @0x3B9A
              adds #0x2,r7
              //ROM_CALL
              mov.w #0xA,r6
              mov.w r6,@-r7
              mov.w #0x7D0,r6
              mov.w r6,@-r7
              mov.w #0x1773,r6
              jsr @0x327C
              adds #0x2,r7
              adds #0x2,r7
              //WAIT 110ms
              mov.w #0x6E,r1
label L_sys_1145
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1146
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1146
              mov.w r1,r1
              bne L_sys_1145
              //ROM_CALL
              mov.w #0xA,r6
              mov.w r6,@-r7
              mov.w #0x546,r6
              mov.w r6,@-r7
              mov.w #0x1773,r6
              jsr @0x327C
              adds #0x2,r7
              adds #0x2,r7
              //WAIT 110ms
              mov.w #0x6E,r1
label L_sys_1147
              subs #0x1,r1
              mov.w #0X294,r2
label L_sys_1148
              subs #0x1,r2
              mov.w r2,r2
              bne L_sys_1148
              mov.w r1,r1
              bne L_sys_1147
              jmp begin_of_task_0
Label endif_1134
              jmp endif_1133
label false_1133
Label endif_1133
              rts 0
label init_task_address_list
              mov.w begin_of_task_0,r6
              mov.w r6,@0xCD16
              mov.w begin_of_task_1,r6
              mov.w r6,@0xCD18
              mov.w begin_of_task_2,r6
              mov.w r6,@0xCD1A
              mov.w begin_of_task_3,r6
              mov.w r6,@0xCD1C
              mov.w 0x0,r6
              mov.w r6,@0xCD1E
              mov.w 0x0,r6
              mov.w r6,@0xCD20
              mov.w 0x0,r6
              mov.w r6,@0xCD22
              mov.w 0x0,r6
              mov.w r6,@0xCD24
              mov.w 0x0,r6
              mov.w r6,@0xCD26
              mov.w 0x0,r6
              mov.w r6,@0xCD28
              rts 0
label sys_init_segment_arrays
              //Initialize array
              //segment_address_array
              mov.b #0x1,r6L
              mov.b r6L,@0xCC40
              mov.b #0x0,r6L
              mov.b r6L,@0xCC41
              mov.b #0x1,r6L
              mov.b r6L,@0xCC42
              mov.b #0x3,r6L
              mov.b r6L,@0xCC43
              mov.b #0x3,r6L
              mov.b r6L,@0xCC44
              mov.b #0x1,r6L
              mov.b r6L,@0xCC45
              mov.b #0x0,r6L
              mov.b r6L,@0xCC46
              mov.b #0x1,r6L
              mov.b r6L,@0xCC47
              mov.b #0x3,r6L
              mov.b r6L,@0xCC48
              mov.b #0x3,r6L
              mov.b r6L,@0xCC49
              mov.b #0x1,r6L
              mov.b r6L,@0xCC4A
              mov.b #0x0,r6L
              mov.b r6L,@0xCC4B
              mov.b #0x1,r6L
              mov.b r6L,@0xCC4C
              mov.b #0x3,r6L
              mov.b r6L,@0xCC4D
              mov.b #0x3,r6L
              mov.b r6L,@0xCC4E
              mov.b #0x2,r6L
              mov.b r6L,@0xCC4F
              mov.b #0x4,r6L
              mov.b r6L,@0xCC50
              mov.b #0x5,r6L
              mov.b r6L,@0xCC51
              mov.b #0x8,r6L
              mov.b r6L,@0xCC52
              mov.b #0x7,r6L
              mov.b r6L,@0xCC53
              mov.b #0x2,r6L
              mov.b r6L,@0xCC54
              mov.b #0x4,r6L
              mov.b r6L,@0xCC55
              mov.b #0x5,r6L
              mov.b r6L,@0xCC56
              mov.b #0x8,r6L
              mov.b r6L,@0xCC57
              mov.b #0x7,r6L
              mov.b r6L,@0xCC58
              mov.b #0x4,r6L
              mov.b r6L,@0xCC59
              mov.b #0x5,r6L
              mov.b r6L,@0xCC5A
              mov.b #0x6,r6L
              mov.b r6L,@0xCC5B
              mov.b #0x8,r6L
              mov.b r6L,@0xCC5C
              mov.b #0x7,r6L
              mov.b r6L,@0xCC5D
              mov.b #0x4,r6L
              mov.b r6L,@0xCC5E
              mov.b #0x5,r6L
              mov.b r6L,@0xCC5F
              mov.b #0x6,r6L
              mov.b r6L,@0xCC60
              mov.b #0x8,r6L
              mov.b r6L,@0xCC61
              mov.b #0x7,r6L
              mov.b r6L,@0xCC62
              //Initialize array
              //segment_bit_array
              mov.b #0x10,r6L
              mov.b r6L,@0xCC63
              mov.b #0x10,r6L
              mov.b r6L,@0xCC64
              mov.b #0x1,r6L
              mov.b r6L,@0xCC65
              mov.b #0x1,r6L
              mov.b r6L,@0xCC66
              mov.b #0x10,r6L
              mov.b r6L,@0xCC67
              mov.b #0x20,r6L
              mov.b r6L,@0xCC68
              mov.b #0x20,r6L
              mov.b r6L,@0xCC69
              mov.b #0x2,r6L
              mov.b r6L,@0xCC6A
              mov.b #0x2,r6L
              mov.b r6L,@0xCC6B
              mov.b #0x20,r6L
              mov.b r6L,@0xCC6C
              mov.b #0x80,r6L
              mov.b r6L,@0xCC6D
              mov.b #0x80,r6L
              mov.b r6L,@0xCC6E
              mov.b #0x8,r6L
              mov.b r6L,@0xCC6F
              mov.b #0x8,r6L
              mov.b r6L,@0xCC70
              mov.b #0x80,r6L
              mov.b r6L,@0xCC71
              mov.b #0x20,r6L
              mov.b r6L,@0xCC72
              mov.b #0x2,r6L
              mov.b r6L,@0xCC73
              mov.b #0x2,r6L
              mov.b r6L,@0xCC74
              mov.b #0x2,r6L
              mov.b r6L,@0xCC75
              mov.b #0x2,r6L
              mov.b r6L,@0xCC76
              mov.b #0x80,r6L
              mov.b r6L,@0xCC77
              mov.b #0x8,r6L
              mov.b r6L,@0xCC78
              mov.b #0x8,r6L
              mov.b r6L,@0xCC79
              mov.b #0x8,r6L
              mov.b r6L,@0xCC7A
              mov.b #0x8,r6L
              mov.b r6L,@0xCC7B
              mov.b #0x20,r6L
              mov.b r6L,@0xCC7C
              mov.b #0x20,r6L
              mov.b r6L,@0xCC7D
              mov.b #0x20,r6L
              mov.b r6L,@0xCC7E
              mov.b #0x20,r6L
              mov.b r6L,@0xCC7F
              mov.b #0x20,r6L
              mov.b r6L,@0xCC80
              mov.b #0x80,r6L
              mov.b r6L,@0xCC81
              mov.b #0x80,r6L
              mov.b r6L,@0xCC82
              mov.b #0x80,r6L
              mov.b r6L,@0xCC83
              mov.b #0x80,r6L
              mov.b r6L,@0xCC84
              mov.b #0x80,r6L
              mov.b r6L,@0xCC85
              rts 0
label sys_write_ASCII
              // DIGIT = 5
              mov.w #0x5,r6
              mov.w r6,@0xCDE4
label beginloop_1149
              //IF DIGIT > 0
              mov.w #0x0,r5
              mov.w @0xCDE4,r6
              cmp.w r5,r6
              bhi fordo_1149
              jmp endloop_1149
label fordo_1149
              subs #0x1,r6
              mov.w r6,@0xCDE4
              
              // BYTE_VALUE = 64
              mov.b #0x40,r6L
              mov.b r6L,@0xCDE6
              
              // SEGMENT_COUNT = 7
              mov.w #0x7,r6
              mov.w r6,@0xCDE8
label beginloop_1150
              //IF SEGMENT_COUNT > 0
              mov.w #0x0,r5
              mov.w @0xCDE8,r6
              cmp.w r5,r6
              bhi fordo_1150
              jmp endloop_1150
label fordo_1150
              subs #0x1,r6
              mov.w r6,@0xCDE8
              
              // TEXT_CODE = TEXT[DIGIT]
              mov.w @0xCDE4,r0
              mov.w #0xCC86,r1
              add.w r1,r0
              mov.b @r0,r6L
              mov.b r6L,@0xCDEA
              
              //TEXT_CODE =TEXT_CODE AND BYTE_VALUE
              mov.b @0xCDE6,r5L
              mov.b @0xCDEA,r6L
              and r5L,r6L
              mov.b r6L,@0xCDEA
              
              //Fill container with cell
              //segment_address_array
              mov.w @0xCDE8,r6
              mov.w r6,@0xCDEC
              
              //SA_ARRAY_POINTER1 =SA_ARRAY_POINTER1 * 5
              mov.w #0x5,r5
              mov.w @0xCDEC,r6
              jsr @0x0130
              mov.w r6,@0xCDEC
              
              //SA_ARRAY_POINTER1 =SA_ARRAY_POINTER1 + 5,228800E+4
              mov.w #0xCC40,r5
              mov.w @0xCDEC,r6
              add.w r5,r6
              mov.w r6,@0xCDEC
              mov.w @0xCDE4,r6
              mov.w r6,@0xCDEE
              
              //SA_ARRAY_POINTER2 =SA_ARRAY_POINTER2 + SA_ARRAY_POINTER1
              mov.w @0xCDEC,r5
              mov.w @0xCDEE,r6
              add.w r5,r6
              mov.w r6,@0xCDEE
              
              // SEGMENT_ADDRESS = ^SA_ARRAY_POINTER2
              mov.w @0xCDEE,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCDF0
              
              //SEGMENT_ADDRESS =SEGMENT_ADDRESS + 6,125100E+4
              mov.w #0xEF43,r5
              mov.w @0xCDF0,r6
              add.w r5,r6
              mov.w r6,@0xCDF0
              
              //Fill container with cell
              //segment_bit_array
              mov.w @0xCDE8,r6
              mov.w r6,@0xCDEC
              
              //SA_ARRAY_POINTER1 =SA_ARRAY_POINTER1 * 5
              mov.w #0x5,r5
              mov.w @0xCDEC,r6
              jsr @0x0130
              mov.w r6,@0xCDEC
              
              //SA_ARRAY_POINTER1 =SA_ARRAY_POINTER1 + 5,232300E+4
              mov.w #0xCC63,r5
              mov.w @0xCDEC,r6
              add.w r5,r6
              mov.w r6,@0xCDEC
              mov.w @0xCDE4,r6
              mov.w r6,@0xCDEE
              
              //SA_ARRAY_POINTER2 =SA_ARRAY_POINTER2 + SA_ARRAY_POINTER1
              mov.w @0xCDEC,r5
              mov.w @0xCDEE,r6
              add.w r5,r6
              mov.w r6,@0xCDEE
              
              // SEGMENT_BIT_VALUE = ^SA_ARRAY_POINTER2
              mov.w @0xCDEE,r0
              mov.b @r0,r6L
              mov.b r6L,@0xCDF2
              
              //IF TEXT_CODE = 0
              mov.b #0x0,r5L
              mov.b @0xCDEA,r6L
              cmp.b r5L,r6L
              beq true_1151
              jmp false_1151
label true_1151
              //SEGMENT_BIT_VALUE =NOT(SEGMENT_BIT_VALUE)
              mov.b @0xCDF2,r6L
              not r6L
              mov.b r6L,@0xCDF2
              
              //^SEGMENT_ADDRESS =^SEGMENT_ADDRESS AND SEGMENT_BIT_VALUE
              mov.b @0xCDF2,r5L
              mov.w @0xCDF0,r0
              mov.b @r0,r6L
              and r5L,r6L
              mov.w @0xCDF0,r0
              mov.b r6L,@r0
              
              //SEGMENT_BIT_VALUE =NOT(SEGMENT_BIT_VALUE)
              mov.b @0xCDF2,r6L
              not r6L
              mov.b r6L,@0xCDF2
              jmp endif_1151
label false_1151
              
              //^SEGMENT_ADDRESS =^SEGMENT_ADDRESS OR SEGMENT_BIT_VALUE
              mov.b @0xCDF2,r5L
              mov.w @0xCDF0,r0
              mov.b @r0,r6L
              or r5L,r6L
              mov.w @0xCDF0,r0
              mov.b r6L,@r0
Label endif_1151
              //BYTE_VALUE =SHLR(BYTE_VALUE)
              mov.b @0xCDE6,r6L
              shlr r6L
              mov.b r6L,@0xCDE6
              jmp beginloop_1150
label endloop_1150
              jmp beginloop_1149
label endloop_1149
              rts 0
label init_sub_address_list
              // SYS_BG_TICKS = 82
              mov.w #0x52,r6
              mov.w r6,@0xCDF4
              
              // SYS_TICKS = 28
              mov.w #0x1C,r6
              mov.w r6,@0xCDF6
              
              // NUMBER_OF_NON_BGH_TASKS = 3
              mov.w #0x3,r6
              mov.w r6,@0xCDCC
              
              // LAST_NUMBER_OF_NON_BGH_TASKS = 3
              mov.w #0x3,r6
              mov.w r6,@0xCDF8
              rts 0
label sys_recalculate_sys_ticks
              // TMP_SYS_TICKS_L_321 = SYS_TICKS
              mov.w @0xCDF6,r6
              mov.w r6,@0xCDFA
              
              //TMP_SYS_TICKS_L_321 =TMP_SYS_TICKS_L_321 * LAST_NUMBER_OF_NON_BGH_TASKS
              mov.w @0xCDF8,r5
              mov.w @0xCDFA,r6
              jsr @0x0130
              mov.w r6,@0xCDFA
              
              //TMP_SYS_TICKS_L_321 =TMP_SYS_TICKS_L_321 * 10
              mov.w #0xA,r5
              mov.w @0xCDFA,r6
              jsr @0x0130
              mov.w r6,@0xCDFA
              
              //TMP_SYS_TICKS_L_321 =TMP_SYS_TICKS_L_321 / NUMBER_OF_NON_BGH_TASKS
              mov.w @0xCDCC,r5
              mov.w @0xCDFA,r6
              jsr @0x01be
              mov.w r6,@0xCDFA
              
              //TMP_SYS_TICKS_L_321 =TMP_SYS_TICKS_L_321 + 5
              mov.w #0x5,r5
              mov.w @0xCDFA,r6
              add.w r5,r6
              mov.w r6,@0xCDFA
              
              //TMP_SYS_TICKS_L_321 =TMP_SYS_TICKS_L_321 / 10
              mov.w #0xA,r5
              mov.w @0xCDFA,r6
              jsr @0x01be
              mov.w r6,@0xCDFA
              
              //IF TMP_SYS_TICKS_L_321 <= 32767
              mov.w #0x7FFF,r5
              mov.w @0xCDFA,r6
              cmp.w r5,r6
              bls true_1152
              // TMP_SYS_TICKS_L_321 = 32767
              mov.w #0x7FFF,r6
              mov.w r6,@0xCDFA
label true_1152
              //IF TMP_SYS_TICKS_L_321 >= 1
              mov.w #0x1,r5
              mov.w @0xCDFA,r6
              cmp.w r5,r6
              bcc true_1153
              // TMP_SYS_TICKS_L_321 = 1
              mov.w #0x1,r6
              mov.w r6,@0xCDFA
label true_1153
              // SYS_TICKS = TMP_SYS_TICKS_L_321
              mov.w @0xCDFA,r6
              mov.w r6,@0xCDF6
              
              // LAST_NUMBER_OF_NON_BGH_TASKS = NUMBER_OF_NON_BGH_TASKS
              mov.w @0xCDCC,r6
              mov.w r6,@0xCDF8
              rts 0
              //sub sys_wait_hundredth_new
label sys_wait_hundredth_new
              //make room for stack variables
              mov.w #0xC,r0
              sub.w r0,r7
              mov.w r5,@(0x0,r7)
              mov.w r6,@(0x2,r7)
              // SV_WAIT_START_ST_400 = Timer (3)
              mov.w @0xEE7C,r6
              jsr sys_type_cast_U16_to_U32
              jsr sys_type_cast_U32_to_I32
              mov.w r5,@(0x4,r7)
              mov.w r6,@(0x6,r7)
              // SV_WAIT_DURATION_ST_400 = 0
              mov.w #0x0,r5
              mov.w #0x0,r6
              mov.w r5,@(0x8,r7)
              mov.w r6,@(0xA,r7)
label beginloop_4001
              IF SV_WAIT_DURATION_ST_400 <= SV_WAIT_TIME_ST_400
              mov.w @(0x0,r7),r3
              mov.w @(0x2,r7),r4
              mov.w @(0x8,r7),r5
              mov.w @(0xA,r7),r6
              sub.w r4,r6
              subx r3L,r5L
              subx r3H,r5H
              ble loopdo_4001
              jmp endloop_4001
label loopdo_4001
              // SV_WAIT_DURATION_ST_400 = Timer (3)
              mov.w @0xEE7C,r6
              jsr sys_type_cast_U16_to_U32
              jsr sys_type_cast_U32_to_I32
              mov.w r5,@(0x8,r7)
              mov.w r6,@(0xA,r7)
              //SV_WAIT_DURATION_ST_400 =SV_WAIT_DURATION_ST_400 - SV_WAIT_START_ST_400
              mov.w @(0x4,r7),r3
              mov.w @(0x6,r7),r4
              mov.w @(0x8,r7),r5
              mov.w @(0xA,r7),r6
              sub.w r4,r6
              subx r3L,r5L
              subx r3H,r5H
              mov.w r5,@(0x8,r7)
              mov.w r6,@(0xA,r7)
              IF SV_WAIT_DURATION_ST_400 < 0
              mov.w #0x0,r3
              mov.w #0x0,r4
              mov.w @(0x8,r7),r5
              mov.w @(0xA,r7),r6
              sub.w r4,r6
              subx r3L,r5L
              subx r3H,r5H
              blt true_4002
              jmp false_4002
label true_4002
              //SV_WAIT_DURATION_ST_400 =SV_WAIT_DURATION_ST_400 + 6.553500E+4
              mov.w #0x0,r3
              mov.w #0xFFFF,r4
              mov.w @(0x8,r7),r5
              mov.w @(0xA,r7),r6
              add.w r4,r6
              addx r3L,r5L
              addx r3H,r5H
              mov.w r5,@(0x8,r7)
              mov.w r6,@(0xA,r7)
              jmp endif_4002
label false_4002
Label endif_4002
              jmp beginloop_4001
label endloop_4001
              //free stack variable space
              mov.w #0xC,r0
              add.w r0,r7
              //end_of_sub_sys_wait_hundredth_new
              rts 0
              //sub sys_wait_ms_new
label sys_wait_ms_new
              //make room for stack variables
              mov.w #0x8,r0
              sub.w r0,r7
              mov.w r6,@(0x0,r7)
              IF SV_TASK = 0
              mov.w #0x0,r5
              mov.w @0xCD8E,r6
              cmp.w r5,r6
              beq true_3001
              jmp false_3001
label true_3001
              // TICKS_ST_300 = SYS_BG_TICKS
              mov.w @0xCDF4,r6
              mov.w r6,@(0x2,r7)
              jmp endif_3001
label false_3001
              
              // TICKS_ST_300 = SYS_TICKS
              mov.w @0xCDF6,r6
              mov.w r6,@(0x2,r7)
Label endif_3001
              // WAIT_TIME1_ST_300 = 0
              mov.w #0x0,r6
              mov.w r6,@(0x4,r7)
label beginloop_3002
              IF WAIT_TIME1_ST_300 < MS_ST_300
              mov.w @(0x0,r7),r5
              mov.w @(0x4,r7),r6
              cmp.w r5,r6
              bcs fordo_3002
              jmp endloop_3002
label fordo_3002
              adds #0x1,r6
              mov.w r6,@(0x4,r7)
              // WAIT_TIME2_ST_300 = 0
              mov.w #0x0,r6
              mov.w r6,@(0x6,r7)
label beginloop_3003
              IF WAIT_TIME2_ST_300 < TICKS_ST_300
              mov.w @(0x2,r7),r5
              mov.w @(0x6,r7),r6
              cmp.w r5,r6
              bcs fordo_3003
              jmp endloop_3003
label fordo_3003
              adds #0x1,r6
              mov.w r6,@(0x6,r7)
              jmp beginloop_3003
label endloop_3003
              jmp beginloop_3002
label endloop_3002
              //free stack variable space
              mov.w #0x8,r0
              add.w r0,r7
              //end_of_sub_sys_wait_ms_new
              rts 0
label  sys_set_motor
              //disable
              orc #0x80
              mov.w r5,@0xCDFC
              mov.w r6,@0xCDFE
              
              // MOTOR_POINTER_L_321 = MOTOR_CODE_L_321
              mov.w @0xCDFC,r6
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 AND 3
              mov.w #0x3,r5
              mov.w @0xCE00,r6
              and r5L,r6L
              and r5H,r6H
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 * 6
              mov.w #0x6,r5
              mov.w @0xCE00,r6
              jsr @0x0130
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 + 6,097200E+4
              mov.w #0xEE2C,r5
              mov.w @0xCE00,r6
              add.w r5,r6
              mov.w r6,@0xCE00
              
              
              mov.w @0xCE00,r0
              //with displacement
              MOV.B @(0x1,R0),R6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCE02
              
              //MOTOR_TEST_L_321 =MOTOR_TEST_L_321 + MOTOR_ACTION_L_321
              mov.w @0xCDFE,r5
              mov.w @0xCE02,r6
              add.w r5,r6
              mov.w r6,@0xCE02
              
              //IF MOTOR_TEST_L_321 <> 3
              mov.w #0x3,r5
              mov.w @0xCE02,r6
              cmp.w r5,r6
              bne true_1154
              
              mov.w @0xCE00,r0
              //with displacement
              MOV.B @(0x0,R0),R6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCE04
              
              //POWER_TEST_L_321 =SHLR(POWER_TEST_L_321)
              mov.w @0xCE04,r6
              shlr r6H
              rotxr r6L
              mov.w r6,@0xCE04
              mov.w @0xCE04,r6
              jsr sys_wait_ms_new
label true_1154
              mov.w @0xCDFE,r6
              
              mov.w @0xCE00,r0
              //with displacement
              MOV.B R6L,@(0x1,R0)
              
              //ROM_CALL
              mov.w @0xCE00,r6
              mov.w r6,@-r7
              mov.w @0xCDFC,r6
              jsr @0x3CE6
              adds #0x2,r7
              //enable
              andc #0x7F
              rts 0
label  sys_set_motor_power
              //disable
              orc #0x80
              mov.w r5,@0xCDFC
              mov.b r6L,@0xCE06
              
              // MOTOR_POINTER_L_321 = MOTOR_CODE_L_321
              mov.w @0xCDFC,r6
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 AND 3
              mov.w #0x3,r5
              mov.w @0xCE00,r6
              and r5L,r6L
              and r5H,r6H
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 * 6
              mov.w #0x6,r5
              mov.w @0xCE00,r6
              jsr @0x0130
              mov.w r6,@0xCE00
              
              //MOTOR_POINTER_L_321 =MOTOR_POINTER_L_321 + 6,097200E+4
              mov.w #0xEE2C,r5
              mov.w @0xCE00,r6
              add.w r5,r6
              mov.w r6,@0xCE00
              
              //IF ^MOTOR_POINTER_L_321 = MOTOR_POWER_L_321
              mov.b @0xCE06,r5L
              mov.w @0xCE00,r0
              mov.b @r0,r6L
              cmp.b r5L,r6L
              beq true_1155
              // ^MOTOR_POINTER_L_321 = MOTOR_POWER_L_321
              mov.b @0xCE06,r6L
              mov.w @0xCE00,r0
              mov.b r6L,@r0
              
              // TEMP_POWER_L_321 = ^MOTOR_POINTER_L_321
              mov.w @0xCE00,r0
              mov.b @r0,r6L
              jsr sys_type_cast_U8_to_U16
              mov.w r6,@0xCE08
              
              //TEMP_POWER_L_321 =TEMP_POWER_L_321 / 8
              mov.w #0x8,r5
              mov.w @0xCE08,r6
              jsr @0x01be
              mov.w r6,@0xCE08
              
              //set motor waveform
              mov.w @0xCE08,r0
              shll r0L
              rotxl r0H
              shll r0L
              rotxl r0H
              mov.w #0xCC8C,r1
              add.w r1,r0
              mov.w @r0,r5
              mov.w @(0x2,r0),r6
              
              mov.w @0xCE00,r0
              //with displacement
              MOV.W R5,@(0x2,R0)
              adds #0x2,r0
              //with displacement
              MOV.W R6,@(0x2,R0)
label true_1155
              //enable
              andc #0x7F
              rts 0
              //cast u8 to u16
              //result in r6
Label sys_type_cast_U8_to_U16
              mov.b #0x0,r6H
              rts 0
              //CAST u32 to i32
              //result in r5r6
label sys_type_cast_U32_to_I32
              btst #7,r5H
              beq sys_ty_ca_U32_I32_1
              //overflow
              mov.w #0x7FFF,r5
              mov.w #0xFFFF,r6
label sys_ty_ca_U32_I32_1
              rts 0
              //cast u16 to u32
              //result in r5r6
Label sys_type_cast_U16_to_U32
              mov.w #0x0,r5
              rts 0
              //CAST u16 to i16
              //result in r6
label sys_type_cast_U16_to_I16
              btst #7,r6H
              beq sys_ty_ca_U16_I16_1
              //overflow
              mov.w #0x7fff,r6
label sys_ty_ca_U16_I16_1
              rts 0
              //CAST i16 to u16
              //result in r6
label sys_type_cast_I16_to_U16
              btst #7,r6H
              beq sys_ty_ca_I16_U16_1
              //negative
              mov.w #0x0,r6
label sys_ty_ca_I16_U16_1
              rts 0
              //Rotate right through carry 32
label sys_ROTXR32
              rotxr r5H
              rotxr r5L
              rotxr r6H
              rotxr r6L
              rts 0
label end_of_program
