1GBZ80(7)             BSD Miscellaneous Information Manual             GBZ80(7)
2

NAME

4     gbz80 — CPU opcode reference
5

DESCRIPTION

7     This is the list of opcodes supported by rgbasm(1), including a short
8     description, 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

LEGEND

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,
41                   0x30 and 0x38).
42

INSTRUCTION OVERVIEW

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

INSTRUCTION REFERENCE

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
466     exact 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
652     between $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   LD [HLD],A
725     Store value in register A into byte pointed by HL and decrement HL after‐
726     wards.
727
728     Cycles: 2
729
730     Bytes: 1
731
732     Flags: None affected.
733
734   LD A,[HLD]
735     Load value into register A from byte pointed by HL and decrement HL
736     afterwards.
737
738     Cycles: 2
739
740     Bytes: 1
741
742     Flags: None affected.
743
744   LD A,[HLI]
745     Load value into register A from byte pointed by HL and increment HL
746     afterwards.
747
748     Cycles: 2
749
750     Bytes: 1
751
752     Flags: None affected.
753
754   LD SP,n16
755     Load value n16 into register SP.
756
757     Cycles: 3
758
759     Bytes: 3
760
761     Flags: None affected.
762
763   LD [n16],SP
764     Store SP & $FF at address n16 and SP >> 8 at address n16 + 1.
765
766     Cycles: 5
767
768     Bytes: 3
769
770     Flags: None affected.
771
772   LD HL,SP+e8
773     Add the signed value e8 to SP and store the result in HL.
774
775     Cycles: 3
776
777     Bytes: 2
778
779     Flags:
780     Z       0
781     N       0
782     H       Set if overflow from bit 3.
783     C       Set if overflow from bit 7.
784
785   LD SP,HL
786     Load register HL into register SP.
787
788     Cycles: 2
789
790     Bytes: 1
791
792     Flags: None affected.
793
794   NOP
795     No OPeration.
796
797     Cycles: 1
798
799     Bytes: 1
800
801     Flags: None affected.
802
803   OR A,r8
804     Store into A the bitwise OR of the value in r8 and A.
805
806     Cycles: 1
807
808     Bytes: 1
809
810     Flags:
811     Z       Set if result is 0.
812     N       0
813     H       0
814     C       0
815
816   OR A,[HL]
817     Store into A the bitwise OR of the byte pointed to by HL and A.
818
819     Cycles: 2
820
821     Bytes: 1
822
823     Flags: See OR A,r8
824
825   OR A,n8
826     Store into A the bitwise OR of n8 and A.
827
828     Cycles: 2
829
830     Bytes: 2
831
832     Flags: See OR A,r8
833
834   POP AF
835     Pop register AF from the stack.  This is roughly equivalent to the fol‐
836     lowing imaginary instructions:
837
838           ld f, [sp] ; See below for individual flags
839           inc sp
840           ld a, [sp]
841           inc sp
842
843     Cycles: 3
844
845     Bytes: 1
846
847     Flags:
848     Z       Set from bit 7 of the popped low byte.
849     N       Set from bit 6 of the popped low byte.
850     H       Set from bit 5 of the popped low byte.
851     C       Set from bit 4 of the popped low byte.
852
853   POP r16
854     Pop register r16 from the stack.  This is roughly equivalent to the fol‐
855     lowing imaginary instructions:
856
857           ld LOW(r16), [sp] ; C, E or L
858           inc sp
859           ld HIGH(r16), [sp] ; B, D or H
860           inc sp
861
862     Cycles: 3
863
864     Bytes: 1
865
866     Flags: None affected.
867
868   PUSH AF
869     Push register AF into the stack.  This is roughly equivalent to the fol‐
870     lowing imaginary instructions:
871
872           dec sp
873           ld [sp], a
874           dec sp
875           ld [sp], flag_Z << 7 | flag_N << 6 | flag_H << 5 | flag_C << 4
876
877     Cycles: 4
878
879     Bytes: 1
880
881     Flags: None affected.
882
883   PUSH r16
884     Push register r16 into the stack.  This is roughly equivalent to the fol‐
885     lowing imaginary instructions:
886
887           dec sp
888           ld [sp], HIGH(r16) ; B, D or H
889           dec sp
890           ld [sp], LOW(r16) ; C, E or L
891
892     Cycles: 4
893
894     Bytes: 1
895
896     Flags: None affected.
897
898   RES u3,r8
899     Set bit u3 in register r8 to 0.  Bit 0 is the rightmost one, bit 7 the
900     leftmost one.
901
902     Cycles: 2
903
904     Bytes: 2
905
906     Flags: None affected.
907
908   RES u3,[HL]
909     Set bit u3 in the byte pointed by HL to 0.  Bit 0 is the rightmost one,
910     bit 7 the leftmost one.
911
912     Cycles: 4
913
914     Bytes: 2
915
916     Flags: None affected.
917
918   RET
919     Return from subroutine.  This is basically a POP PC (if such an instruc‐
920     tion existed).  See POP r16 for an explanation of how POP works.
921
922     Cycles: 4
923
924     Bytes: 1
925
926     Flags: None affected.
927
928   RET cc
929     Return from subroutine if condition cc is met.
930
931     Cycles: 5 taken / 2 untaken
932
933     Bytes: 1
934
935     Flags: None affected.
936
937   RETI
938     Return from subroutine and enable interrupts.  This is basically equiva‐
939     lent to executing EI then RET, meaning that IME is set right after this
940     instruction.
941
942     Cycles: 4
943
944     Bytes: 1
945
946     Flags: None affected.
947
948   RL r8
949     Rotate bits in register r8 left through carry.
950
951           C <- [7 <- 0] <- C
952
953     Cycles: 2
954
955     Bytes: 2
956
957     Flags:
958     Z       Set if result is 0.
959     N       0
960     H       0
961     C       Set according to result.
962
963   RL [HL]
964     Rotate byte pointed to by HL left through carry.
965
966           C <- [7 <- 0] <- C
967
968     Cycles: 4
969
970     Bytes: 2
971
972     Flags: See RL r8
973
974   RLA
975     Rotate register A left through carry.
976
977           C <- [7 <- 0] <- C
978
979     Cycles: 1
980
981     Bytes: 1
982
983     Flags:
984     Z       0
985     N       0
986     H       0
987     C       Set according to result.
988
989   RLC r8
990     Rotate register r8 left.
991
992           C <- [7 <- 0] <- [7]
993
994     Cycles: 2
995
996     Bytes: 2
997
998     Flags:
999     Z       Set if result is 0.
1000     N       0
1001     H       0
1002     C       Set according to result.
1003
1004   RLC [HL]
1005     Rotate byte pointed to by HL left.
1006
1007           C <- [7 <- 0] <- [7]
1008
1009     Cycles: 4
1010
1011     Bytes: 2
1012
1013     Flags: See RLC r8
1014
1015   RLCA
1016     Rotate register A left.
1017
1018           C <- [7 <- 0] <- [7]
1019
1020     Cycles: 1
1021
1022     Bytes: 1
1023
1024     Flags:
1025     Z       0
1026     N       0
1027     H       0
1028     C       Set according to result.
1029
1030   RR r8
1031     Rotate register r8 right through carry.
1032
1033           C -> [7 -> 0] -> C
1034
1035     Cycles: 2
1036
1037     Bytes: 2
1038
1039     Flags:
1040     Z       Set if result is 0.
1041     N       0
1042     H       0
1043     C       Set according to result.
1044
1045   RR [HL]
1046     Rotate byte pointed to by HL right through carry.
1047
1048           C -> [7 -> 0] -> C
1049
1050     Cycles: 4
1051
1052     Bytes: 2
1053
1054     Flags: See RR r8
1055
1056   RRA
1057     Rotate register A right through carry.
1058
1059           C -> [7 -> 0] -> C
1060
1061     Cycles: 1
1062
1063     Bytes: 1
1064
1065     Flags:
1066     Z       0
1067     N       0
1068     H       0
1069     C       Set according to result.
1070
1071   RRC r8
1072     Rotate register r8 right.
1073
1074           [0] -> [7 -> 0] -> C
1075
1076     Cycles: 2
1077
1078     Bytes: 2
1079
1080     Flags:
1081     Z       Set if result is 0.
1082     N       0
1083     H       0
1084     C       Set according to result.
1085
1086   RRC [HL]
1087     Rotate byte pointed to by HL right.
1088
1089           [0] -> [7 -> 0] -> C
1090
1091     Cycles: 4
1092
1093     Bytes: 2
1094
1095     Flags: See RRC r8
1096
1097   RRCA
1098     Rotate register A right.
1099
1100           [0] -> [7 -> 0] -> C
1101
1102     Cycles: 1
1103
1104     Bytes: 1
1105
1106     Flags:
1107     Z       0
1108     N       0
1109     H       0
1110     C       Set according to result.
1111
1112   RST vec
1113     Call address vec.  This is a shorter and faster equivalent to CALL for
1114     suitable values of vec.
1115
1116     Cycles: 4
1117
1118     Bytes: 1
1119
1120     Flags: None affected.
1121
1122   SBC A,r8
1123     Subtract the value in r8 and the carry flag from A.
1124
1125     Cycles: 1
1126
1127     Bytes: 1
1128
1129     Flags:
1130     Z       Set if result is 0.
1131     N       1
1132     H       Set if borrow from bit 4.
1133     C       Set if borrow (i.e. if (r8 + carry) > A).
1134
1135   SBC A,[HL]
1136     Subtract the byte pointed to by HL and the carry flag from A.
1137
1138     Cycles: 2
1139
1140     Bytes: 1
1141
1142     Flags: See SBC A,r8
1143
1144   SBC A,n8
1145     Subtract the value n8 and the carry flag from A.
1146
1147     Cycles: 2
1148
1149     Bytes: 2
1150
1151     Flags: See SBC A,r8
1152
1153   SCF
1154     Set Carry Flag.
1155
1156     Cycles: 1
1157
1158     Bytes: 1
1159
1160     Flags:
1161     N       0
1162     H       0
1163     C       1
1164
1165   SET u3,r8
1166     Set bit u3 in register r8 to 1.  Bit 0 is the rightmost one, bit 7 the
1167     leftmost one.
1168
1169     Cycles: 2
1170
1171     Bytes: 2
1172
1173     Flags: None affected.
1174
1175   SET u3,[HL]
1176     Set bit u3 in the byte pointed by HL to 1.  Bit 0 is the rightmost one,
1177     bit 7 the leftmost one.
1178
1179     Cycles: 4
1180
1181     Bytes: 2
1182
1183     Flags: None affected.
1184
1185   SLA r8
1186     Shift Left Arithmetic register r8.
1187
1188           C <- [7 <- 0] <- 0
1189
1190     Cycles: 2
1191
1192     Bytes: 2
1193
1194     Flags:
1195     Z       Set if result is 0.
1196     N       0
1197     H       0
1198     C       Set according to result.
1199
1200   SLA [HL]
1201     Shift Left Arithmetic byte pointed to by HL.
1202
1203           C <- [7 <- 0] <- 0
1204
1205     Cycles: 4
1206
1207     Bytes: 2
1208
1209     Flags: See SLA r8
1210
1211   SRA r8
1212     Shift Right Arithmetic register r8.
1213
1214           [7] -> [7 -> 0] -> C
1215
1216     Cycles: 2
1217
1218     Bytes: 2
1219
1220     Flags:
1221     Z       Set if result is 0.
1222     N       0
1223     H       0
1224     C       Set according to result.
1225
1226   SRA [HL]
1227     Shift Right Arithmetic byte pointed to by HL.
1228
1229           [7] -> [7 -> 0] -> C
1230
1231     Cycles: 4
1232
1233     Bytes: 2
1234
1235     Flags: See SRA r8
1236
1237   SRL r8
1238     Shift Right Logic register r8.
1239
1240           0 -> [7 -> 0] -> C
1241
1242     Cycles: 2
1243
1244     Bytes: 2
1245
1246     Flags:
1247     Z       Set if result is 0.
1248     N       0
1249     H       0
1250     C       Set according to result.
1251
1252   SRL [HL]
1253     Shift Right Logic byte pointed to by HL.
1254
1255           0 -> [7 -> 0] -> C
1256
1257     Cycles: 4
1258
1259     Bytes: 2
1260
1261     Flags: See SRA r8
1262
1263   STOP
1264     Enter CPU very low power mode.  Also used to switch between double and
1265     normal speed CPU modes in GBC.
1266
1267     Cycles: -
1268
1269     Bytes: 2
1270
1271     Flags: None affected.
1272
1273   SUB A,r8
1274     Subtract the value in r8 from A.
1275
1276     Cycles: 1
1277
1278     Bytes: 1
1279
1280     Flags:
1281     Z       Set if result is 0.
1282     N       1
1283     H       Set if borrow from bit 4.
1284     C       Set if borrow (set if r8 > A).
1285
1286   SUB A,[HL]
1287     Subtract the byte pointed to by HL from A.
1288
1289     Cycles: 2
1290
1291     Bytes: 1
1292
1293     Flags: See SUB A,r8
1294
1295   SUB A,n8
1296     Subtract the value n8 from A.
1297
1298     Cycles: 2
1299
1300     Bytes: 2
1301
1302     Flags: See SUB A,r8
1303
1304   SWAP r8
1305     Swap upper 4 bits in register r8 and the lower 4 ones.
1306
1307     Cycles: 2
1308
1309     Bytes: 2
1310
1311     Flags:
1312     Z       Set if result is 0.
1313     N       0
1314     H       0
1315     C       0
1316
1317   SWAP [HL]
1318     Swap upper 4 bits in the byte pointed by HL and the lower 4 ones.
1319
1320     Cycles: 4
1321
1322     Bytes: 2
1323
1324     Flags: See SWAP r8
1325
1326   XOR A,r8
1327     Bitwise XOR between the value in r8 and A.
1328
1329     Cycles: 1
1330
1331     Bytes: 1
1332
1333     Flags:
1334     Z       Set if result is 0.
1335     N       0
1336     H       0
1337     C       0
1338
1339   XOR A,[HL]
1340     Bitwise XOR between the byte pointed to by HL and A.
1341
1342     Cycles: 2
1343
1344     Bytes: 1
1345
1346     Flags: See XOR A,r8
1347
1348   XOR A,n8
1349     Bitwise XOR between the value in n8 and A.
1350
1351     Cycles: 2
1352
1353     Bytes: 2
1354
1355     Flags: See XOR A,r8
1356

SEE ALSO

1358     rgbasm(1), rgbds(7)
1359

HISTORY

1361     rgbds was originally written by Carsten Sørensen as part of the ASMotor
1362     package, and was later packaged in RGBDS by Justin Lloyd.  It is now
1363     maintained by a number of contributors at .:
1364           https://github.com/gbdev/rgbds
1365
1366BSD                            February 23, 2018                           BSD
Impressum