Skip to content

Commit 6892ac5

Browse files
committed
add 'loop' instr
1 parent 83a0342 commit 6892ac5

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

impl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,13 @@ DEF(jr) {
239239
vmnext;
240240
}
241241

242+
DEF(loop) {
243+
if (rgA != 0) {
244+
rgA--;
245+
pc += imm19s;
246+
util_checkpc();
247+
}
248+
vmnext;
249+
}
250+
242251
#endif /* impl.h */

opcodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ DEF(dec, 34) /* [M] rgA = rgA - 1 */
5656
DEF(swp, 35) /* [I] rgA, rgB = rgB, rgA */
5757
DEF(adr, 36) /* [M] rgA = pc + imm19s */
5858
DEF(jr, 37) /* [M] pc = rgA */
59+
DEF(loop, 38) /* [M] if (rgA-- != 0) pc += imm19s */
5960

6061
#endif /* opcodes.h */

test/cnt_1bill

20 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)