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/CUDApp/blob/main/om/encoder/bw_enc_sm121.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / encoder / bw_enc_sm121.om` 679 lines · 15513 bytes Raw Blame History 1 note bw_enc_sm121.om: the sm_121 instruction encoder of CUDApp (aien-dev/CUDApp#79, OM-GPU-RETIRE). 2 note It turns a solved BlackwellIR program into machine code: four 32-bit words per instruction, 3 note little-endian, padded with NOPs to a multiple of 8 and at least 32 instructions. 4 note It replaces encode_single_insn and omega_bw_encode_program of src/omega_blackwell_codegen.c, 5 note which stays compiled only behind CUDAPP_MIGRATION_PENDING_C_ENCODER as the differential oracle 6 note or the explicit CUDAPP_MIGRATION_PENDING_C_NO_POSIX oracle switch; both defaults use Omega. 7 note 8 note Input (bw_om_encode in src/omega_blackwell_codegen.c packs it; 8 ulong per instruction, at most 1024 instructions): 9 note 0 op (the BlackwellIROpcode number) 1 dst_vreg 2 src1_vreg 3 src2_vreg 4 src3_vreg 10 note 5 ureg (the five vreg fields are C int, passed as 64-bit two's complement: negative = none) 11 note 6 imm or control shl 32 12 note 7 is_uniform or predicate_p0 shl 1 or predicate_not shl 2 or bar_reg shl 8 13 note or dst_subreg shl 16 or src1_subreg shl 24 or src2_subreg shl 32 or src3_subreg shl 40 14 note phys: vreg_to_phys 0..255 then uvreg_to_phys at 256..287 (C int, two's complement). 15 note pad 1: omega_bw_encode_program (pad to the multiple of 8, at least 32); pad 0: exactly n instructions. 16 note Result: the bytes written, or 0 when an instruction is refused (unknown op, an offset outside its 17 note field, a BSSY delta below 2, a barrier register above 15, a P0 guard on LDCU / LDCU.64) or n is above 1024. 18 note Every constant is the decimal form of the C encoder's hex word (conversions by Wolfram, 19 note evidence/CUDAPP-OM-ENCODER/wolfram-constants.txt). 20 21 const NEG ulong `9223372036854775808` 22 const NOPW ulong 31000 23 const NOPC ulong `1032192` 24 25 fn put4 w edit ulong 4 a ulong b ulong c ulong d ulong to void 26 put w 0 a 27 put w 1 b 28 put w 2 c 29 put w 3 d 30 end 31 32 note the physical register of one operand field: phys + subreg, or dflt when the vreg is negative 33 fn preg phys view ulong 288 v ulong sb ulong dflt ulong to ulong 34 if ge v NEG 35 ret dflt 36 end 37 ret add get phys v sb 38 end 39 40 note 1 when a vreg field is given (not negative), else 0 41 fn pres v ulong to ulong 42 if ge v NEG 43 ret 0 44 end 45 ret 1 46 end 47 48 note Only constant loads have uniform destinations; IMAD uses is_uniform for its source. 49 fn isuld op ulong to bool 50 ret or eq op 6 eq op 7 51 end 52 53 fn opnds ins view ulong 8192 i ulong phys view ulong 288 o edit ulong 16 to void 54 b = mul i 8 55 f = get ins add b 7 56 put o 0 get ins b 57 put o 1 preg phys get ins add b 1 and shr f 16 255 0 58 put o 2 preg phys get ins add b 2 and shr f 24 255 0 59 put o 3 preg phys get ins add b 3 and shr f 32 255 0 60 put o 4 preg phys get ins add b 4 and shr f 40 255 255 61 u = get ins add b 5 62 put o 5 0 63 if lt u NEG 64 put o 5 get phys add u 256 65 end 66 put o 14 pres u 67 x = get ins add b 6 68 put o 6 and x `4294967295` 69 put o 7 shr x 32 70 put o 8 and f 1 71 put o 9 and shr f 1 1 72 put o 10 and shr f 2 1 73 put o 11 and shr f 8 255 74 put o 12 pres get ins add b 2 75 put o 13 pres get ins add b 3 76 d = get ins add b 1 77 put o 15 pres d 78 if and isuld get o 0 lt d NEG 79 put o 1 get phys add d 256 80 end 81 end 82 83 note the control word: the instruction's own, else the op's default 84 fn ctl o view ulong 16 dflt ulong to ulong 85 c = get o 7 86 if ne c 0 87 ret c 88 end 89 ret dflt 90 end 91 92 note low 8 bits of operand slot k 93 fn rb o view ulong 16 k ulong to ulong 94 ret and get o k 255 95 end 96 97 note slot k when its vreg (presence slot h) is given, else RZ 98 fn rz o view ulong 16 k ulong h ulong to ulong 99 if ne get o h 0 100 ret rb o k 101 end 102 ret 255 103 end 104 105 fn wd o view ulong 16 base ulong to ulong 106 ret or base shl rb o 1 16 107 end 108 109 fn wa o view ulong 16 base ulong to ulong 110 ret or base shl rb o 2 24 111 end 112 113 fn wda o view ulong 16 base ulong to ulong 114 ret or wd o base shl rb o 2 24 115 end 116 117 note the 4-bit guard predicate field: 7 always, 0 @P0, 8 @!P0 118 fn pred o view ulong 16 to ulong 119 if eq get o 9 0 120 ret 7 121 end 122 if eq get o 10 0 123 ret 0 124 end 125 ret 8 126 end 127 128 note a signed 24-bit byte offset (imm read as int32) fits 129 fn off24 imm ulong to bool 130 ret or lt imm `8388608` ge imm `4286578688` 131 end 132 133 note ops 0..14: moves, constants, integer multiply-add, compares and global memory 134 fn enc_a o view ulong 16 w edit ulong 4 to ulong 135 op = get o 0 136 imm = get o 6 137 if eq op 0 138 put4 w NOPW 0 0 ctl o NOPC 139 ret 0 140 end 141 if eq op 1 142 put4 w wd o 29186 255 3840 ctl o `1040896` 143 ret 0 144 end 145 if eq op 2 146 put4 w wd o 30722 imm 3840 ctl o `1040896` 147 ret 0 148 end 149 if eq op 3 150 put4 w wd o 31001 0 shl and imm 255 8 ctl o 926208 151 ret 0 152 end 153 if eq op 4 154 put4 w wd o `4278221698` and shl imm 6 `16776960` 2048 ctl o `1040896` 155 ret 0 156 end 157 if eq op 5 158 put4 w wd o `4278221698` and shl imm 6 `16776960` 2560 ctl o 926208 159 ret 0 160 end 161 if eq op 6 162 put4 w wd o `4278220716` and shl imm 5 `16776960` `134219776` ctl o 926208 163 ret 0 164 end 165 if eq op 7 166 put4 w wd o `4278220716` and shl imm 5 `16776960` `134220288` ctl o 945664 167 ret 0 168 end 169 if eq op 8 170 if ne get o 13 0 171 put4 w wda o 29220 rb o 3 or `126747136` rb o 4 ctl o `2083328` 172 ret 0 173 end 174 if and ne get o 8 0 ne get o 14 0 175 put4 w wda o 31780 rb o 5 or `260964864` rb o 4 ctl o `2083328` 176 ret 0 177 end 178 put4 w wda o 30756 imm or `126747136` rb o 4 ctl o `2083328` 179 ret 0 180 end 181 if eq op 9 182 put4 w wda o 30757 imm or `126746624` rb o 4 ctl o `2083840` 183 ret 0 184 end 185 if eq op 10 186 if and ne get o 8 0 ne get o 14 0 187 put4 w wda o 31756 rb o 5 `200302704` ctl o `3136000` 188 ret 0 189 end 190 put4 w wda o 30732 imm `66085488` ctl o `2087424` 191 ret 0 192 end 193 if eq op 11 194 note Existing C LDG.E signed byte-offset form (#373), identical to the wide-load field below. 195 if not off24 imm 196 ret 1 197 end 198 put4 w wda o 31105 or rb o 5 shl and imm `16777215` 8 `203299072` ctl o 991744 199 ret 0 200 end 201 if eq op 12 202 if not off24 imm 203 ret 1 204 end 205 put4 w wa o 31110 or rb o 3 shl and imm `16777215` 8 or `202381568` rb o 5 ctl o `1040896` 206 ret 0 207 end 208 if eq op 13 209 put4 w wa o 31110 rb o 3 or `202447104` rb o 5 ctl o `1040896` 210 ret 0 211 end 212 if eq op 14 213 put4 w wda o 29200 rb o 3 `134209791` ctl o `17811968` 214 ret 0 215 end 216 ret 1 217 end 218 219 note ops 15..29: tensor core, shifts, wide and strong loads, stores, fences, atomics 220 fn enc_b o view ulong 16 w edit ulong 4 to ulong 221 op = get o 0 222 imm = get o 6 223 if or eq op 15 eq op 16 224 p = ulong 0 225 if eq op 16 226 p = 262144 227 end 228 put4 w wda o 29244 rb o 3 or or rb o 4 6144 p ctl o `1040896` 229 ret 0 230 end 231 if eq op 17 232 put4 w or wd o 30745 `4278190080` imm or 71168 rb o 2 ctl o `2083328` 233 ret 0 234 end 235 if eq op 18 236 put4 w wda o 30738 imm `126796031` ctl o `2083328` 237 ret 0 238 end 239 if eq op 19 240 put4 w wda o 31105 rb o 5 `203298048` ctl o 991744 241 ret 0 242 end 243 if eq op 20 244 put4 w wda o 31105 rb o 5 `203380992` ctl o 991744 245 ret 0 246 end 247 if eq op 21 248 put4 w wda o 31105 rb o 5 `203364608` ctl o 991744 249 ret 0 250 end 251 if eq op 22 252 a = wa o 31110 253 if ne get o 9 0 254 a = or wa o 2438 shl pred o 12 255 end 256 put4 w a rb o 3 or `202463488` rb o 5 ctl o `1040896` 257 ret 0 258 end 259 if eq op 23 260 put4 w 31122 0 45056 ctl o `1043456` 261 ret 0 262 end 263 if eq op 24 264 put4 w 31122 0 12288 ctl o `1043456` 265 ret 0 266 end 267 if eq op 25 268 put4 w `4278221199` 0 `33554432` ctl o `1042432` 269 ret 0 270 end 271 if eq op 26 272 put4 w wda o 31144 or rb o 3 `2147483648` or `136270080` rb o 5 ctl o `3284480` 273 ret 0 274 end 275 if eq op 27 276 put4 w wda o 31144 or rb o 3 `2147483648` or `203378944` rb o 5 ctl o `3284480` 277 ret 0 278 end 279 if eq op 28 280 put4 w wa o 29196 rb o 3 `66084976` ctl o `2087424` 281 ret 0 282 end 283 if eq op 29 284 put4 w wda o 29202 rb o 3 `126762239` ctl o `2083328` 285 ret 0 286 end 287 ret 1 288 end 289 290 note ops 30..45: floating point, special functions, shuffles, shared memory, exit 291 fn enc_c o view ulong 16 w edit ulong 4 to ulong 292 op = get o 0 293 imm = get o 6 294 if eq op 30 295 put4 w wda o 29217 rb o 3 0 ctl o `5227520` 296 ret 0 297 end 298 if eq op 31 299 put4 w wda o 29217 or rb o 3 `2147483648` 0 ctl o `5227520` 300 ret 0 301 end 302 if eq op 32 303 put4 w wda o 29216 rb o 3 `4194304` ctl o `5227520` 304 ret 0 305 end 306 if eq op 33 307 put4 w wda o 29219 rb o 3 rb o 4 ctl o `5227520` 308 ret 0 309 end 310 if eq op 34 311 c = ulong `66084864` 312 if ne imm 0 313 c = imm 314 end 315 a = or or 29195 shl and get o 1 7 16 shl rb o 2 24 316 put4 w a rb o 3 c ctl o `5227520` 317 ret 0 318 end 319 if eq op 35 320 put4 w wda o 29192 rb o 3 and get o 4 7 ctl o `1034752` 321 ret 0 322 end 323 if eq op 36 324 put4 w wda o 29193 rb o 3 `58720256` ctl o `5227520` 325 ret 0 326 end 327 if eq op 37 328 put4 w wda o 29193 rb o 3 `125829120` ctl o `5227520` 329 ret 0 330 end 331 if eq op 38 332 put4 w wd o 29253 rb o 2 `2102272` ctl o `5235200` 333 ret 0 334 end 335 if eq op 39 336 put4 w wd o 29445 rb o 2 `2158848` ctl o `5120512` 337 ret 0 338 end 339 if eq op 40 340 put4 w wd o 29448 rb o 2 4096 ctl o 926720 341 ret 0 342 end 343 if eq op 41 344 put4 w wd o 29448 rb o 2 5120 ctl o 926720 345 ret 0 346 end 347 if eq op 42 348 put4 w wda o 32649 or `134225664` shl and imm 31 21 917504 ctl o 926720 349 ret 0 350 end 351 if eq op 43 352 put4 w wda o 31108 0 and imm 65535 ctl o `1040896` 353 ret 0 354 end 355 if eq op 44 356 put4 w wa o 29576 rb o 3 and imm 65535 ctl o `1040896` 357 ret 0 358 end 359 if eq op 45 360 a = ulong 31053 361 put4 w a 0 `58720256` ctl o `1042944` 362 ret 0 363 end 364 ret 1 365 end 366 367 note op 46: BRA. rel = imm - 1 as int32; low 6 bits at w0 18..23, rel arithmetic-shifted by 6 at w1 bit 2 368 fn enc_bra o view ulong 16 w edit ulong 4 to ulong 369 imm = get o 6 370 rel = and sub imm 1 `4294967295` 371 s = shr rel 6 372 c = ulong `58720256` 373 if ge rel `2147483648` 374 s = or s `4227858432` 375 c = `58982399` 376 end 377 d = get o 7 378 if eq d 0 379 d = `1042944` 380 if and eq imm 0 eq get o 9 0 381 d = NOPC 382 end 383 end 384 a = or or 2375 shl pred o 12 shl and rel 63 18 385 put4 w a and shl s 2 `4294967295` c d 386 ret 0 387 end 388 389 note ops 46..59: branches, reconvergence, barriers, wide shared loads, three-source integer ops 390 fn enc_d o view ulong 16 w edit ulong 4 to ulong 391 op = get o 0 392 imm = get o 6 393 bar = get o 11 394 if eq op 46 395 ret enc_bra o w 396 end 397 if eq op 47 398 put4 w wd o 29448 rb o 2 2048 ctl o 926720 399 ret 0 400 end 401 if eq op 48 402 put4 w 31517 0 65536 ctl o `1043456` 403 ret 0 404 end 405 if eq op 49 406 put4 w wda o 31108 255 `134219776` ctl o 927744 407 ret 0 408 end 409 if eq op 50 410 put4 w wa o 31112 rb o 3 `134220031` ctl o `1040896` 411 ret 0 412 end 413 if eq op 51 414 a = or or 29202 shl rb o 1 16 shl rz o 2 12 24 415 put4 w a rz o 3 13 or or `126746624` shl and imm 255 8 rb o 4 ctl o `2083328` 416 ret 0 417 end 418 if eq op 52 419 a = or or 29209 shl rb o 1 16 shl rz o 2 12 24 420 put4 w a rz o 3 13 or 1536 rb o 4 ctl o `2083328` 421 ret 0 422 end 423 if eq op 53 424 a = or or 29223 shl rb o 1 16 shl rz o 2 12 24 425 put4 w a rz o 3 13 or `126746624` rb o 4 ctl o `2083328` 426 ret 0 427 end 428 if eq op 54 429 if or or lt imm 2 ge imm `2147483648` ge bar 16 430 ret 1 431 end 432 a = or or 2373 shl pred o 12 shl bar 16 433 put4 w a and mul sub imm 1 16 `4294967295` `58720768` ctl o `1040896` 434 ret 0 435 end 436 if eq op 55 437 if ge bar 16 438 ret 1 439 end 440 a = or or 2369 shl pred o 12 shl bar 16 441 put4 w a 0 `58720768` ctl o `1042944` 442 ret 0 443 end 444 if eq op 56 445 if not off24 imm 446 ret 1 447 end 448 put4 w wda o 31105 or rb o 5 shl and imm `16777215` 8 `203299584` ctl o 991744 449 ret 0 450 end 451 if eq op 57 452 if not off24 imm 453 ret 1 454 end 455 put4 w wda o 31105 or rb o 5 shl and imm `16777215` 8 `203300096` ctl o 991744 456 ret 0 457 end 458 if eq op 58 459 if ge imm `8388608` 460 ret 1 461 end 462 put4 w wda o 31108 shl and imm `16777215` 8 3072 ctl o `1042432` 463 ret 0 464 end 465 if eq op 59 466 put4 w wd o 29448 rb o 2 3072 ctl o 926720 467 ret 0 468 end 469 ret 1 470 end 471 472 note ops 60..63 (Training R5): SHFL.BFLY (SHFL.DOWN's words with w1 bit 26), F2FP.BF16.F32.PACK_AB, 473 note ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS and .GPU (no dst vreg encodes RZ, presence slot 15). 474 note Constants by Wolfram: FromDigits of `0c001f00` 7f89 `000e0000` `000e2400` 723e 10ff `004fc400` 79a3 `80000000` 475 note `0c1f5300` `0c1ef300` `00321e00` base 16 = `201334528` 32649 917504 926720 29246 4351 `5227520` 31139 `2147483648` 476 note `203379456` `203354880` `3284480`. 477 note op 64 (Omega NG kernel traps, Hive NG D10): ATOMG.E.MIN.64.STRONG.SYS, ATOMG.E.ADD's words with w2 op bits 478 note 23..26 = 1 and type bits 9..11 = 2 (nvdisasm 13.0 SM121); no dst vreg encodes RZ. Wolfram: FromDigits of 79a8 479 note `089f5500` base 16 = 31144 `144659712`. 480 fn enc_e o view ulong 16 w edit ulong 4 to ulong 481 op = get o 0 482 if eq op 60 483 put4 w wda o 32649 or `201334528` shl and get o 6 31 21 917504 ctl o 926720 484 ret 0 485 end 486 if eq op 61 487 put4 w wda o 29246 rb o 3 4351 ctl o `5227520` 488 ret 0 489 end 490 if or eq op 62 eq op 63 491 s = ulong `203379456` 492 if eq op 63 493 s = `203354880` 494 end 495 a = or or 31139 shl rz o 1 15 16 shl rb o 2 24 496 put4 w a or rb o 3 `2147483648` or s rb o 5 ctl o `3284480` 497 ret 0 498 end 499 if eq op 64 500 a = or or 31144 shl rz o 1 15 16 shl rb o 2 24 501 put4 w a or rb o 3 `2147483648` or `144659712` rb o 5 ctl o `3284480` 502 ret 0 503 end 504 note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"7245","7305","`00201000`","`0020f000`","`004fe200`","`004e2200`"} 505 note -> {29253,29445,`2101248`,`2158592`,`5235200`,`5120512`}. 506 if eq op 65 507 put4 w wd o 29253 rb o 2 `2101248` ctl o `5235200` 508 ret 0 509 end 510 if eq op 66 511 put4 w wd o 29445 rb o 2 `2158592` ctl o `5120512` 512 ret 0 513 end 514 note Native half forms are the E1_CVT sm_121 fixtures in src/omega_numeric.c. 515 note Widening is HADD2.F32 Rd,-RZ,Ra.H0_H0; narrowing is F2F.F16.F32 Rd,Ra. 516 note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"`ff007230`","`20000000`","4100","7304","`00200800`","`010fca00`","`010e2800`"} 517 note -> {`4278219312`,`536870912`,16640,29444,`2099200`,`17811968`,`17704960`}. 518 if eq op 67 519 put4 w wd o `4278219312` or `536870912` rb o 2 16640 ctl o `17811968` 520 ret 0 521 end 522 if eq op 68 523 put4 w wd o 29444 rb o 2 `2099200` ctl o `17704960` 524 ret 0 525 end 526 ret 1 527 end 528 529 note IEEE binary64 register forms, independently derived using nvcc 13.0.88 sm_121 and nvdisasm. 530 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 531 note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"7229","7228","722b","722a","7308","1800","1c00","7310","301000","201800","7312","201c00","7311","30d100","`03f06000`","`000e2400`"} 532 note -> {29225,29224,29227,29226,29448,6144,7168,29456,`3149824`,`2103296`,29458,`2104320`,29457,`3199232`,`66084864`,926720}. 533 note R255 is RZ, not the upper half of a writable double pair. 534 fn dpair o view ulong 16 k ulong to ulong 535 r = get o k 536 if or ne and r 1 0 ge r 254 537 ret 0 538 end 539 ret 1 540 end 541 542 fn pick c bool a ulong b ulong to ulong 543 if c 544 ret a 545 end 546 ret b 547 end 548 549 fn enc_f o view ulong 16 w edit ulong 4 to ulong 550 op = get o 0 551 if gt op 79 552 ret 1 553 end 554 if le op 72 555 if eq and dpair o 2 dpair o 3 0 556 ret 1 557 end 558 if eq op 72 559 if ne get o 15 0 560 ret 1 561 end 562 put4 w wa o 29226 rb o 3 pick ne get o 6 0 get o 6 `66084864` ctl o 926720 563 ret 0 564 end 565 if eq dpair o 1 0 566 ret 1 567 end 568 if eq op 69 569 put4 w wda o 29225 0 rb o 3 ctl o 926720 570 ret 0 571 end 572 if eq op 70 573 put4 w wda o 29224 rb o 3 0 ctl o 926720 574 ret 0 575 end 576 if and ne get o 4 255 eq dpair o 4 0 577 ret 1 578 end 579 put4 w wda o 29227 rb o 3 rb o 4 ctl o 926720 580 ret 0 581 end 582 if le op 74 583 put4 w wd o 29448 rb o 2 pick eq op 73 6144 7168 ctl o 926720 584 ret 0 585 end 586 if or eq op 76 eq op 79 587 if eq dpair o 2 0 588 ret 1 589 end 590 else 591 if eq dpair o 1 0 592 ret 1 593 end 594 end 595 if le op 76 596 put4 w wd o 29456 rb o 2 pick eq op 75 `2103296` `3149824` ctl o 926720 597 ret 0 598 end 599 if le op 78 600 put4 w wd o 29458 rb o 2 pick eq op 77 `2104320` `2103296` ctl o 926720 601 ret 0 602 end 603 put4 w wd o 29457 rb o 2 `3199232` ctl o 926720 604 ret 0 605 end 606 607 fn encraw o view ulong 16 w edit ulong 4 to ulong 608 op = get o 0 609 if lt op 15 610 ret enc_a o w 611 end 612 if lt op 30 613 ret enc_b o w 614 end 615 if lt op 46 616 ret enc_c o w 617 end 618 if lt op 60 619 ret enc_d o w 620 end 621 if lt op 69 622 ret enc_e o w 623 end 624 ret enc_f o w 625 end 626 627 note A P0 guard is not a uniform guard: LDCU and LDCU.64 must refuse it (DRA-483). 628 note See PROVENANCE.md and guard_pred_test.om for the independent instruction oracle. 629 fn enc1 o view ulong 16 w edit ulong 4 to ulong 630 r = encraw o w 631 if or ne r 0 eq get o 9 0 632 ret r 633 end 634 op = get o 0 635 if isuld op 636 ret 1 637 end 638 x = get w 0 639 put w 0 or sub x and x 61440 shl pred o 12 640 ret 0 641 end 642 643 note the 16 bytes of instruction i, each word little-endian 644 fn store code edit uchar 16384 i ulong w view ulong 4 to void 645 for k ulong 4 646 x = get w k 647 q = add mul i 16 mul k 4 648 for j ulong 4 649 put code add q j uchar and shr x mul j 8 255 650 end 651 end 652 end 653 654 fn bw_enc_sm121 ins view ulong 8192 phys view ulong 288 n ulong pad ulong code edit uchar 16384 to ulong 655 o = new ulong 16 0 656 w = new ulong 4 0 657 if gt n 1024 658 ret 0 659 end 660 cnt = n 661 if ne pad 0 662 cnt = mul div add n 7 8 8 663 if lt cnt 32 664 cnt = 32 665 end 666 end 667 for i ulong cnt 668 if lt i n 669 opnds ins i phys edit o 670 if ne enc1 view o edit w 0 671 ret 0 672 end 673 else 674 put4 edit w NOPW 0 0 NOPC 675 end 676 store code i view w 677 end 678 ret mul cnt 16 679 end