Skip to content

Instantly share code, notes, and snippets.

@billglover
billglover / keybase.md
Created January 15, 2017 18:47
key base.io verification

Keybase proof

I hereby claim:

  • I am billglover on github.
  • I am billglover (https://keybase.io/billglover) on keybase.
  • I have a public key whose fingerprint is 8880 C31E 00BC 4F55 DB20 29D9 845F 3ED6 0173 678F

To claim this, I am signing this object:

@billglover
billglover / jsyk_bot_privacy.md
Created February 18, 2017 15:24
Privacy Policy for the JSYK Bot

This bot is for educational purposes. The only personal data that we retrieve from Facebook is the name of users who send messages to the bot. This data is used to personalise replies and we do not store this data or transmit it to third parties. The bot itself is hosted on AWS in Ireland and data retrieved may appear in diagnostic logs.

@billglover
billglover / example1.go
Created September 18, 2018 14:54
Increment an integer 1000 times
package main
func main() {
n := inc(1000)
println(n)
}
func inc(n int) int {
for i := 0; i < 1000; i++ {
n = n + 1
@billglover
billglover / example2.go
Created September 18, 2018 15:09
Increment an integer 1000 times (with a function call)
package main
func main() {
n := inc(1000)
println(n)
}
func inc(n int) int {
for i := 0; i < 1000; i++ {
n = add(n)
@billglover
billglover / example1.nasm
Created September 18, 2018 15:11
Increment an integer 1000 times
0x0000 00000 (inline.go:8) TEXT "".inc(SB), NOSPLIT, $0-16
0x0000 00000 (inline.go:8) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (inline.go:8) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (inline.go:8) FUNCDATA $3, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (inline.go:9) PCDATA $2, $0
0x0000 00000 (inline.go:9) PCDATA $0, $0
0x0000 00000 (inline.go:9) MOVQ "".n+8(SP), AX
0x0005 00005 (inline.go:9) XORL CX, CX
0x0007 00007 (inline.go:9) JMP 15
0x0009 00009 (inline.go:9) INCQ CX
@billglover
billglover / example1.nasm
Last active September 18, 2018 15:17
Increment an integer 1000 times
; inc(n int) int
00000 TEXT "".inc(SB), NOSPLIT, $0-16 ; function definition
00000 MOVQ "".n+8(SP), AX ; move parameter from stack to AX
00005 XORL CX, CX ; zero out register CX
00007 JMP 15 ; go to line 15
00009 INCQ CX ; increment register CX
00012 INCQ AX ; increment register AX
00015 CMPQ CX, $1000 ; compare register CX with 1000
00022 JLT 9 ; go to line 9
00024 MOVQ AX, "".~r1+16(SP) ; move AX to stack return value
@billglover
billglover / example2.nasm
Last active September 18, 2018 15:20
Increment an integer 1000 times (with a function call)
; inc(n int) int
00000 TEXT "".inc(SB), NOSPLIT, $0-16 ; function definition
00000 MOVQ "".n+8(SP), AX ; move parameter from stack to AX
00005 XORL CX, CX ; zero out register CX
00007 JMP 15 ; go to line 15
00009 INCQ CX ; increment register CX
00012 INCQ AX ; increment register AX
00015 CMPQ CX, $1000 ; compare register CX with 1000
00022 JLT 9 ; go to line 9
00024 MOVQ AX, "".~r1+16(SP) ; move AX to stack return value
@billglover
billglover / example2.go
Last active September 18, 2018 15:23
Increment an integer 1000 times (with a function call and no inlining)
package main
func main() {
n := inc(1000)
println(n)
}
func inc(n int) int {
for i := 0; i < 1000; i++ {
n = add(n)
@billglover
billglover / example2.nasm
Last active September 18, 2018 15:25
Increment an integer 1000 times (with a function call and no inlining)
; inc(n int) int
00000 TEXT "".inc(SB), $32-16 ; function definition
00000 MOVQ (TLS), CX ; move TLS to register CX
00009 CMPQ SP, 16(CX) ; compare SP with part of CX
00013 JLS 88 ; go to line 88 if 'less than'
00015 SUBQ $32, SP ; increase stack size by 32-bytes
00019 MOVQ BP, 24(SP) ; move BP to the stack
00024 LEAQ 24(SP), BP ; update BP to new location
; --- ---
00029 XORL AX, AX ; zero out register AX
// RemoteAddr allows HTTP servers and other software to record
// the network address that sent the request, usually for
// logging. This field is not filled in by ReadRequest and
// has no defined format. The HTTP server in this package
// sets RemoteAddr to an "IP:port" address before invoking a
// handler.
// This field is ignored by the HTTP client.
RemoteAddr string