Skip to content

Commit 1f7691a

Browse files
committed
Add not instruction.
1 parent 283d5de commit 1f7691a

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

langs/a86/ast.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
(instruct Push (a1) check:push)
150150
(instruct Pop (a1) check:register)
151151
(instruct Lea (dst x) check:lea)
152+
(instruct Not (x) check:register)
152153
(instruct Div (den) check:register)
153154

154155
(instruct Offset (r i) check:offset)
@@ -217,6 +218,7 @@
217218
(Push? x)
218219
(Pop? x)
219220
(Lea? x)
221+
(Not? x)
220222
(Div? x)
221223
(Comment? x)
222224
(Equ? x)

langs/a86/printer.rkt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@
170170
(string-append tab "lea "
171171
(arg->string d) ", [rel "
172172
(exp->string x) "]")]
173+
[(Not r)
174+
(string-append tab "not "
175+
(reg->string r))]
173176
[(Div r)
174177
(string-append tab "div "
175178
(arg->string r))]

www/notes/a86.scrbl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,20 @@ Each register plays the same role as in x86, so for example
12161216
]
12171217
}
12181218

1219+
@defstruct*[Not ([a1 register?])]{
1220+
Perform bitwise not operation (each 1 is set to 0, and each 0 is set to 1) on the destination operand.
1221+
1222+
@ex[
1223+
(asm-interp
1224+
(prog
1225+
(Global 'entry)
1226+
(Label 'entry)
1227+
(Mov 'rax 0)
1228+
(Not 'rax)
1229+
(Ret)))
1230+
]
1231+
}
1232+
12191233
@defstruct*[Lea ([dst (or/c register? offset?)] [x label?])]{
12201234
Loads the address of the given label into @racket[dst].
12211235

0 commit comments

Comments
 (0)