   0:# INIT TABLES
  12:# 
  13:# ======= START RUNG 1 =======
  14:LabelRung1:
  15:
  16:set bit '$rung_top'
  18:# start series [
  19:# ELEM_ADD
  20:if '$rung_top' {
  21:    increment 'CCD'; copy overlap(-1 to 0) flag to '$overlap'; copy overflow flag to 'ROverflowFlagV'
  22:}
  24:# ] finish series
  25:# 
  26:# ======= START RUNG 2 =======
  27:LabelRung2:
  28:
  29:set bit '$rung_top'
  31:# start series [
  32:# ELEM_GRT
  33:if '$rung_top' {
  34:    if 'CCD' <= '99' {
  35:        clear bit '$rung_top'
  36:    }
  37:}
  39:# ELEM_MOVE
  40:if '$rung_top' {
  41:    let var 'CCD' := 0
  42:}
  44:# ] finish series
  45:# 
  46:# ======= START RUNG 3 =======
  47:LabelRung3:
  48:
  49:# Convert binary 'CCD' variable to binary-coded decimal 'bcd' un
  50:# One byte 'CDD' to two digits(bytes) 'bcd'(one byte - one digit
  51:# 
  52:# ======= START RUNG 4 =======
  53:LabelRung4:
  54:
  55:set bit '$rung_top'
  57:# start series [
  58:# ELEM_BIN2BCD
  59:if '$rung_top' {
  60:    let var 'bcd' = bin2bcd('CCD');
  61:}
  63:# ] finish series
  64:# 
  65:# ======= START RUNG 5 =======
  66:LabelRung5:
  67:
  68:# Convert 'bcd' unpacked to 'bcd' packed(one digit-one nible) va
  69:# 
  70:# ======= START RUNG 6 =======
  71:LabelRung6:
  72:
  73:set bit '$rung_top'
  75:# start series [
  76:# ELEM_SR0
  77:if '$rung_top' {
  78:    let var 'bcd4' := 'bcd' sr0 '4'
  79:}
  81:# ELEM_OR
  82:if '$rung_top' {
  83:    let var 'bcd' := 'bcd' | 'bcd4'
  84:}
  86:# ELEM_AND
  87:if '$rung_top' {
  88:    let var 'bcd' := 'bcd' & '0xFF'
  89:}
  91:# ] finish series
  92:# 
  93:# ======= START RUNG 7 =======
  94:LabelRung7:
  95:
  96:# Set MCU ports as outputs.
  97:# 
  98:# ======= START RUNG 8 =======
  99:LabelRung8:
 100:
 101:set bit '$rung_top'
 103:# start series [
 104:# ELEM_ONE_SHOT_RISING
 105:if '$rung_top' {
 106:    if '$once_0_ONE_SHOT_RISING' {
 107:        clear bit '$rung_top'
 108:    } else {
 109:        set bit '$once_0_ONE_SHOT_RISING'
 110:    }
 111:} else {
 112:    clear bit '$once_0_ONE_SHOT_RISING'
 113:}
 115:# ELEM_MOVE
 116:if '$rung_top' {
 117:    let var '#TRISF' := 255
 118:}
 120:# ] finish series
 121:# 
 122:# ======= START RUNG 9 =======
 123:LabelRung9:
 124:
 125:# Out packed bcd value to port. Two digits - one byte.
 126:# 
 127:# ======= START RUNG 10 =======
 128:LabelRung10:
 129:
 130:set bit '$rung_top'
 132:# start series [
 133:# ELEM_MOVE
 134:if '$rung_top' {
 135:    let var '#PORTF' := 'bcd'
 136:}
 138:# ] finish series
 139:LabelRung11:
 140:
 141:# Latest INT_OP here
