From: Andrew Gerrand Date: Mon, 18 Nov 2013 01:40:54 +0000 (+1100) Subject: [release-branch.go1.2] doc/asm: more about SP, ARM R11 X-Git-Tag: go1.2rc5~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d8aa1bcbb57fc23c2aa77837f250090f6967067;p=gostls13.git [release-branch.go1.2] doc/asm: more about SP, ARM R11 ««« CL 26170043 / b1edf8faa5d6 doc/asm: more about SP, ARM R11 Also rename URL to /doc/asm. R=golang-dev, minux.ma, r CC=golang-dev https://golang.org/cl/26170043 »»» R=golang-dev CC=golang-dev https://golang.org/cl/28120043 --- diff --git a/doc/asm.html b/doc/asm.html index ba19700643..b855b9ef7a 100644 --- a/doc/asm.html +++ b/doc/asm.html @@ -1,6 +1,6 @@

A Quick Guide to Go's Assembler

@@ -113,12 +113,30 @@ is the name foo as an address in memory.

-The FP is a virtual frame pointer. +The FP pseudo-register is a virtual frame pointer +used to refer to function arguments. The compilers maintain a virtual frame pointer and refer to the arguments on the stack as offsets from that pseudo-register. Thus 0(FP) is the first argument to the function, 8(FP) is the second (on a 64-bit machine), and so on. -To refer to an argument by name, add the name to the numerical offset, like this: first_arg+0(FP). -The name in this syntax has no semantic value; think of it as a comment to the reader. +When referring to a function argument this way, it is conventional to place the name +at the beginning, as in first_arg+0(FP) and second_arg+8(FP). +Some of the assemblers enforce this convention, rejecting plain 0(FP) and 8(FP). +For assembly functions with Go prototypes, go vet will check that the argument names +and offsets match. +

+ +

+The SP pseudo-register is a virtual stack pointer +used to refer to frame-local variables and the arguments being +prepared for function calls. +It points to the top of the local stack frame, so references should use negative offsets +in the range [−framesize, 0): +x-8(SP), y-4(SP), and so on. +On architectures with a real register named SP, the name prefix distinguishes +references to the virtual stack pointer from references to the architectural SP register. +That is, x-8(SP) and -8(SP) are different memory locations: +the first refers to the virtual stack pointer pseudo-register, while the second refers to the +hardware's SP register.

@@ -358,11 +376,26 @@ MOVQ m(CX), BX // Move m into BX.

ARM

-The registers R9 and R10 are reserved by the -compiler and linker to point to the m (machine) and g +The registers R9, R10, and R11 +are reserved by the compiler and linker. +

+ +

+R9 and R10 point to the m (machine) and g (goroutine) structures, respectively. -Within assembler source code, these pointers -can be referred to as simply m and g. +Within assembler source code, these pointers must be referred to as m and g; +the names R9 and R10 are not recognized. +

+ +

+To make it easier for people and compilers to write assembly, the ARM linker +allows general addressing forms and pseudo-operations like DIV or MOD +that may not be expressible using a single hardware instruction. +It implements these forms as multiple instructions, often using the R11 register +to hold temporary values. +Hand-written assembly can use R11, but doing so requires +being sure that the linker is not also using it to implement any of the other +instructions in the function.

@@ -370,6 +403,10 @@ When defining a TEXT, specifying frame size $-4 tells the linker that this is a leaf function that does not need to save LR on entry.

+

+The name SP always refers to the virtual stack pointer described earlier. +For the hardware register, use R13. +

Unsupported opcodes

diff --git a/src/cmd/5a/doc.go b/src/cmd/5a/doc.go index 74d025fe2c..3e9e78fe6d 100644 --- a/src/cmd/5a/doc.go +++ b/src/cmd/5a/doc.go @@ -12,7 +12,7 @@ Go-specific considerations are documented at - http://golang.org/doc/asm.html + http://golang.org/doc/asm Its target architecture is the ARM, referred to by these tools as arm. diff --git a/src/cmd/6a/doc.go b/src/cmd/6a/doc.go index 9fdc6ed3a5..9f14cc0d05 100644 --- a/src/cmd/6a/doc.go +++ b/src/cmd/6a/doc.go @@ -12,9 +12,9 @@ Go-specific considerations are documented at - http://golang.org/doc/asm.html + http://golang.org/doc/asm -IIts target architecture is the x86-64, referred to by these tools as amd64. +Its target architecture is the x86-64, referred to by these tools as amd64. */ package main diff --git a/src/cmd/8a/doc.go b/src/cmd/8a/doc.go index bdf2fcfbb7..84c7254c80 100644 --- a/src/cmd/8a/doc.go +++ b/src/cmd/8a/doc.go @@ -12,7 +12,7 @@ Go-specific considerations are documented at - http://golang.org/doc/asm.html + http://golang.org/doc/asm I Its target architecture is the x86, referred to by these tools for historical reasons as 386.