debug: fix (*Architecture).IntN

Change-Id: I68ba29f3a7d06095a779f6b010d74d5ac9008c49
Reviewed-on: https://go-review.googlesource.com/1841
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/ogle/arch/arch.go b/ogle/arch/arch.go
index 90fd5f4..0d5b53e 100644
--- a/ogle/arch/arch.go
+++ b/ogle/arch/arch.go
@@ -66,7 +66,25 @@
 }
 
 func (a *Architecture) IntN(buf []byte) int64 {
-	return int64(a.UintN(buf))
+	if len(buf) == 0 {
+		return 0
+	}
+	x := int64(0)
+	if a.ByteOrder == binary.LittleEndian {
+		i := len(buf)-1
+		x = int64(int8(buf[i]))  // sign-extended
+		for i--; i >= 0; i-- {
+			x <<= 8
+			x |= int64(buf[i])  // not sign-extended
+		}
+	} else {
+		x = int64(int8(buf[0]))    // sign-extended
+		for i := 1; i < len(buf); i++ {
+			x <<= 8
+			x |= int64(buf[i])  // not sign-extended
+		}
+	}
+	return x
 }
 
 func (a *Architecture) UintN(buf []byte) uint64 {