1GBZ80(7) BSD Miscellaneous Information Manual GBZ80(7)
2
4 gbz80 — CPU opcode reference
5
7 This is the list of opcodes supported by rgbasm(1), including a short de‐
8 scription, the number of bytes needed to encode them and the number of
9 CPU cycles at 1MHz (or 2MHz in GBC dual speed mode) needed to complete
10 them.
11
12 Note: All arithmetic/logic operations that use register A as destination
13 can omit the destination as it is assumed to be register A by default.
14 The following two lines have the same effect:
15
16 OR A,B
17 OR B
18
20 List of abbreviations used in this document.
21
22 r8 Any of the 8-bit registers (A, B, C, D, E, H, L).
23
24 r16 Any of the general-purpose 16-bit registers (BC, DE, HL).
25
26 n8 8-bit integer constant.
27
28 n16 16-bit integer constant.
29
30 e8 8-bit offset (-128 to 127).
31
32 u3 3-bit unsigned integer constant (0 to 7).
33
34 cc Condition codes:
35 Z Execute if Z is set.
36 NZ Execute if Z is not set.
37 C Execute if C is set.
38 NC Execute if C is not set.
39
40 vec One of the RST vectors (0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30
41 and 0x38).
42
44 8-bit Arithmetic and Logic Instructions
45 ADC A,r8
46 ADC A,[HL]
47 ADC A,n8
48 ADD A,r8
49 ADD A,[HL]
50 ADD A,n8
51 AND A,r8
52 AND A,[HL]
53 AND A,n8
54 CP A,r8
55 CP A,[HL]
56 CP A,n8
57 DEC r8
58 DEC [HL]
59 INC r8
60 INC [HL]
61 OR A,r8
62 OR A,[HL]
63 OR A,n8
64 SBC A,r8
65 SBC A,[HL]
66 SBC A,n8
67 SUB A,r8
68 SUB A,[HL]
69 SUB A,n8
70 XOR A,r8
71 XOR A,[HL]
72 XOR A,n8
73
74 16-bit Arithmetic Instructions
75 ADD HL,r16
76 DEC r16
77 INC r16
78
79 Bit Operations Instructions
80 BIT u3,r8
81 BIT u3,[HL]
82 RES u3,r8
83 RES u3,[HL]
84 SET u3,r8
85 SET u3,[HL]
86 SWAP r8
87 SWAP [HL]
88
89 Bit Shift Instructions
90 RL r8
91 RL [HL]
92 RLA
93 RLC r8
94 RLC [HL]
95 RLCA
96 RR r8
97 RR [HL]
98 RRA
99 RRC r8
100 RRC [HL]
101 RRCA
102 SLA r8
103 SLA [HL]
104 SRA r8
105 SRA [HL]
106 SRL r8
107 SRL [HL]
108
109 Load Instructions
110 LD r8,r8
111 LD r8,n8
112 LD r16,n16
113 LD [HL],r8
114 LD [HL],n8
115 LD r8,[HL]
116 LD [r16],A
117 LD [n16],A
118 LDH [n16],A
119 LDH [C],A
120 LD A,[r16]
121 LD A,[n16]
122 LDH A,[n16]
123 LDH A,[C]
124 LD [HLI],A
125 LD [HLD],A
126 LD A,[HLI]
127 LD A,[HLD]
128
129 Jumps and Subroutines
130 CALL n16
131 CALL cc,n16
132 JP HL
133 JP n16
134 JP cc,n16
135 JR e8
136 JR cc,e8
137 RET cc
138 RET
139 RETI
140 RST vec
141
142 Stack Operations Instructions
143 ADD HL,SP
144 ADD SP,e8
145 DEC SP
146 INC SP
147 LD SP,n16
148 LD [n16],SP
149 LD HL,SP+e8
150 LD SP,HL
151 POP AF
152 POP r16
153 PUSH AF
154 PUSH r16
155
156 Miscellaneous Instructions
157 CCF
158 CPL
159 DAA
160 DI
161 EI
162 HALT
163 NOP
164 SCF
165 STOP
166
168 ADC A,r8
169 Add the value in r8 plus the carry flag to A.
170
171 Cycles: 1
172
173 Bytes: 1
174
175 Flags:
176 Z Set if result is 0.
177 N 0
178 H Set if overflow from bit 3.
179 C Set if overflow from bit 7.
180
181 ADC A,[HL]
182 Add the byte pointed to by HL plus the carry flag to A.
183
184 Cycles: 2
185
186 Bytes: 1
187
188 Flags: See ADC A,r8
189
190 ADC A,n8
191 Add the value n8 plus the carry flag to A.
192
193 Cycles: 2
194
195 Bytes: 2
196
197 Flags: See ADC A,r8
198
199 ADD A,r8
200 Add the value in r8 to A.
201
202 Cycles: 1
203
204 Bytes: 1
205
206 Flags:
207 Z Set if result is 0.
208 N 0
209 H Set if overflow from bit 3.
210 C Set if overflow from bit 7.
211
212 ADD A,[HL]
213 Add the byte pointed to by HL to A.
214
215 Cycles: 2
216
217 Bytes: 1
218
219 Flags: See ADD A,r8
220
221 ADD A,n8
222 Add the value n8 to A.
223
224 Cycles: 2
225
226 Bytes: 2
227
228 Flags: See ADD A,r8
229
230 ADD HL,r16
231 Add the value in r16 to HL.
232
233 Cycles: 2
234
235 Bytes: 1
236
237 Flags:
238 N 0
239 H Set if overflow from bit 11.
240 C Set if overflow from bit 15.
241
242 ADD HL,SP
243 Add the value in SP to HL.
244
245 Cycles: 2
246
247 Bytes: 1
248
249 Flags: See ADD HL,r16
250
251 ADD SP,e8
252 Add the signed value e8 to SP.
253
254 Cycles: 4
255
256 Bytes: 2
257
258 Flags:
259 Z 0
260 N 0
261 H Set if overflow from bit 3.
262 C Set if overflow from bit 7.
263
264 AND A,r8
265 Bitwise AND between the value in r8 and A.
266
267 Cycles: 1
268
269 Bytes: 1
270
271 Flags:
272 Z Set if result is 0.
273 N 0
274 H 1
275 C 0
276
277 AND A,[HL]
278 Bitwise AND between the byte pointed to by HL and A.
279
280 Cycles: 2
281
282 Bytes: 1
283
284 Flags: See AND A,r8
285
286 AND A,n8
287 Bitwise AND between the value in n8 and A.
288
289 Cycles: 2
290
291 Bytes: 2
292
293 Flags: See AND A,r8
294
295 BIT u3,r8
296 Test bit u3 in register r8, set the zero flag if bit not set.
297
298 Cycles: 2
299
300 Bytes: 2
301
302 Flags:
303 Z Set if the selected bit is 0.
304 N 0
305 H 1
306
307 BIT u3,[HL]
308 Test bit u3 in the byte pointed by HL, set the zero flag if bit not set.
309
310 Cycles: 3
311
312 Bytes: 2
313
314 Flags: See BIT u3,r8
315
316 CALL n16
317 Call address n16. This pushes the address of the instruction after the
318 CALL on the stack, such that RET can pop it later; then, it executes an
319 implicit JP n16.
320
321 Cycles: 6
322
323 Bytes: 3
324
325 Flags: None affected.
326
327 CALL cc,n16
328 Call address n16 if condition cc is met.
329
330 Cycles: 6 taken / 3 untaken
331
332 Bytes: 3
333
334 Flags: None affected.
335
336 CCF
337 Complement Carry Flag.
338
339 Cycles: 1
340
341 Bytes: 1
342
343 Flags:
344 N 0
345 H 0
346 C Inverted.
347
348 CP A,r8
349 Subtract the value in r8 from A and set flags accordingly, but don't
350 store the result. This is useful for ComParing values.
351
352 Cycles: 1
353
354 Bytes: 1
355
356 Flags:
357 Z Set if result is 0.
358 N 1
359 H Set if borrow from bit 4.
360 C Set if borrow (i.e. if r8 > A).
361
362 CP A,[HL]
363 Subtract the byte pointed to by HL from A and set flags accordingly, but
364 don't store the result.
365
366 Cycles: 2
367
368 Bytes: 1
369
370 Flags: See CP A,r8
371
372 CP A,n8
373 Subtract the value n8 from A and set flags accordingly, but don't store
374 the result.
375
376 Cycles: 2
377
378 Bytes: 2
379
380 Flags: See CP A,r8
381
382 CPL
383 ComPLement accumulator (A = ~A).
384
385 Cycles: 1
386
387 Bytes: 1
388
389 Flags:
390 N 1
391 H 1
392
393 DAA
394 Decimal Adjust Accumulator to get a correct BCD representation after an
395 arithmetic instruction.
396
397 Cycles: 1
398
399 Bytes: 1
400
401 Flags:
402 Z Set if result is 0.
403 H 0
404 C Set or reset depending on the operation.
405
406 DEC r8
407 Decrement value in register r8 by 1.
408
409 Cycles: 1
410
411 Bytes: 1
412
413 Flags:
414 Z Set if result is 0.
415 N 1
416 H Set if borrow from bit 4.
417
418 DEC [HL]
419 Decrement the byte pointed to by HL by 1.
420
421 Cycles: 3
422
423 Bytes: 1
424
425 Flags: See DEC r8
426
427 DEC r16
428 Decrement value in register r16 by 1.
429
430 Cycles: 2
431
432 Bytes: 1
433
434 Flags: None affected.
435
436 DEC SP
437 Decrement value in register SP by 1.
438
439 Cycles: 2
440
441 Bytes: 1
442
443 Flags: None affected.
444
445 DI
446 Disable Interrupts by clearing the IME flag.
447
448 Cycles: 1
449
450 Bytes: 1
451
452 Flags: None affected.
453
454 EI
455 Enable Interrupts by setting the IME flag. The flag is only set after
456 the instruction following EI.
457
458 Cycles: 1
459
460 Bytes: 1
461
462 Flags: None affected.
463
464 HALT
465 Enter CPU low-power consumption mode until an interrupt occurs. The ex‐
466 act behavior of this instruction depends on the state of the IME flag.
467
468 IME set
469 The CPU enters low-power mode until after an interrupt is about
470 to be serviced. The handler is executed normally, and the CPU
471 resumes execution after the HALT when that returns.
472
473 IME not set
474 The behavior depends on whether an interrupt is pending (i.e.
475 ‘[IE] & [IF]’ is non-zero).
476
477 None pending
478 As soon as an interrupt becomes pending, the CPU resumes
479 execution. This is like the above, except that the han‐
480 dler is not called.
481
482 Some pending
483 The CPU continues execution after the HALT, but the byte
484 after it is read twice in a row (PC is not incremented,
485 due to a hardware bug).
486
487 Cycles: -
488
489 Bytes: 1
490
491 Flags: None affected.
492
493 INC r8
494 Increment value in register r8 by 1.
495
496 Cycles: 1
497
498 Bytes: 1
499
500 Flags:
501 Z Set if result is 0.
502 N 0
503 H Set if overflow from bit 3.
504
505 INC [HL]
506 Increment the byte pointed to by HL by 1.
507
508 Cycles: 3
509
510 Bytes: 1
511
512 Flags: See INC r8
513
514 INC r16
515 Increment value in register r16 by 1.
516
517 Cycles: 2
518
519 Bytes: 1
520
521 Flags: None affected.
522
523 INC SP
524 Increment value in register SP by 1.
525
526 Cycles: 2
527
528 Bytes: 1
529
530 Flags: None affected.
531
532 JP n16
533 Jump to address n16; effectively, store n16 into PC.
534
535 Cycles: 4
536
537 Bytes: 3
538
539 Flags: None affected.
540
541 JP cc,n16
542 Jump to address n16 if condition cc is met.
543
544 Cycles: 4 taken / 3 untaken
545
546 Bytes: 3
547
548 Flags: None affected.
549
550 JP HL
551 Jump to address in HL; effectively, load PC with value in register HL.
552
553 Cycles: 1
554
555 Bytes: 1
556
557 Flags: None affected.
558
559 JR e8
560 Relative Jump by adding e8 to the address of the instruction following
561 the JR. To clarify, an operand of 0 is equivalent to no jumping.
562
563 Cycles: 3
564
565 Bytes: 2
566
567 Flags: None affected.
568
569 JR cc,e8
570 Relative Jump by adding e8 to the current address if condition cc is met.
571
572 Cycles: 3 taken / 2 untaken
573
574 Bytes: 2
575
576 Flags: None affected.
577
578 LD r8,r8
579 Load (copy) value in register on the right into register on the left.
580
581 Cycles: 1
582
583 Bytes: 1
584
585 Flags: None affected.
586
587 LD r8,n8
588 Load value n8 into register r8.
589
590 Cycles: 2
591
592 Bytes: 2
593
594 Flags: None affected.
595
596 LD r16,n16
597 Load value n16 into register r16.
598
599 Cycles: 3
600
601 Bytes: 3
602
603 Flags: None affected.
604
605 LD [HL],r8
606 Store value in register r8 into byte pointed to by register HL.
607
608 Cycles: 2
609
610 Bytes: 1
611
612 Flags: None affected.
613
614 LD [HL],n8
615 Store value n8 into byte pointed to by register HL.
616
617 Cycles: 3
618
619 Bytes: 2
620
621 Flags: None affected.
622
623 LD r8,[HL]
624 Load value into register r8 from byte pointed to by register HL.
625
626 Cycles: 2
627
628 Bytes: 1
629
630 Flags: None affected.
631
632 LD [r16],A
633 Store value in register A into byte pointed to by register r16.
634
635 Cycles: 2
636
637 Bytes: 1
638
639 Flags: None affected.
640
641 LD [n16],A
642 Store value in register A into byte at address n16.
643
644 Cycles: 4
645
646 Bytes: 3
647
648 Flags: None affected.
649
650 LDH [n16],A
651 Store value in register A into byte at address n16, provided it is be‐
652 tween $FF00 and $FFFF.
653
654 Cycles: 3
655
656 Bytes: 2
657
658 Flags: None affected.
659
660 This is sometimes written as ‘LDIO [n16],A’, or ‘LD [$FF00+n8],A’.
661
662 LDH [C],A
663 Store value in register A into byte at address $FF00+C.
664
665 Cycles: 2
666
667 Bytes: 1
668
669 Flags: None affected.
670
671 This is sometimes written as ‘LDIO [C],A’, or ‘LD [$FF00+C],A’.
672
673 LD A,[r16]
674 Load value in register A from byte pointed to by register r16.
675
676 Cycles: 2
677
678 Bytes: 1
679
680 Flags: None affected.
681
682 LD A,[n16]
683 Load value in register A from byte at address n16.
684
685 Cycles: 4
686
687 Bytes: 3
688
689 Flags: None affected.
690
691 LDH A,[n16]
692 Load value in register A from byte at address n16, provided it is between
693 $FF00 and $FFFF.
694
695 Cycles: 3
696
697 Bytes: 2
698
699 Flags: None affected.
700
701 This is sometimes written as ‘LDIO A,[n16]’, or ‘LD A,[$FF00+n8]’.
702
703 LDH A,[C]
704 Load value in register A from byte at address $FF00+c.
705
706 Cycles: 2
707
708 Bytes: 1
709
710 Flags: None affected.
711
712 This is sometimes written as ‘LDIO A,[C]’, or ‘LD A,[$FF00+C]’.
713
714 LD [HLI],A
715 Store value in register A into byte pointed by HL and increment HL after‐
716 wards.
717
718 Cycles: 2
719
720 Bytes: 1
721
722 Flags: None affected.
723
724 This is sometimes written as ‘LD [HL+],A’, or ‘LDI [HL],A’.
725
726 LD [HLD],A
727 Store value in register A into byte pointed by HL and decrement HL after‐
728 wards.
729
730 Cycles: 2
731
732 Bytes: 1
733
734 Flags: None affected.
735
736 This is sometimes written as ‘LD [HL-],A’, or ‘LDD [HL],A’.
737
738 LD A,[HLD]
739 Load value into register A from byte pointed by HL and decrement HL af‐
740 terwards.
741
742 Cycles: 2
743
744 Bytes: 1
745
746 Flags: None affected.
747
748 This is sometimes written as ‘LD A,[HL-]’, or ‘LDD A,[HL]’.
749
750 LD A,[HLI]
751 Load value into register A from byte pointed by HL and increment HL af‐
752 terwards.
753
754 Cycles: 2
755
756 Bytes: 1
757
758 Flags: None affected.
759
760 This is sometimes written as ‘LD A,[HL+],’, or ‘LDI A,[HL]’.
761
762 LD SP,n16
763 Load value n16 into register SP.
764
765 Cycles: 3
766
767 Bytes: 3
768
769 Flags: None affected.
770
771 LD [n16],SP
772 Store SP & $FF at address n16 and SP >> 8 at address n16 + 1.
773
774 Cycles: 5
775
776 Bytes: 3
777
778 Flags: None affected.
779
780 LD HL,SP+e8
781 Add the signed value e8 to SP and store the result in HL.
782
783 Cycles: 3
784
785 Bytes: 2
786
787 Flags:
788 Z 0
789 N 0
790 H Set if overflow from bit 3.
791 C Set if overflow from bit 7.
792
793 LD SP,HL
794 Load register HL into register SP.
795
796 Cycles: 2
797
798 Bytes: 1
799
800 Flags: None affected.
801
802 NOP
803 No OPeration.
804
805 Cycles: 1
806
807 Bytes: 1
808
809 Flags: None affected.
810
811 OR A,r8
812 Store into A the bitwise OR of the value in r8 and A.
813
814 Cycles: 1
815
816 Bytes: 1
817
818 Flags:
819 Z Set if result is 0.
820 N 0
821 H 0
822 C 0
823
824 OR A,[HL]
825 Store into A the bitwise OR of the byte pointed to by HL and A.
826
827 Cycles: 2
828
829 Bytes: 1
830
831 Flags: See OR A,r8
832
833 OR A,n8
834 Store into A the bitwise OR of n8 and A.
835
836 Cycles: 2
837
838 Bytes: 2
839
840 Flags: See OR A,r8
841
842 POP AF
843 Pop register AF from the stack. This is roughly equivalent to the fol‐
844 lowing imaginary instructions:
845
846 ld f, [sp] ; See below for individual flags
847 inc sp
848 ld a, [sp]
849 inc sp
850
851 Cycles: 3
852
853 Bytes: 1
854
855 Flags:
856 Z Set from bit 7 of the popped low byte.
857 N Set from bit 6 of the popped low byte.
858 H Set from bit 5 of the popped low byte.
859 C Set from bit 4 of the popped low byte.
860
861 POP r16
862 Pop register r16 from the stack. This is roughly equivalent to the fol‐
863 lowing imaginary instructions:
864
865 ld LOW(r16), [sp] ; C, E or L
866 inc sp
867 ld HIGH(r16), [sp] ; B, D or H
868 inc sp
869
870 Cycles: 3
871
872 Bytes: 1
873
874 Flags: None affected.
875
876 PUSH AF
877 Push register AF into the stack. This is roughly equivalent to the fol‐
878 lowing imaginary instructions:
879
880 dec sp
881 ld [sp], a
882 dec sp
883 ld [sp], flag_Z << 7 | flag_N << 6 | flag_H << 5 | flag_C << 4
884
885 Cycles: 4
886
887 Bytes: 1
888
889 Flags: None affected.
890
891 PUSH r16
892 Push register r16 into the stack. This is roughly equivalent to the fol‐
893 lowing imaginary instructions:
894
895 dec sp
896 ld [sp], HIGH(r16) ; B, D or H
897 dec sp
898 ld [sp], LOW(r16) ; C, E or L
899
900 Cycles: 4
901
902 Bytes: 1
903
904 Flags: None affected.
905
906 RES u3,r8
907 Set bit u3 in register r8 to 0. Bit 0 is the rightmost one, bit 7 the
908 leftmost one.
909
910 Cycles: 2
911
912 Bytes: 2
913
914 Flags: None affected.
915
916 RES u3,[HL]
917 Set bit u3 in the byte pointed by HL to 0. Bit 0 is the rightmost one,
918 bit 7 the leftmost one.
919
920 Cycles: 4
921
922 Bytes: 2
923
924 Flags: None affected.
925
926 RET
927 Return from subroutine. This is basically a POP PC (if such an instruc‐
928 tion existed). See POP r16 for an explanation of how POP works.
929
930 Cycles: 4
931
932 Bytes: 1
933
934 Flags: None affected.
935
936 RET cc
937 Return from subroutine if condition cc is met.
938
939 Cycles: 5 taken / 2 untaken
940
941 Bytes: 1
942
943 Flags: None affected.
944
945 RETI
946 Return from subroutine and enable interrupts. This is basically equiva‐
947 lent to executing EI then RET, meaning that IME is set right after this
948 instruction.
949
950 Cycles: 4
951
952 Bytes: 1
953
954 Flags: None affected.
955
956 RL r8
957 Rotate bits in register r8 left through carry.
958
959 C <- [7 <- 0] <- C
960
961 Cycles: 2
962
963 Bytes: 2
964
965 Flags:
966 Z Set if result is 0.
967 N 0
968 H 0
969 C Set according to result.
970
971 RL [HL]
972 Rotate byte pointed to by HL left through carry.
973
974 C <- [7 <- 0] <- C
975
976 Cycles: 4
977
978 Bytes: 2
979
980 Flags: See RL r8
981
982 RLA
983 Rotate register A left through carry.
984
985 C <- [7 <- 0] <- C
986
987 Cycles: 1
988
989 Bytes: 1
990
991 Flags:
992 Z 0
993 N 0
994 H 0
995 C Set according to result.
996
997 RLC r8
998 Rotate register r8 left.
999
1000 C <- [7 <- 0] <- [7]
1001
1002 Cycles: 2
1003
1004 Bytes: 2
1005
1006 Flags:
1007 Z Set if result is 0.
1008 N 0
1009 H 0
1010 C Set according to result.
1011
1012 RLC [HL]
1013 Rotate byte pointed to by HL left.
1014
1015 C <- [7 <- 0] <- [7]
1016
1017 Cycles: 4
1018
1019 Bytes: 2
1020
1021 Flags: See RLC r8
1022
1023 RLCA
1024 Rotate register A left.
1025
1026 C <- [7 <- 0] <- [7]
1027
1028 Cycles: 1
1029
1030 Bytes: 1
1031
1032 Flags:
1033 Z 0
1034 N 0
1035 H 0
1036 C Set according to result.
1037
1038 RR r8
1039 Rotate register r8 right through carry.
1040
1041 C -> [7 -> 0] -> C
1042
1043 Cycles: 2
1044
1045 Bytes: 2
1046
1047 Flags:
1048 Z Set if result is 0.
1049 N 0
1050 H 0
1051 C Set according to result.
1052
1053 RR [HL]
1054 Rotate byte pointed to by HL right through carry.
1055
1056 C -> [7 -> 0] -> C
1057
1058 Cycles: 4
1059
1060 Bytes: 2
1061
1062 Flags: See RR r8
1063
1064 RRA
1065 Rotate register A right through carry.
1066
1067 C -> [7 -> 0] -> C
1068
1069 Cycles: 1
1070
1071 Bytes: 1
1072
1073 Flags:
1074 Z 0
1075 N 0
1076 H 0
1077 C Set according to result.
1078
1079 RRC r8
1080 Rotate register r8 right.
1081
1082 [0] -> [7 -> 0] -> C
1083
1084 Cycles: 2
1085
1086 Bytes: 2
1087
1088 Flags:
1089 Z Set if result is 0.
1090 N 0
1091 H 0
1092 C Set according to result.
1093
1094 RRC [HL]
1095 Rotate byte pointed to by HL right.
1096
1097 [0] -> [7 -> 0] -> C
1098
1099 Cycles: 4
1100
1101 Bytes: 2
1102
1103 Flags: See RRC r8
1104
1105 RRCA
1106 Rotate register A right.
1107
1108 [0] -> [7 -> 0] -> C
1109
1110 Cycles: 1
1111
1112 Bytes: 1
1113
1114 Flags:
1115 Z 0
1116 N 0
1117 H 0
1118 C Set according to result.
1119
1120 RST vec
1121 Call address vec. This is a shorter and faster equivalent to CALL for
1122 suitable values of vec.
1123
1124 Cycles: 4
1125
1126 Bytes: 1
1127
1128 Flags: None affected.
1129
1130 SBC A,r8
1131 Subtract the value in r8 and the carry flag from A.
1132
1133 Cycles: 1
1134
1135 Bytes: 1
1136
1137 Flags:
1138 Z Set if result is 0.
1139 N 1
1140 H Set if borrow from bit 4.
1141 C Set if borrow (i.e. if (r8 + carry) > A).
1142
1143 SBC A,[HL]
1144 Subtract the byte pointed to by HL and the carry flag from A.
1145
1146 Cycles: 2
1147
1148 Bytes: 1
1149
1150 Flags: See SBC A,r8
1151
1152 SBC A,n8
1153 Subtract the value n8 and the carry flag from A.
1154
1155 Cycles: 2
1156
1157 Bytes: 2
1158
1159 Flags: See SBC A,r8
1160
1161 SCF
1162 Set Carry Flag.
1163
1164 Cycles: 1
1165
1166 Bytes: 1
1167
1168 Flags:
1169 N 0
1170 H 0
1171 C 1
1172
1173 SET u3,r8
1174 Set bit u3 in register r8 to 1. Bit 0 is the rightmost one, bit 7 the
1175 leftmost one.
1176
1177 Cycles: 2
1178
1179 Bytes: 2
1180
1181 Flags: None affected.
1182
1183 SET u3,[HL]
1184 Set bit u3 in the byte pointed by HL to 1. Bit 0 is the rightmost one,
1185 bit 7 the leftmost one.
1186
1187 Cycles: 4
1188
1189 Bytes: 2
1190
1191 Flags: None affected.
1192
1193 SLA r8
1194 Shift Left Arithmetic register r8.
1195
1196 C <- [7 <- 0] <- 0
1197
1198 Cycles: 2
1199
1200 Bytes: 2
1201
1202 Flags:
1203 Z Set if result is 0.
1204 N 0
1205 H 0
1206 C Set according to result.
1207
1208 SLA [HL]
1209 Shift Left Arithmetic byte pointed to by HL.
1210
1211 C <- [7 <- 0] <- 0
1212
1213 Cycles: 4
1214
1215 Bytes: 2
1216
1217 Flags: See SLA r8
1218
1219 SRA r8
1220 Shift Right Arithmetic register r8.
1221
1222 [7] -> [7 -> 0] -> C
1223
1224 Cycles: 2
1225
1226 Bytes: 2
1227
1228 Flags:
1229 Z Set if result is 0.
1230 N 0
1231 H 0
1232 C Set according to result.
1233
1234 SRA [HL]
1235 Shift Right Arithmetic byte pointed to by HL.
1236
1237 [7] -> [7 -> 0] -> C
1238
1239 Cycles: 4
1240
1241 Bytes: 2
1242
1243 Flags: See SRA r8
1244
1245 SRL r8
1246 Shift Right Logic register r8.
1247
1248 0 -> [7 -> 0] -> C
1249
1250 Cycles: 2
1251
1252 Bytes: 2
1253
1254 Flags:
1255 Z Set if result is 0.
1256 N 0
1257 H 0
1258 C Set according to result.
1259
1260 SRL [HL]
1261 Shift Right Logic byte pointed to by HL.
1262
1263 0 -> [7 -> 0] -> C
1264
1265 Cycles: 4
1266
1267 Bytes: 2
1268
1269 Flags: See SRA r8
1270
1271 STOP
1272 Enter CPU very low power mode. Also used to switch between double and
1273 normal speed CPU modes in GBC.
1274
1275 Cycles: -
1276
1277 Bytes: 2
1278
1279 Flags: None affected.
1280
1281 SUB A,r8
1282 Subtract the value in r8 from A.
1283
1284 Cycles: 1
1285
1286 Bytes: 1
1287
1288 Flags:
1289 Z Set if result is 0.
1290 N 1
1291 H Set if borrow from bit 4.
1292 C Set if borrow (set if r8 > A).
1293
1294 SUB A,[HL]
1295 Subtract the byte pointed to by HL from A.
1296
1297 Cycles: 2
1298
1299 Bytes: 1
1300
1301 Flags: See SUB A,r8
1302
1303 SUB A,n8
1304 Subtract the value n8 from A.
1305
1306 Cycles: 2
1307
1308 Bytes: 2
1309
1310 Flags: See SUB A,r8
1311
1312 SWAP r8
1313 Swap upper 4 bits in register r8 and the lower 4 ones.
1314
1315 Cycles: 2
1316
1317 Bytes: 2
1318
1319 Flags:
1320 Z Set if result is 0.
1321 N 0
1322 H 0
1323 C 0
1324
1325 SWAP [HL]
1326 Swap upper 4 bits in the byte pointed by HL and the lower 4 ones.
1327
1328 Cycles: 4
1329
1330 Bytes: 2
1331
1332 Flags: See SWAP r8
1333
1334 XOR A,r8
1335 Bitwise XOR between the value in r8 and A.
1336
1337 Cycles: 1
1338
1339 Bytes: 1
1340
1341 Flags:
1342 Z Set if result is 0.
1343 N 0
1344 H 0
1345 C 0
1346
1347 XOR A,[HL]
1348 Bitwise XOR between the byte pointed to by HL and A.
1349
1350 Cycles: 2
1351
1352 Bytes: 1
1353
1354 Flags: See XOR A,r8
1355
1356 XOR A,n8
1357 Bitwise XOR between the value in n8 and A.
1358
1359 Cycles: 2
1360
1361 Bytes: 2
1362
1363 Flags: See XOR A,r8
1364
1366 rgbasm(1), rgbds(7)
1367
1369 rgbds was originally written by Carsten Sørensen as part of the ASMotor
1370 package, and was later packaged in RGBDS by Justin Lloyd. It is now
1371 maintained by a number of contributors at https://github.com/gbdev/rgbds
1372
1373BSD March 28, 2021 BSD