Z80 InstructionsSource files: Z80 InstructionsZ80 instructions must not start in column 1 but must be preceded by 'white space', at minimum one space or one tab, because any word which starts in column 1 is treated as a Source files: Label definitionslabel definition. Legal instructionsAll legal Z80 Instructions: Legal instructionsZ80 opcodes are supported. ! Z80 Instructions: Legal instructionsOpcode ! A s s e m b l e r M n e m o n i c ! ! dec ! hex ! immediate ! after $CB ! after $ED ! +-----+-----+--------------+--------------+--------------+ ! 0 ! 00 ! nop ! rlc b ! ! ! 1 ! 01 ! ld bc,NN ! rlc c ! ! ! 2 ! 02 ! ld (bc),a ! rlc d ! ! ! 3 ! 03 ! inc bc ! rlc e ! ! ! 4 ! 04 ! inc b ! rlc h ! ! ! 5 ! 05 ! dec b ! rlc l ! ! ! 6 ! 06 ! ld b,N ! rlc (hl) ! ! ! 7 ! 07 ! rlca ! rlc a ! ! +-----+-----+--------------+--------------+--------------+ ! 8 ! 08 ! ex af,af' ! rrc b ! ! ! 9 ! 09 ! add hl,bc ! rrc c ! ! ! 10 ! 0a ! ld a,(bc) ! rrc d ! ! ! 11 ! 0b ! dec bc ! rrc e ! ! ! 12 ! 0c ! inc c ! rrc h ! ! ! 13 ! 0d ! dec c ! rrc l ! ! ! 14 ! 0e ! ld c,N ! rrc (hl) ! ! ! 15 ! 0f ! rrca ! rrc a ! ! +-----+-----+--------------+--------------+--------------+ ! 16 ! 10 ! djnz DIS ! rl b ! ! ! 17 ! 11 ! ld de,NN ! rl c ! ! ! 18 ! 12 ! ld (de),a ! rl d ! ! ! 19 ! 13 ! inc de ! rl e ! ! ! 20 ! 14 ! inc d ! rl h ! ! ! 21 ! 15 ! dec d ! rl l ! ! ! 22 ! 16 ! ld d,N ! rl (hl) ! ! ! 23 ! 17 ! rla ! rl a ! ! +-----+-----+--------------+--------------+--------------+ ! 24 ! 18 ! jr DIS ! rr b ! ! ! 25 ! 19 ! add hl,de ! rr c ! ! ! 26 ! 1a ! ld a,(de) ! rr d ! ! ! 27 ! 1b ! dec de ! rr e ! ! ! 28 ! 1c ! inc e ! rr h ! ! ! 29 ! 1d ! dec e ! rr l ! ! ! 30 ! 1e ! ld e,N ! rr (hl) ! ! ! 31 ! 1f ! rra ! rr a ! ! +-----+-----+--------------+--------------+--------------+ ! 32 ! 20 ! jr nz,DIS ! sla b ! ! ! 33 ! 21 ! ld hl,NN ! sla c ! ! ! 34 ! 22 ! ld (NN),hl ! sla d ! ! ! 35 ! 23 ! inc hl ! sla e ! ! ! 36 ! 24 ! inc h ! sla h ! ! ! 37 ! 25 ! dec h ! sla l ! ! ! 38 ! 26 ! ld h,N ! sla (hl) ! ! ! 39 ! 27 ! daa ! sla a ! ! +-----+-----+--------------+--------------+--------------+ ! 40 ! 28 ! jr z,DIS ! sra b ! ! ! 41 ! 29 ! add hl,hl ! sra c ! ! ! 42 ! 2a ! ld hl,(NN) ! sra d ! ! ! 43 ! 2b ! dec hl ! sra e ! ! ! 44 ! 2c ! inc l ! sra h ! ! ! 45 ! 2d ! dec l ! sra l ! ! ! 46 ! 2e ! ld l,N ! sra (hl) ! ! ! 47 ! 2f ! cpl ! sra a ! ! +-----+-----+--------------+--------------+--------------+ ! 48 ! 30 ! jr nc,DIS ! Illegal instructions: sllsll b (ill.)! ! ! 49 ! 31 ! ld sp,NN ! Illegal instructions: sllsll c "" ! ! ! 50 ! 32 ! ld (NN),a ! Illegal instructions: sllsll d "" ! ! ! 51 ! 33 ! inc sp ! Illegal instructions: sllsll e "" ! ! ! 52 ! 34 ! inc (hl) ! Illegal instructions: sllsll h "" ! ! ! 53 ! 35 ! dec (hl) ! Illegal instructions: sllsll l "" ! ! ! 54 ! 36 ! ld (hl),N ! Illegal instructions: sllsll (hl) "" ! ! ! 55 ! 37 ! scf ! Illegal instructions: sllsll a "" ! ! +-----+-----+--------------+--------------+--------------+ ! 56 ! 38 ! jr c,DIS ! srl b ! ! ! 57 ! 39 ! add hl,sp ! srl c ! ! ! 58 ! 3a ! ld a,(NN) ! srl d ! ! ! 59 ! 3b ! dec sp ! srl e ! ! ! 60 ! 3c ! inc a ! srl h ! ! ! 61 ! 3d ! dec a ! srl l ! ! ! 62 ! 3e ! ld a,N ! srl (hl) ! ! ! 63 ! 3f ! ccf ! srl a ! ! +-----+-----+--------------+--------------+--------------+ ! 64 ! 40 ! ld b,b ! bit 0,b ! in b,(c) ! ! 65 ! 41 ! ld b,c ! bit 0,c ! out (c),b ! ! 66 ! 42 ! ld b,d ! bit 0,d ! sbc hl,bc ! ! 67 ! 43 ! ld b,e ! bit 0,e ! ld (NN),bc ! ! 68 ! 44 ! ld b,h ! bit 0,h ! neg ! ! 69 ! 45 ! ld b,l ! bit 0,l ! retn ! ! 70 ! 46 ! ld b,(hl) ! bit 0,(hl) ! im 0 ! ! 71 ! 47 ! ld b,a ! bit 0,a ! ld i,a ! +-----+-----+--------------+--------------+--------------+ ! 72 ! 48 ! ld c,b ! bit 1,b ! in c,(c) ! ! 73 ! 49 ! ld c,c ! bit 1,c ! out (c),c ! ! 74 ! 4a ! ld c,d ! bit 1,d ! adc hl,bc ! ! 75 ! 4b ! ld c,e ! bit 1,e ! ld bc,(NN) ! ! 76 ! 4c ! ld c,h ! bit 1,h ! ! ! 77 ! 4d ! ld c,l ! bit 1,l ! reti ! ! 78 ! 4e ! ld c,(hl) ! bit 1,(hl) ! ! ! 79 ! 4f ! ld c,a ! bit 1,a ! ld r,a ! +-----+-----+--------------+--------------+--------------+ ! 80 ! 50 ! ld d,b ! bit 2,b ! in d,(c) ! ! 81 ! 51 ! ld d,c ! bit 2,c ! out (c),d ! ! 82 ! 52 ! ld d,d ! bit 2,d ! sbc hl,de ! ! 83 ! 53 ! ld d,e ! bit 2,e ! ld (NN),de ! ! 84 ! 54 ! ld d,h ! bit 2,h ! ! ! 85 ! 55 ! ld d,l ! bit 2,l ! ! ! 86 ! 56 ! ld d,(hl) ! bit 2,(hl) ! im 1 ! ! 87 ! 57 ! ld d,a ! bit 2,a ! ld a,i ! +-----+-----+--------------+--------------+--------------+ ! 88 ! 58 ! ld e,b ! bit 3,b ! in e,(c) ! ! 89 ! 59 ! ld e,c ! bit 3,c ! out (c),e ! ! 90 ! 5a ! ld e,d ! bit 3,d ! adc hl,de ! ! 91 ! 5b ! ld e,e ! bit 3,e ! ld de,(NN) ! ! 92 ! 5c ! ld e,h ! bit 3,h ! ! ! 93 ! 5d ! ld e,l ! bit 3,l ! ! ! 94 ! 5e ! ld e,(hl) ! bit 3,(hl) ! im 2 ! ! 95 ! 5f ! ld e,a ! bit 3,a ! ld a,r ! +-----+-----+--------------+--------------+--------------+ ! 96 ! 60 ! ld h,b ! bit 4,b ! in h,(c) ! ! 97 ! 61 ! ld h,c ! bit 4,c ! out (c),h ! ! 98 ! 62 ! ld h,d ! bit 4,d ! sbc hl,hl ! ! 99 ! 63 ! ld h,e ! bit 4,e ! ld (NN),hl ! ! 100 ! 64 ! ld h,h ! bit 4,h ! ! ! 101 ! 65 ! ld h,l ! bit 4,l ! ! ! 102 ! 66 ! ld h,(hl) ! bit 4,(hl) ! ! ! 103 ! 67 ! ld h,a ! bit 4,a ! rrd ! +-----+-----+--------------+--------------+--------------+ ! 104 ! 68 ! ld l,b ! bit 5,b ! in l,(c) ! ! 105 ! 69 ! ld l,c ! bit 5,c ! out (c),l ! ! 106 ! 6a ! ld l,d ! bit 5,d ! adc hl,hl ! ! 107 ! 6b ! ld l,e ! bit 5,e ! ld hl,(NN) ! ! 108 ! 6c ! ld l,h ! bit 5,h ! ! ! 109 ! 6d ! ld l,l ! bit 5,l ! ! ! 110 ! 6e ! ld l,(hl) ! bit 5,(hl) ! ! ! 111 ! 6f ! ld l,a ! bit 5,a ! rld ! +-----+-----+--------------+--------------+--------------+ ! 112 ! 70 ! ld (hl),b ! bit 6,b ! in f,(c) ! ! 113 ! 71 ! ld (hl),c ! bit 6,c ! ! ! 114 ! 72 ! ld (hl),d ! bit 6,d ! sbc hl,sp ! ! 115 ! 73 ! ld (hl),e ! bit 6,e ! ld (NN),sp ! ! 116 ! 74 ! ld (hl),h ! bit 6,h ! ! ! 117 ! 75 ! ld (hl),l ! bit 6,l ! ! ! 118 ! 76 ! halt ! bit 6,(hl) ! ! ! 119 ! 77 ! ld (hl),a ! bit 6,a ! ! +-----+-----+--------------+--------------+--------------+ ! 120 ! 78 ! ld a,b ! bit 7,b ! in a,(c) ! ! 121 ! 79 ! ld a,c ! bit 7,c ! out (c),a ! ! 122 ! 7a ! ld a,d ! bit 7,d ! adc hl,sp ! ! 123 ! 7b ! ld a,e ! bit 7,e ! ld sp,(NN) ! ! 124 ! 7c ! ld a,h ! bit 7,h ! ! ! 125 ! 7d ! ld a,l ! bit 7,l ! ! ! 126 ! 7e ! ld a,(hl) ! bit 7,(hl) ! ! ! 127 ! 7f ! ld a,a ! bit 7,a ! ! +-----+-----+--------------+--------------+--------------+ ! 128 ! 80 ! add a,b ! res 0,b ! ! ! 129 ! 81 ! add a,c ! res 0,c ! ! ! 130 ! 82 ! add a,d ! res 0,d ! ! ! 131 ! 83 ! add a,e ! res 0,e ! ! ! 132 ! 84 ! add a,h ! res 0,h ! ! ! 133 ! 85 ! add a,l ! res 0,l ! ! ! 134 ! 86 ! add a,(hl) ! res 0,(hl) ! ! ! 135 ! 87 ! add a,a ! res 0,a ! ! +-----+-----+--------------+--------------+--------------+ ! 136 ! 88 ! adc a,b ! res 1,b ! ! ! 137 ! 89 ! adc a,c ! res 1,c ! ! ! 138 ! 8a ! adc a,d ! res 1,d ! ! ! 139 ! 8b ! adc a,e ! res 1,e ! ! ! 140 ! 8c ! adc a,h ! res 1,h ! ! ! 141 ! 8d ! adc a,l ! res 1,l ! ! ! 142 ! 8e ! adc a,(hl) ! res 1,(hl) ! ! ! 143 ! 8f ! adc a,a ! res 1,a ! ! +-----+-----+--------------+--------------+--------------+ ! 144 ! 90 ! sub b ! res 2,b ! ! ! 145 ! 91 ! sub c ! res 2,c ! ! ! 146 ! 92 ! sub d ! res 2,d ! ! ! 147 ! 93 ! sub e ! res 2,e ! ! ! 148 ! 94 ! sub h ! res 2,h ! ! ! 149 ! 95 ! sub l ! res 2,l ! ! ! 150 ! 96 ! sub (hl) ! res 2,(hl) ! ! ! 151 ! 97 ! sub a ! res 2,a ! ! +-----+-----+--------------+--------------+--------------+ ! 152 ! 98 ! sbc a,b ! res 3,b ! ! ! 153 ! 99 ! sbc a,c ! res 3,c ! ! ! 154 ! 9a ! sbc a,d ! res 3,d ! ! ! 155 ! 9b ! sbc a,e ! res 3,e ! ! ! 156 ! 9c ! sbc a,h ! res 3,h ! ! ! 157 ! 9d ! sbc a,l ! res 3,l ! ! ! 158 ! 9e ! sbc a,(hl) ! res 3,(hl) ! ! ! 159 ! 9f ! sbc a,a ! res 3,a ! ! +-----+-----+--------------+--------------+--------------+ ! 160 ! a0 ! and b ! res 4,b ! ldi ! ! 161 ! a1 ! and c ! res 4,c ! cpi ! ! 162 ! a2 ! and d ! res 4,d ! ini ! ! 163 ! a3 ! and e ! res 4,e ! outi ! ! 164 ! a4 ! and h ! res 4,h ! ! ! 165 ! a5 ! and l ! res 4,l ! ! ! 166 ! a6 ! and (hl) ! res 4,(hl) ! ! ! 167 ! a7 ! and a ! res 4,a ! ! +-----+-----+--------------+--------------+--------------+ ! 168 ! a8 ! xor b ! res 5,b ! ldd ! ! 169 ! a9 ! xor c ! res 5,c ! cpd ! ! 170 ! aa ! xor d ! res 5,d ! ind ! ! 171 ! ab ! xor e ! res 5,e ! outd ! ! 172 ! ac ! xor h ! res 5,h ! ! ! 173 ! ad ! xor l ! res 5,l ! ! ! 174 ! ae ! xor (hl) ! res 5,(hl) ! ! ! 175 ! af ! xor a ! res 5,a ! ! +-----+-----+--------------+--------------+--------------+ ! 176 ! b0 ! or b ! res 6,b ! ldir ! ! 177 ! b1 ! or c ! res 6,c ! cpir ! ! 178 ! b2 ! or d ! res 6,d ! inir ! ! 179 ! b3 ! or e ! res 6,e ! otir ! ! 180 ! b4 ! or h ! res 6,h ! ! ! 181 ! b5 ! or l ! res 6,l ! ! ! 182 ! b6 ! or (hl) ! res 6,(hl) ! ! ! 183 ! b7 ! or a ! res 6,a ! ! +-----+-----+--------------+--------------+--------------+ ! 184 ! b8 ! cp b ! res 7,b ! lddr ! ! 185 ! b9 ! cp c ! res 7,c ! cpdr ! ! 186 ! ba ! cp d ! res 7,d ! indr ! ! 187 ! bb ! cp e ! res 7,e ! otdr ! ! 188 ! bc ! cp h ! res 7,h ! ! ! 189 ! bd ! cp l ! res 7,l ! ! ! 190 ! be ! cp (hl) ! res 7,(hl) ! ! ! 191 ! bf ! cp a ! res 7,a ! ! +-----+-----+--------------+--------------+--------------+ ! 192 ! c0 ! ret nz ! set 0,b ! ! ! 193 ! c1 ! pop bc ! set 0,c ! ! ! 194 ! c2 ! jp nz,NN ! set 0,d ! ! ! 195 ! c3 ! jp NN ! set 0,e ! ! ! 196 ! c4 ! call nz,NN ! set 0,h ! ! ! 197 ! c5 ! push bc ! set 0,l ! ! ! 198 ! c6 ! add a,N ! set 0,(hl) ! ! ! 199 ! c7 ! rst 0 ! set 0,a ! ! +-----+-----+--------------+--------------+--------------+ ! 200 ! c8 ! ret z ! set 1,b ! ! ! 201 ! c9 ! ret ! set 1,c ! ! ! 202 ! ca ! jp z,NN ! set 1,d ! ! ! 203 ! cb ! PREFIX col.2 ! set 1,e ! ! ! 204 ! cc ! call z,NN ! set 1,h ! ! ! 205 ! cd ! call NN ! set 1,l ! ! ! 206 ! ce ! adc a,NN ! set 1,(hl) ! ! ! 207 ! cf ! rst 8 ! set 1,a ! ! +-----+-----+--------------+--------------+--------------+ ! 208 ! d0 ! ret nc ! set 2,b ! ! ! 209 ! d1 ! pop de ! set 2,c ! ! ! 210 ! d2 ! jp nc,NN ! set 2,d ! ! ! 211 ! d3 ! out (N),a ! set 2,e ! ! ! 212 ! d4 ! call nc,NN ! set 2,h ! ! ! 213 ! d5 ! push de ! set 2,l ! ! ! 214 ! d6 ! sub N ! set 2,(hl) ! ! ! 215 ! d7 ! rst 16 ! set 2,a ! ! +-----+-----+--------------+--------------+--------------+ ! 216 ! d8 ! ret c ! set 3,b ! ! ! 217 ! d9 ! exx ! set 3,c ! ! ! 218 ! da ! jp c,NN ! set 3,d ! ! ! 219 ! Pseudo instructions: defb, dbdb ! in a,(N) ! set 3,e ! ! ! 220 ! dc ! call c,NN ! set 3,h ! ! ! 221 ! dd ! PREFIX IX ! set 3,l ! ! ! 222 ! de ! sbc a,N ! set 3,(hl) ! ! ! 223 ! df ! rst 24 ! set 3,a ! ! +-----+-----+--------------+--------------+--------------+ ! 224 ! e0 ! ret po ! set 4,b ! ! ! 225 ! e1 ! pop hl ! set 4,c ! ! ! 226 ! e2 ! jp po,NN ! set 4,d ! ! ! 227 ! e3 ! ex (sp),hl ! set 4,e ! ! ! 228 ! e4 ! call po,NN ! set 4,h ! ! ! 229 ! e5 ! push hl ! set 4,l ! ! ! 230 ! e6 ! and N ! set 4,(hl) ! ! ! 231 ! e7 ! rst 32 ! set 4,a ! ! +-----+-----+--------------+--------------+--------------+ ! 232 ! e8 ! ret pe ! set 5,b ! ! ! 233 ! e9 ! jp (hl) ! set 5,c ! ! ! 234 ! ea ! jp pe,NN ! set 5,d ! ! ! 235 ! eb ! ex de,hl ! set 5,e ! ! ! 236 ! ec ! call pe,NN ! set 5,h ! ! ! 237 ! ed ! PREFIX col.3 ! set 5,l ! ! ! 238 ! ee ! xor N ! set 5,(hl) ! ! ! 239 ! ef ! rst 40 ! set 5,a ! ! +-----+-----+--------------+--------------+--------------+ ! 240 ! f0 ! ret p ! set 6,b ! ! ! 241 ! f1 ! pop af ! set 6,c ! ! ! 242 ! f2 ! jp p,NN ! set 6,d ! ! ! 243 ! f3 ! di ! set 6,e ! ! ! 244 ! f4 ! call p,NN ! set 6,h ! ! ! 245 ! f5 ! push af ! set 6,l ! ! ! 246 ! f6 ! or N ! set 6,(hl) ! ! ! 247 ! f7 ! rst 48 ! set 6,a ! ! +-----+-----+--------------+--------------+--------------+ ! 248 ! f8 ! ret m ! set 7,b ! ! ! 249 ! f9 ! ld sp,hl ! set 7,c ! ! ! 250 ! fa ! jp m,NN ! set 7,d ! ! ! 251 ! fb ! ei ! set 7,e ! ! ! 252 ! fc ! call m,NN ! set 7,h ! ! ! 253 ! fd ! PREFIX IY ! set 7,l ! ! ! 254 ! fe ! cp N ! set 7,(hl) ! ! ! 255 ! ff ! rst 56 ! set 7,a ! ! +-----+-----+--------------+--------------+--------------+ Illegal instructionsThe following Z80 Instructions: Illegal instructionsillegal instructions are recognized: sllshift left register A, padding bit 0 with '1' This presumably should have been padding bit 0 with '0', complementing the srl instruction, but when Zilog found out that their delivered cpus had a General information: Bug reportsbug and actually padded bit 0 with '1', they fixed it by removing the Z80 Instructions: Legal instructionsopcode from the specs. :-| Just guessing. Syntax variantsBesides of the official Zilog Target files: #target z80Z80 assembler syntax, the following variations of their syntax are allowed: out (c),reg out (bc),reg in reg,(c) in reg,(bc) add x add a,x sub x sub a,x adc x adc a,x sbc x sbc a,x and x and a,x or x or a,x xor x xor a,x cp x cp a,x rst 0 rst 0 rst 1 rst 8 rst 2 rst 16 rst 3 rst 24 rst 4 rst 32 rst 5 rst 40 rst 6 rst 48 rst 7 rst 56 ld bc,de ld bc,hl ld de,bc ld de,hl ld hl,bc ld hl,de |