- ASM86v?? (found on ticalc.org)
- TASM (also found on ticalc.org)
- TASM80.TAB (notice a patern)

The most important thing you need to understandis what a register is, and how to use it. A register is a 16bit (2byte) memory location, found on the CPU itself. On the Z80 you havethe following important Registers:#include "asm86.h" ;I use Asm86 to compile, so I include this#include "ti86asm.inc" ;this is TI's includefile

.org _asm_exec_ram ;starting point for all asm progs, $D748; all the ASM goes in here.end

- AF
- BC
- DE
- HL
- IX
- IY
- (there are others, but we won't use them in my examples,I don't even unstand them all)

Thefirst thing you will want to do is to load a value into a register. This is done with the LD instruction. Here are some examples:

The register HL, is primarly used for ADDRESSING,this means it usually points to another memory location. The videoMemory is located at $FC00, so to have hl "point" to the video memory youuse the command:ld a,0 ; loads the value0 into register ald b,2 ; loads the value 2 intoregister bld de,257 ; loads the value 257 into register de;(same as loading 1 into d and 1 into e)ld d,$0A ; NOTE $8A represents a HEX number,; %00100100 represents a BIN number,; 52 just a decimal number.; this loads $0A into d, $0A is the same as 10ld a,d ; loads the current valueof d into a (in this case 10)

:An 8-bit regiser can only hold the values from 0-255 (%00000000-%11111111),but a 16 bit register can hold the values 0-65535.NOTE

ld hl,$FC00 ;loads the value $FC00 into registerhl

back to list of instructionsld a,%10101010 ;loads thevalue %10101010 into reg. ald (hl),a ;loads the value %10101010 into the;memory location that hl "points" to;the value of HL is $fc00 therefore;the value %10101010 is loaded into;memory location $fc00, which happens;to be the video memory :);IT DOES NOT CHANGE THE VALUE OF HL!!ld a,(hl) ;similiarly this loads the value at;mem location $fc00 into the reg. a

ADD/SUB

The next thing to learn, is how to add and subtractfrom a register. To do this we use the indtructions ADD and SUB.

- add a,##
- add hl,
*ss*(where*ss*= bc,de,hl, or sp) - add ix,
*pp*(where*pp*= bc,de,ix, or sp) - add iy,
*rr*(where*rr =*bc,de,iy, or sp)

In order to add anything to the other registers, you mustdo it inderectly:ld a,8 ;a=8add a,10 ;a=a+10 a=18ld hl,$FC00 ;hl = $FC00ld bc,$00BB ;bc = $00BBadd hl,FCBB ;hl=hl+bc hl = $fcbb

Now you know how to add, what about subtracting?ld b,8 ;b=8ld a,b ;a=badd a,5 ;a='b+5'ld b,a ;b='b+5'

;or

ld bc,46 ;bc=46ld h,b ;you can't do'ld hl,bc'ld l,c ;ld bc,52 ;add hl,bc ;hl = bc+52ld b,h ;.ld c,l ;bc =bc+52

- sub ## ; a=a-##

ADD and SUB let you add or subtract any number, however ifyou only want to add or subract the value 1 then you can use INC/DECld a,16 ;a=16sub 5 ;a=a-5, a=11

ld b,65 ;b=65ld a,b ;a=65sub 6 ;a=65-6, a=59ld b,a ;b=59

- inc
*r*;(where*r*=a,b,c,d,e,h,orl) - inc
*ss*;(where*ss*=bc,de,hl, or sp) - dec
*r* - dec
*ss*

back to list of instructionsld a,5 ;a=5inc a ;a=a+1, a=6ld b,a ;b=a, b=6dec b ;b=b-1, b=5

ld bc,568 ;bc=568inc bc ;bc=bc+1, bc=569inc bc ;bc=bc+1, bc=570