 # Basic Assembly Language Commands

DEC
EX
EXX
INC
LD
NOP
Back to the lesson index

When refering to memory there are serveral methods used to tell what part of memory is being talked about. These are called addressing methods because you can use them to find the "address" of the memory location in question.
• If you want to access a specific byte or word in memory you can use direct addressing. This uses hexadecimal notation. If you wanted to load A with the byte at memory location 39A2h you would use the command LD A, (39A2). ( and ) serve the same purpose as [ and ] in other assembly languages. The number in the parenthesis is the address of memory that a byte or word is taken from or put in.
• If the address of the byte you needed was calculated while the program was running (at run-time) then you could get at that byte or word with register-indirect addressing. An example of its usage: LD A, (BC) the byte whose address is in BC will be put in A.
• If you frequently use a list at an unknown location you can use indexed addressing. For instance, to move the third byte of a list beginning at the address in DE to C you would use the command LD C, (DE+2). The third byte is two bytes past the first so +2 ia used. You can add a number as large as 127, or subtract a number as small as -128. The hitch is that the number, +3 , -2, +17 is always the same. You couldn't use LD C, (DE + B).

## DEC

This is one of the most basic math operators. All it does is subtract one from a number. This is faster than the subtract instruction, so if this is all your program needs, you should let your program use this. The syntax for this command is as follows:
DEC ?
where ? is one of the following: IX, IY, BC, DE, HL, SP, A, B, C, D, E, H, L, (IX+d), (IY+d) where d = -128 to 127

## EX

This operand lets you swap the values of two registers or between a register and memory. The syntax is:
EX (SP), HL
EX (SP), IX
EX (SP), IY
EX AF, AF'
EX DE, HL
As shown, one of the forms of EX swaps AF with AF', which if you don't currently care about the flag register allows you to use two more registers called A' and F'. The hitch is that A' and F' have to be swapped with A and F to use what's in them, and because of this you can't use A and A' or F and F' at the same time.

## EXX

This useful command is similar to EX AF, AF', but uses different registers. The syntax is:
EXX
This will swap BC and BC', DE and DE', and HL and HL'. If you looked at EX yo know why this is useful, but the same hitch applies. There is also a new hitch, all 3 register pairs must be swapped at once. You can't just swap BC and BC' without swapping the other pairs as well.

### INC

This operation is similar to DEC, but instead of subtracting one, it adds one. It's syntax is:
INC ?
where ? is one of the following: IX, IY, BC, DE, HL, SP, A, B, C, D, E, H, L, (IX+d), (IY+d) where d = -128 to 127

### LD

This command stands for load, and is one of the most commonly used commands in any assembly language. It's equivalent on PCs is MOV. The syntax is:
LD I, A
LD A, I
LD R, A
LD A, R
LD (BC), ? In these 6 lines ? means A, B, C, D, E, H, L, 0-255, 0-65535,
LD (DE), ? BC, DE, HL, or SP and d is between -128 and 127.
LD (HL), ?
LD (#), ?
LD (IX+d), ?
LD (IY+d), ?

LD A, ? In these 7 lines ? means A, B, C, D, E, H, L, 0-255, (HL), (BC),
LD B, ? (DE), (SP), (IX+d), (IY+d), or (#) where d is -127 to 128 and # is
LD C, ? a location in the TI's memory.
LD D, ?
LD E, ?
LD H, ?
LD L, ?

### NOP

This command stands for No Op, or no operation. When the processor gets this command it does nothing for one clock cycle, then does the next command. This is used mostly for timing when writing to the display adaptor, and should not be used except as neccesary because except for the display adaptor it serves no useful purpose on the 82.
Questions, comments, flames? Send them in!
If you need help (more simple or more technical) tell me and I'll send it to you by e-mail. Also, is there anything in specific you want to see examples of? Let me know!