#include "ti86asm.inc" .org _asm_exec_ram Begin: call _getkey cp kAdd ;cp I guess is like saying check if something is happening kAdd is the plus ;so what this is saying is to check if the plus key is being pressed jr z,Acon ;This is going to jump to the contrast increase routine if the plus key is ;pressed. If it is not pressed it will continue in the loop.Pretend that the ;plus key is the number 3. When you say cp kAdd it is loading the value of ;that key into an area of memory and if you press the plus key it subtracts ;3 so it sets the zero flag and allows you to jump. cp kSub ;this is checking if the minus key is pressed jr z,Scon ;this is the jump if the minus key is pressed cp kExit ;check the exit key jr z,End ;jump if exit key is pressed jr Begin ;jump no matter what to the beginning Acon: ld a,($C008) ;this is loading the value of the current contrast settings into a register ;so that you can manipulate it. If you just loaded a number in it, it would ;destroy the current settings, so it usually is helpful keep the current ;value. inc a ;this adds 1 to the value at $C008 which, in turn, will darken the contrast ;but can only do so after you reload it back into the memory address that ;controls the contrast ld ($C008),a ;this is where you put the new value back in the contrast memory address out (2),a ;this ouputs the new value in memory to port 2, which is the contrast jr Begin ;this jumps you back to the original loop Scon: ld a,1 ld a,($C008) ;loads current contrast settings into a register sbc a,1 ;subtracts 1 from a ld ($C008),a ;loads the new value back in out (2),a ;this outputs to the video port jr Begin ;jumps to original loop End: ret ;will return to the calling program. If I would have pust call z,end instead ;of jr end this would just put you back in the original loop, but because of ;the fact that when you run an assembly program It's just like doing a call ;command except it is from the calcs operating system so it returns to the ;program it is called from last and that is the operating system so it ends ;the program .end