Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/qualification/security673/branch-check.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / qualification / security673 / branch-check.om` 212 lines ยท 3390 bytes Raw Blame History 1 note Consume independently decoded GNU objdump output, not machine words from the compiler. 2 note Exit61 target mismatch;62 invalid input;90 usage. Only the first branch mnemonic and unique mov marker 3 note are selected: with no argument the first b.ne and mov x1, 12345 (forward corpus modes 0..3); with 4 note argument 1 the first b.al and mov x4, 12345 (mode4, the backward continue to the loop head). 5 global linebuf uchar 512 6 global chunk uchar 4096 7 global cursor ulong 1 8 global branch ulong 1 9 global marker ulong 1 10 global bcount ulong 1 11 global mcount ulong 1 12 global form uchar 8 13 global mn uchar 8 14 global mnl ulong 1 15 global label uchar 32 16 global labl ulong 1 17 text mnf "b.ne" 18 text labf "mov\tx1, #0x3039" 19 text mnb "b.al" 20 text labb "mov\tx4, #0x3039" 21 fn hexval b uchar to ulong 22 if and ge b 48 le b 57 23 ret sub ulong b 48 24 end 25 if and ge b 97 le b 102 26 ret add sub ulong b 97 10 27 end 28 ret 16 29 end 30 fn number start ulong n ulong to ulong 31 p = start 32 value = ulong 0 33 while lt p n 34 v = hexval get linebuf p 35 if eq v 16 36 if eq p start 37 exit 62 38 end 39 put cursor 0 p 40 ret value 41 end 42 if ge sub p start 16 43 exit 62 44 end 45 value = or shl value 4 v 46 p = add p 1 47 end 48 if eq p start 49 exit 62 50 end 51 put cursor 0 p 52 ret value 53 end 54 fn hasmn i ulong n ulong to bool 55 if or eq i 0 ge add i get mnl 0 n 56 ret false 57 end 58 if and ne get linebuf sub i 1 9 ne get linebuf sub i 1 32 59 ret false 60 end 61 for j ulong get mnl 0 62 if ne get linebuf add i j get mn j 63 ret false 64 end 65 end 66 v = get linebuf add i get mnl 0 67 ret or eq v 9 eq v 32 68 end 69 fn hasmark i ulong n ulong to bool 70 if or eq i 0 gt add i get labl 0 n 71 ret false 72 end 73 if and ne get linebuf sub i 1 9 ne get linebuf sub i 1 32 74 ret false 75 end 76 for j ulong get labl 0 77 if ne get linebuf add i j get label j 78 ret false 79 end 80 end 81 if lt add i get labl 0 n 82 v = get linebuf add i get labl 0 83 if and ne v 32 ne v 9 84 ret false 85 end 86 end 87 ret true 88 end 89 fn target i ulong n ulong to ulong 90 p = add i get mnl 0 91 while lt p n 92 v = get linebuf p 93 if and ne v 32 ne v 9 94 if gt add p 2 n 95 exit 62 96 end 97 if or ne v 48 ne get linebuf add p 1 120 98 exit 62 99 end 100 value = number add p 2 n 101 q = get cursor 0 102 if lt q n 103 v = get linebuf q 104 if and ne v 32 ne v 9 105 exit 62 106 end 107 end 108 ret value 109 end 110 p = add p 1 111 end 112 exit 62 113 end 114 fn inspect n ulong to void 115 p = ulong 0 116 while lt p n 117 if ne get linebuf p 32 118 if eq hexval get linebuf p 16 119 ret 120 end 121 addr = number p n 122 q = get cursor 0 123 if ge q n 124 ret 125 end 126 if or ne get linebuf q 58 lt addr 176 127 ret 128 end 129 for i ulong n 130 if eq get bcount 0 0 131 if hasmn i n 132 put branch 0 target i n 133 put bcount 0 1 134 end 135 end 136 if hasmark i n 137 put marker 0 addr 138 put mcount 0 add get mcount 0 1 139 end 140 end 141 ret 142 end 143 p = add p 1 144 end 145 end 146 fn main to int 147 back = false 148 if eq argcnt 2 149 r = argread 1 form 0 len form 150 if or ne r 1 ne get form 0 49 151 ret 90 152 end 153 back = true 154 else 155 if ne argcnt 1 156 ret 90 157 end 158 end 159 if back 160 put mnl 0 len mnb 161 for j ulong len mnb 162 put mn j get mnb j 163 end 164 put labl 0 len labb 165 for j ulong len labb 166 put label j get labb j 167 end 168 else 169 put mnl 0 len mnf 170 for j ulong len mnf 171 put mn j get mnf j 172 end 173 put labl 0 len labf 174 for j ulong len labf 175 put label j get labf j 176 end 177 end 178 n = ulong 0 179 go = true 180 while go 181 r = read 0 chunk 0 len chunk 182 if lt r 0 183 ret 62 184 end 185 if eq r 0 186 go = false 187 else 188 for k ulong ulong r 189 if eq get chunk k 10 190 inspect n 191 n = ulong 0 192 else 193 if ge n len linebuf 194 ret 62 195 end 196 put linebuf n get chunk k 197 n = add n 1 198 end 199 end 200 end 201 end 202 if ne n 0 203 inspect n 204 end 205 if or ne get bcount 0 1 ne get mcount 0 1 206 ret 62 207 end 208 if ne get branch 0 get marker 0 209 ret 61 210 end 211 ret 0 212 end