Skip to content

Commit 8a5f0f0

Browse files
committed
Some notes on sign extensions in a86 docs.
1 parent b39a8e0 commit 8a5f0f0

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

www/notes/a86.scrbl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ Each register plays the same role as in x86, so for example
943943
An addition instruction. Adds @racket[src] to @racket[dst]
944944
and writes the result to @racket[dst].
945945

946+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
947+
946948
@ex[
947949
(asm-interp
948950
(prog
@@ -959,6 +961,8 @@ Each register plays the same role as in x86, so for example
959961
A subtraction instruction. Subtracts @racket[src] frrom
960962
@racket[dst] and writes the result to @racket[dst].
961963

964+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
965+
962966
@ex[
963967
(asm-interp
964968
(prog
@@ -974,6 +978,8 @@ Each register plays the same role as in x86, so for example
974978
Compare @racket[a1] to @racket[a2]. Doing a comparison
975979
sets the status flags that affect the conditional instructions like @racket[Je], @racket[Jl], etc.
976980

981+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
982+
977983
@ex[
978984
(asm-interp
979985
(prog
@@ -1448,6 +1454,8 @@ Each register plays the same role as in x86, so for example
14481454

14491455
Compute logical ``and'' of @racket[dst] and @racket[src] and put result in @racket[dst].
14501456

1457+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
1458+
14511459
@#reader scribble/comment-reader
14521460
(ex
14531461
(asm-interp
@@ -1463,6 +1471,8 @@ Each register plays the same role as in x86, so for example
14631471
@defstruct*[Or ([dst (or/c register? offset?)] [src (or/c register? offset? 32-bit-integer?)])]{
14641472
Compute logical ``or'' of @racket[dst] and @racket[src] and put result in @racket[dst].
14651473

1474+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
1475+
14661476
@#reader scribble/comment-reader
14671477
(ex
14681478
(asm-interp
@@ -1478,6 +1488,8 @@ Each register plays the same role as in x86, so for example
14781488
@defstruct*[Xor ([dst (or/c register? offset?)] [src (or/c register? offset? 32-bit-integer?)])]{
14791489
Compute logical ``exclusive or'' of @racket[dst] and @racket[src] and put result in @racket[dst].
14801490

1491+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
1492+
14811493
@#reader scribble/comment-reader
14821494
(ex
14831495
(asm-interp
@@ -1508,7 +1520,8 @@ Each register plays the same role as in x86, so for example
15081520

15091521
@defstruct*[Sar ([dst register?] [i (integer-in 0 63)])]{
15101522
Shift @racket[dst] to the right @racket[i] bits and put result in @racket[dst].
1511-
The rightmost bits are discarded.
1523+
The rightmost bits are discarded. The added leftmost bits are filled with the
1524+
sign bit of the original.
15121525

15131526
@#reader scribble/comment-reader
15141527
(ex
@@ -1535,6 +1548,8 @@ Each register plays the same role as in x86, so for example
15351548
Decrements the stack pointer and then stores the source
15361549
operand on the top of the stack.
15371550

1551+
In the case of a 32-bit immediate, it is sign-extended to 64-bits.
1552+
15381553
@ex[
15391554
(asm-interp
15401555
(prog

0 commit comments

Comments
 (0)