Skip to content

Instantly share code, notes, and snippets.

@mnakama
Last active March 22, 2021 21:56
Show Gist options
  • Save mnakama/91e925e8f55e4c09072c3bc3f09bb372 to your computer and use it in GitHub Desktop.
Save mnakama/91e925e8f55e4c09072c3bc3f09bb372 to your computer and use it in GitHub Desktop.
very strange Go assembly output
# command-line-arguments
"".main STEXT size=687 args=0x0 locals=0xa0 funcid=0x0
0x0000 00000 (bintest-if.go:8) TEXT "".main(SB), ABIInternal, $160-0
0x0000 00000 (bintest-if.go:8) MOVQ (TLS), CX
0x0009 00009 (bintest-if.go:8) LEAQ -32(SP), AX
0x000e 00014 (bintest-if.go:8) CMPQ AX, 16(CX)
0x0012 00018 (bintest-if.go:8) PCDATA $0, $-2
0x0012 00018 (bintest-if.go:8) JLS 677
0x0018 00024 (bintest-if.go:8) PCDATA $0, $-1
0x0018 00024 (bintest-if.go:8) SUBQ $160, SP
0x001f 00031 (bintest-if.go:8) MOVQ BP, 152(SP)
0x0027 00039 (bintest-if.go:8) LEAQ 152(SP), BP
0x002f 00047 (bintest-if.go:8) FUNCDATA $0, gclocals·3e27b3aa6b89137cce48b3379a2a6610(SB)
0x002f 00047 (bintest-if.go:8) FUNCDATA $1, gclocals·c55ab1d011ad8a6dd16a7a45d623cada(SB)
0x002f 00047 (bintest-if.go:8) FUNCDATA $2, "".main.stkobj(SB)
0x002f 00047 (bintest-if.go:9) LEAQ type.bool(SB), AX
0x0036 00054 (bintest-if.go:9) MOVQ AX, (SP)
0x003a 00058 (bintest-if.go:9) MOVQ $8, 8(SP)
0x0043 00067 (bintest-if.go:9) MOVQ $8, 16(SP)
0x004c 00076 (bintest-if.go:9) PCDATA $1, $0
0x004c 00076 (bintest-if.go:9) CALL runtime.makeslice(SB)
0x0051 00081 (bintest-if.go:9) MOVQ 24(SP), AX
0x0056 00086 (bintest-if.go:9) MOVQ AX, ""..autotmp_23+96(SP)
0x005b 00091 (bintest-if.go:11) LEAQ go.string."v"(SB), CX
0x0062 00098 (bintest-if.go:11) MOVQ CX, (SP)
0x0066 00102 (bintest-if.go:11) MOVQ $1, 8(SP)
0x006f 00111 (bintest-if.go:11) MOVQ $0, 16(SP)
0x0078 00120 (bintest-if.go:11) LEAQ go.string."flags to extract"(SB), CX
0x007f 00127 (bintest-if.go:11) MOVQ CX, 24(SP)
0x0084 00132 (bintest-if.go:11) MOVQ $16, 32(SP)
0x008d 00141 (bintest-if.go:11) PCDATA $1, $1
0x008d 00141 (bintest-if.go:11) CALL flag.Uint(SB)
0x0092 00146 (bintest-if.go:11) MOVQ 40(SP), AX
0x0097 00151 (bintest-if.go:11) MOVQ AX, "".num+88(SP)
0x009c 00156 (bintest-if.go:13) PCDATA $1, $2
0x009c 00156 (bintest-if.go:13) NOP
0x00a0 00160 (bintest-if.go:13) CALL flag.Parse(SB)
0x00a5 00165 (bintest-if.go:15) MOVQ "".num+88(SP), AX
0x00aa 00170 (bintest-if.go:15) MOVQ (AX), AX
0x00ad 00173 (bintest-if.go:15) MOVQ AX, ""..autotmp_24+80(SP)
0x00b2 00178 (bintest-if.go:16) XORPS X0, X0
0x00b5 00181 (bintest-if.go:16) MOVUPS X0, ""..autotmp_6+104(SP)
0x00ba 00186 (bintest-if.go:16) LEAQ type.uint8(SB), CX
0x00c1 00193 (bintest-if.go:16) MOVQ CX, ""..autotmp_6+104(SP)
0x00c6 00198 (bintest-if.go:16) MOVBLZX AL, CX
0x00c9 00201 (bintest-if.go:16) LEAQ runtime.staticuint64s(SB), DX
0x00d0 00208 (bintest-if.go:16) LEAQ (DX)(CX*8), CX
0x00d4 00212 (bintest-if.go:16) MOVQ CX, ""..autotmp_6+112(SP)
0x00d9 00217 (bintest-if.go:16) LEAQ go.string."val: %b\n"(SB), CX
0x00e0 00224 (bintest-if.go:16) MOVQ CX, (SP)
0x00e4 00228 (bintest-if.go:16) MOVQ $8, 8(SP)
0x00ed 00237 (bintest-if.go:16) LEAQ ""..autotmp_6+104(SP), CX
0x00f2 00242 (bintest-if.go:16) MOVQ CX, 16(SP)
0x00f7 00247 (bintest-if.go:16) MOVQ $1, 24(SP)
0x0100 00256 (bintest-if.go:16) MOVQ $1, 32(SP)
0x0109 00265 (bintest-if.go:16) PCDATA $1, $1
0x0109 00265 (bintest-if.go:16) CALL fmt.Printf(SB)
0x010e 00270 (bintest-if.go:19) MOVQ ""..autotmp_24+80(SP), AX
0x0113 00275 (bintest-if.go:19) TESTB $1, AL
0x0115 00277 (bintest-if.go:19) JEQ 666 <- A. this jumps to the end of the code (B)
0x011b 00283 (bintest-if.go:20) MOVQ ""..autotmp_23+96(SP), CX <- this line gets repeated at (B) because we skip it here?
0x0120 00288 (bintest-if.go:20) MOVB $1, (CX) <- this is the only thing we actually need to skip
0x0123 00291 (bintest-if.go:22) TESTB $2, AL <- C. and then it jumps back to here
0x0125 00293 (bintest-if.go:22) JEQ 299
0x0127 00295 (bintest-if.go:23) MOVB $1, 1(CX)
0x012b 00299 (bintest-if.go:25) TESTB $4, AL
0x012d 00301 (bintest-if.go:25) JEQ 307
0x012f 00303 (bintest-if.go:26) MOVB $1, 2(CX)
0x0133 00307 (bintest-if.go:28) TESTB $8, AL
0x0135 00309 (bintest-if.go:28) JEQ 315
0x0137 00311 (bintest-if.go:29) MOVB $1, 3(CX)
0x013b 00315 (bintest-if.go:31) TESTB $16, AL
0x013d 00317 (bintest-if.go:31) JEQ 323
0x013f 00319 (bintest-if.go:32) MOVB $1, 4(CX)
0x0143 00323 (bintest-if.go:34) TESTB $32, AL
0x0145 00325 (bintest-if.go:34) JEQ 331
0x0147 00327 (bintest-if.go:35) MOVB $1, 5(CX)
0x014b 00331 (bintest-if.go:37) TESTB $64, AL
0x014d 00333 (bintest-if.go:37) JEQ 339
0x014f 00335 (bintest-if.go:38) MOVB $1, 6(CX)
0x0153 00339 (bintest-if.go:40) TESTB $-128, AL
0x0155 00341 (bintest-if.go:40) JEQ 347
0x0157 00343 (bintest-if.go:41) MOVB $1, 7(CX)
0x015b 00347 (bintest-if.go:44) XORPS X0, X0
0x015e 00350 (bintest-if.go:44) MOVUPS X0, ""..autotmp_6+104(SP)
0x0163 00355 (bintest-if.go:44) MOVQ CX, (SP)
0x0167 00359 (bintest-if.go:44) MOVQ $8, 8(SP)
0x0170 00368 (bintest-if.go:44) MOVQ $8, 16(SP)
0x0179 00377 (bintest-if.go:44) PCDATA $1, $3
0x0179 00377 (bintest-if.go:44) CALL runtime.convTslice(SB)
0x017e 00382 (bintest-if.go:44) MOVQ 24(SP), AX
0x0183 00387 (bintest-if.go:44) LEAQ type.[]bool(SB), CX
0x018a 00394 (bintest-if.go:44) MOVQ CX, ""..autotmp_6+104(SP)
0x018f 00399 (bintest-if.go:44) MOVQ AX, ""..autotmp_6+112(SP)
0x0194 00404 (bintest-if.go:44) LEAQ go.string."result: %v\n"(SB), AX
0x019b 00411 (bintest-if.go:44) MOVQ AX, (SP)
0x019f 00415 (bintest-if.go:44) MOVQ $11, 8(SP)
0x01a8 00424 (bintest-if.go:44) LEAQ ""..autotmp_6+104(SP), AX
0x01ad 00429 (bintest-if.go:44) MOVQ AX, 16(SP)
0x01b2 00434 (bintest-if.go:44) MOVQ $1, 24(SP)
0x01bb 00443 (bintest-if.go:44) MOVQ $1, 32(SP)
0x01c4 00452 (bintest-if.go:44) PCDATA $1, $1
0x01c4 00452 (bintest-if.go:44) CALL fmt.Printf(SB)
0x01c9 00457 (bintest-if.go:8) XORL AX, AX
0x01cb 00459 (bintest-if.go:46) JMP 640
0x01d0 00464 (bintest-if.go:46) MOVQ AX, "".i+64(SP)
0x01d5 00469 (bintest-if.go:46) MOVQ ""..autotmp_23+96(SP), CX
0x01da 00474 (bintest-if.go:46) MOVBLZX (CX)(AX*1), DX
0x01de 00478 (bintest-if.go:46) MOVQ DX, ""..autotmp_25+72(SP)
0x01e3 00483 (bintest-if.go:47) XORPS X0, X0
0x01e6 00486 (bintest-if.go:47) MOVUPS X0, ""..autotmp_9+120(SP)
0x01eb 00491 (bintest-if.go:47) MOVUPS X0, ""..autotmp_9+136(SP)
0x01f3 00499 (bintest-if.go:47) MOVQ AX, (SP)
0x01f7 00503 (bintest-if.go:47) PCDATA $1, $4
0x01f7 00503 (bintest-if.go:47) CALL runtime.convT64(SB)
0x01fc 00508 (bintest-if.go:47) MOVQ 8(SP), AX
0x0201 00513 (bintest-if.go:47) LEAQ type.int(SB), CX
0x0208 00520 (bintest-if.go:47) MOVQ CX, ""..autotmp_9+120(SP)
0x020d 00525 (bintest-if.go:47) MOVQ AX, ""..autotmp_9+128(SP)
0x0215 00533 (bintest-if.go:47) LEAQ type.bool(SB), AX
0x021c 00540 (bintest-if.go:47) MOVQ AX, ""..autotmp_9+136(SP)
0x0224 00548 (bintest-if.go:47) MOVQ ""..autotmp_25+72(SP), DX
0x0229 00553 (bintest-if.go:47) LEAQ runtime.staticuint64s(SB), BX
0x0230 00560 (bintest-if.go:47) LEAQ (BX)(DX*8), DX
0x0234 00564 (bintest-if.go:47) MOVQ DX, ""..autotmp_9+144(SP)
0x023c 00572 (bintest-if.go:47) LEAQ go.string."result %d: %t\n"(SB), DX
0x0243 00579 (bintest-if.go:47) MOVQ DX, (SP)
0x0247 00583 (bintest-if.go:47) MOVQ $14, 8(SP)
0x0250 00592 (bintest-if.go:47) LEAQ ""..autotmp_9+120(SP), SI
0x0255 00597 (bintest-if.go:47) MOVQ SI, 16(SP)
0x025a 00602 (bintest-if.go:47) MOVQ $2, 24(SP)
0x0263 00611 (bintest-if.go:47) MOVQ $2, 32(SP)
0x026c 00620 (bintest-if.go:47) PCDATA $1, $1
0x026c 00620 (bintest-if.go:47) CALL fmt.Printf(SB)
0x0271 00625 (bintest-if.go:46) MOVQ "".i+64(SP), AX
0x0276 00630 (bintest-if.go:46) INCQ AX
0x0279 00633 (bintest-if.go:46) NOP
0x0280 00640 (bintest-if.go:46) CMPQ AX, $8
0x0284 00644 (bintest-if.go:46) JLT 464
0x028a 00650 (bintest-if.go:46) PCDATA $1, $-1
0x028a 00650 (bintest-if.go:46) MOVQ 152(SP), BP
0x0292 00658 (bintest-if.go:46) ADDQ $160, SP
0x0299 00665 (bintest-if.go:46) RET
0x029a 00666 (bintest-if.go:23) MOVQ ""..autotmp_23+96(SP), CX <- this assignment was skipped over, but repeated here???
0x029f 00671 (bintest-if.go:23) NOP <- a NOP... for some reason?
0x02a0 00672 (bintest-if.go:19) JMP 291 <- jump back to (C)
0x02a5 00677 (bintest-if.go:19) NOP
0x02a5 00677 (bintest-if.go:8) PCDATA $1, $-1
0x02a5 00677 (bintest-if.go:8) PCDATA $0, $-2
0x02a5 00677 (bintest-if.go:8) CALL runtime.morestack_noctxt(SB)
0x02aa 00682 (bintest-if.go:8) PCDATA $0, $-1
0x02aa 00682 (bintest-if.go:8) JMP 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment