 (ns clojure-pf.bpf.code
   "BPF instruction codes and operations.")
 
-(def my-prog [:ld :abs :w
+; Utilities
 
-(def ^:private ^:const kind-table
+(def ^:private kind-table
   "Instruction kinds"
   {:ld    0x00    ; load to acc
    :ldx   0x01    ; load to idx
    :st    0x02    ; store acc
    :stx   0x03    ; store idx
    :alu   0x04    ; op between accumulator and source
+   :jmp   0x05    ; jump
    :ret   0x06    ; return
    :misc  0x07})  ; miscellaneous
 
-(def ^:private ^:const size-table
+(def ^:private size-table
   "Data size variants."
   {:w     0x00    ; word
    :h     0x08    ; halfword
    :b     0x10})  ; byte
 
-(def ^:private ^:const mode-table
+(def ^:private mode-table
   "Addressing modes."
   {:imm   0x00    ; constant
    :abs   0x20    ; data at fixed-offset

         source-table
         retval-table))

; Category checking

(defn kind? [ins]
  (contains? kind-table ins))

(defn size? [ins]
  (contains? size-table ins))

(defn mode? [ins]
  (contains? mode-table ins))

(defn op? [ins]
  (contains? operation-table ins))

(defn source? [ins]
  (contains? source-table ins))

(defn retval? [ins]
  (contains? retval-table ins))

; Translation

(defn to-code [ins]
  (get table ins))

   :jge   0x30    ; jump-if-greater-or-equal
   :jset  0x40})  ; jump-if-set

(def ^:private source-table
  "Value modes."
  {:k     0x00    ; constant
   :x     0x08})  ; index register

(def ^:private retval-table
  "Return value modes."
  {:k     0x00    ; constant
   :x     0x08    ; index register
   :a     0x10})  ; accumulator

(def ^:private table
  "All instruction constants."
  (merge kind-table
         size-table
