Created
June 30, 2017 04:53
-
-
Save freeformz/fd02e7771865d0e36e59cd78e568e5e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00135 (main.go:29) TEXT "".oopsy(SB) | |
00136 (main.go:29) FUNCDATA $0, "".gcargs·6(SB) | |
00137 (main.go:29) FUNCDATA $1, "".gclocals·7(SB) | |
00138 (main.go:29) TYPE s(FP), type.[]int(SB) | |
00139 (main.go:29) TYPE .autotmp_18-8(SP), type.int(SB) | |
00140 (main.go:29) TYPE i-16(SP), type.int(SB) | |
00141 (main.go:30) MOVQ $0, AX // AX = 0 | |
00142 (main.go:34) MOVQ "".s+8(FP), CX // CX = 6 (len of the slice) | |
00143 (main.go:30) MOVQ AX, "".i-16(SP) // i = 0 | |
00144 (main.go:34) MOVQ CX, ""..autotmp_18-8(SP) // autotmp_18 = 6 | |
00145 (main.go:30) MOVQ "".s+8(FP), DX // DX = 6 (len of the slice) | |
00146 (main.go:30) CMPQ AX, DX // compare AX (0) to DX (6) and if they're equal jump to 170 (final print and RET) | |
00147 (main.go:30) JGE $0, 170 | |
00148 (main.go:31) MOVQ "".s+16(FP), CX // CX = 6 (capacity of slice) | |
00149 (main.go:31) CMPQ CX, $2 // compare CX (6) to 2 and if < jump to 168 (panicslice) | |
00150 (main.go:31) JCS $0, 168 | |
00151 (main.go:32) CMPQ AX, $2 // compare AX (0) to 2 and if == jump to 166 (panicindex) | |
00152 (main.go:32) JCC $0, 166 | |
00153 (main.go:32) MOVQ "".s(FP), BX // BX = address of underlying array | |
00154 (main.go:32) MOVQ (BX)(AX*8), SI // SI = 6 (first value of underlying array, (BX)(AX*8) indexes to it since AX = 0 | |
00155 (main.go:32) MOVQ SI, ""..autotmp_18-8(SP) . // autotmp_18 = 6 | |
00156 (main.go:32) CALL runtime.printlock(SB) // setup and print | |
00157 (main.go:32) MOVQ ""..autotmp_18-8(SP), AX | |
00158 (main.go:32) MOVQ AX, (SP) | |
00159 (main.go:32) CALL runtime.printint(SB) | |
00160 (main.go:32) CALL runtime.printnl(SB) | |
00161 (main.go:32) CALL runtime.printunlock(SB) // done printing | |
00162 (main.go:30) MOVQ "".i-16(SP), AX // AX = 0 | |
00163 (main.go:30) INCQ AX // AX = 1 | |
00164 (main.go:31) MOVQ $2, CX // CX = 2 | |
00165 (main.go:30) JMP 143 . // Go to the top of the loop (see below) | |
00166 (main.go:32) CALL runtime.panicindex(SB) | |
00167 (main.go:32) UNDEF | |
00168 (main.go:31) CALL runtime.panicslice(SB) | |
00169 (main.go:31) UNDEF | |
00170 (main.go:34) CALL runtime.printlock(SB) | |
00171 (main.go:34) MOVQ "".s(FP), AX | |
00172 (main.go:34) MOVQ AX, (SP) | |
00173 (main.go:34) MOVQ ""..autotmp_18-8(SP), AX | |
00174 (main.go:34) MOVQ AX, 8(SP) | |
00175 (main.go:34) MOVQ "".s+16(FP), AX | |
00176 (main.go:34) MOVQ AX, 16(SP) | |
00177 (main.go:34) CALL runtime.printslice(SB) | |
00178 (main.go:34) CALL runtime.printnl(SB) | |
00179 (main.go:34) CALL runtime.printunlock(SB) | |
00180 (main.go:35) RET | |
00181 (<unknown line number>) END | |
Pass #2 AX=1 , CX = 2 | |
00143 (main.go:30) MOVQ AX, "".i-16(SP) // i = 1 | |
00144 (main.go:34) MOVQ CX, ""..autotmp_18-8(SP) // autotmp_18 = 2 | |
00145 (main.go:30) MOVQ "".s+8(FP), DX // DX = 6 (len of the slice) | |
00146 (main.go:30) CMPQ AX, DX // compare AX (1) to DX (6) and if they're equal jump to 170 (final print and RET) | |
00147 (main.go:30) JGE $0, 170 | |
00148 (main.go:31) MOVQ "".s+16(FP), CX // CX = 6 (capacity of slice) | |
00149 (main.go:31) CMPQ CX, $2 // compare CX (6) to 2 and if < jump to 168 (panicslice) | |
00150 (main.go:31) JCS $0, 168 | |
00151 (main.go:32) CMPQ AX, $2 // compare AX (1) to 2 and if == jump to 166 (panicindex) | |
00152 (main.go:32) JCC $0, 166 | |
00153 (main.go:32) MOVQ "".s(FP), BX // BX = address of underlying array | |
00154 (main.go:32) MOVQ (BX)(AX*8), SI // SI = 5 (2nd value of underlying array, (BX)(AX*8) indexes to it since AX = 1 | |
00155 (main.go:32) MOVQ SI, ""..autotmp_18-8(SP) . // autotmp_18 = 5 | |
00156 (main.go:32) CALL runtime.printlock(SB) // setup and print | |
00157 (main.go:32) MOVQ ""..autotmp_18-8(SP), AX | |
00158 (main.go:32) MOVQ AX, (SP) | |
00159 (main.go:32) CALL runtime.printint(SB) | |
00160 (main.go:32) CALL runtime.printnl(SB) | |
00161 (main.go:32) CALL runtime.printunlock(SB) // done printing | |
00162 (main.go:30) MOVQ "".i-16(SP), AX // AX = 1 | |
00163 (main.go:30) INCQ AX // AX = 2 | |
00164 (main.go:31) MOVQ $2, CX // CX = 2 | |
00165 (main.go:30) JMP 143 . // Go to the top of the loop (see below) | |
Pass #3 AX=2 , CX = 2 | |
00143 (main.go:30) MOVQ AX, "".i-16(SP) // i = 2 | |
00144 (main.go:34) MOVQ CX, ""..autotmp_18-8(SP) // autotmp_18 = 2 | |
00145 (main.go:30) MOVQ "".s+8(FP), DX // DX = 6 (len of the slice) | |
00146 (main.go:30) CMPQ AX, DX // compare AX (2) to DX (6) and if they're equal jump to 170 (final print and RET) | |
00147 (main.go:30) JGE $0, 170 | |
00148 (main.go:31) MOVQ "".s+16(FP), CX // CX = 6 (capacity of slice) | |
00149 (main.go:31) CMPQ CX, $2 // compare CX (6) to 2 and if < jump to 168 (panicslice) | |
00150 (main.go:31) JCS $0, 168 | |
00151 (main.go:32) CMPQ AX, $2 // compare AX (2) to 2 and if == jump to 166 (panicindex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code for the other function:

Which is similar to: https://play.golang.org/p/k5a73PHaka