/*
!
$
%
&
*
+
-
/
:
=
?
\
_
|

*/


/*
2011-06-06 00:54

NEG 
INC DEC 
ADD ADC ADIW 
SUB SUBI SBC SBCI SBIW 
MUL MULS MULSU FMUL FMULS FMULSU 

 COM 
 CLR SER 
SWAP 
AND ANDI 
OR ORI 
EOR 
LSL LSR ROL ROR ASR 

RJMP IJMP EIJMP JMP 
RCALL ICALL EICALL CALL 
RET RETI 

TST 
CP CPC CPI CPSE 

SBRC SBRS SBIC SBIS 

 BRBS BRBC 
BREQ BRNE BRCS BRCC BRMI BRPL BRVS BRVC BRTS BRTC BRHS BRHC BRIE BRID 
BRSH BRLO 
BRGE BRLT 

MOV MOVW 
LDI LDS LD LDD 
STS ST STD 
LPM ELPM SPM ESPM 
IN OUT 
PUSH POP 

SBR CBR 
SBI CBI 

 BSET BCLR 
SEC CLC SEN CLN SEZ CLZ SEI CLI SES CLS SEV CLV SET CLT SEH CLH 
BST BLD 

NOP SLEEP WDR 

*/

/*

Status Register (SREG)

SREG : Status register
C : Carry flag in status register
Z : Zero flag in status register
N : Negative flag in status register
V : Two's complement overflow indicator
S : N [+] V, For signed tests
H : Half Carry flag in the status register
T : Transfer bit used by BLD and BST instructions
I : Global interrupt enable/disable flag


Registers and Operands

Rd    : Destination (and source) register in the register file
Rr    : Source register in the register file
R     : Result after instruction is executed 
K     : Constant data
k     : Constant address
b     : Bit in the register file or I/O register (3 bit)
s     : Bit in the status register (3 bit)
X,Y,Z : Indirect address register  (X=R27:R26, Y=R29:R28 and Z=R31:R30)
A     : I/O location address
q     : Displacement for direct addressing (6 bit)

ADC Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
ADD Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
ADIW Rd+1:Rd,K ; d{24|26|28|30} , 0 =< K =< 63
AND Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
ANDI Rd,K ; 16 =< d =< 31 , 0 =< K =< 255
ASR Rd ; 0 =< d =< 31
BCLR s ; 0 =< s =< 7
BLD Rd,b ; 0 =< d =< 31 , 0 =< b =< 7
BRBC s, k ; 0 =< s =< 7 , -64 =< k =< +63
BRBS s,k ; 0 =< s =< 7 , -64 =< k =< +63
BRCC k ; -64 =< k =< +63
BRCS k ; -64 =< k =< +63
BREAK ; NONE
BREQ k ; -64 =< k =< +63
BRGE k ; -64 =< k =< +63
BRHC k ; -64 =< k =< +63
BRHS k ; -64 =< k =< +63
BRID k ; -64 =< k =< +63
BRIE k ; -64 =< k =< +63
BRLO k ; -64 =< k =< +63 
BRLT k ; -64 =< k =< +63
BRMI k ; -64 =< k =< +63
BRNE k ; -64 =< k =< +63
BRPL k ; -64 =< k =< +63
BRSH k ; -64 =< k =< +63
BRTC k ; -64 =< k =< +63
BRTS k ; -64 =< k =< +63
BRVC k ; -64 =< k =< +63
BRVS k ; -64 =< k =< +63 
BSET s ; 0 =< s =< 7
BST Rd,b ; 0 =< d =< 31 , 0 =< b =< 7
CALL k ; 0 =< k < 64K|4M 
CBI A, b ; 0 =< A =< 31 , 0 =< b =< 7
CBR Rd,K ; 16 =< d =< 31 , 0 =< K =< 25 . (ANDI with K complemented)
CLC ; NONE
CLH ; NONE
CLI ; NONE
CLN ; NONE
CLR Rd ; 0 =< d =< 31 . (EOR Rd,Rd)
CLS ; NONE
CLT ; NONE
CLV ; NONE
CLZ ; NONE
COM Rd ; 0 =< d =< 31
CP Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
CPC Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
CPI Rd,K ; 16 =< d =< 31 , 0=< K =< 255
CPSE Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
DEC Rd ; 0 =< d =< 31
DES K ; 0x00 =< K =< 0x0F
EICALL ; NONE
EIJMP ; NONE
ELPM [Rd, Z[+]] ; 0 =< d =< 31
EOR Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
FMUL Rd,Rr ; 16 =< d =< 23 , 16=< r =< 23
FMULS Rd,Rr ; 16 =< d =< 23 , 16=< r =< 23
FMULSU Rd,Rr ; 16 =< d =< 23 , 16=< r =< 23
ICALL ; NONE
IJMP ; NONE
IN Rd,A ; 0 =< d =< 31 , 0 =< A =< 63
INC Rd ; 0 =< d =< 31
JMP k ; 0 =< k < 4M
LD Rd,[-]X[+]|[-]Y[+]|[-]Z[+] ; 0 =< d =< 31
LDD Rd,Y+q|Z+q ; 0 =< d =< 31 , 0 =< q =< 63 
LDI Rd,K ; 16 =< d =< 31 , 0 =< K =< 255
LDS Rd,k ; 0 =< d =< 31 , 0 =< k =< 65535 | 0x40 =< k =< 0xBF
LPM [Rd, Z[+]] ; 0 =< d =< 31
LSL Rd ; 0 =< d =< 31
LSR Rd ; 0 =< d =< 31
MOV Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
MOVW Rd+1:Rd,Rr+1:Rr ; d{0,2,...,30} , r{0,2,...,30}
MUL Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31 
MULS Rd,Rr ; 16 =< d =< 31 , 16 =< r =< 31
MULSU Rd,R ; r16 =< d =< 23 , 16 =< r =< 23
NEG Rd ; 0 =< d =< 31
NOP ; NONE
OR Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
ORI Rd,K ; 16 =< d =< 31 , 0 =< K =< 255
OUT A,Rr ; 0 =< r =< 31 , 0 =< A =< 63
POP Rd ; 0 =< d =< 31
PUSH Rr ; 0 =< r =< 31
RCALL k ; -2K =< k < +2K
RET ; NONE
RETI ; NONE
RJMP k ; -2K =< k < +2K
ROL Rd ; 0 =< d =< 31 . (see ADC Rd,Rd)
ROR Rd ; 0 =< d =< 31
SBC Rd,Rr ; 0 =< d =< 31 , 0 =< r =< 31
SBR Rd,K ; 16 =< d =< 31 , 0=<K=<255
SBRC Rr,b ; 0 =< r =< 31 , 0 =< b =< 7
SBRS Rr,b ; 0 =< r =< 31 , 0 =< b =< 7
SEC ; NONE
SEH ; NONE
SBI A,b ; 0 =< A =< 31, 0 =< b =< 7
SBCI Rd,K ; 16 =< d =< 31, 0 =< K =< 255
SBIC A,b ; 0 =< A =< 31, 0 =< b =< 7
SBIS A,b ; 0 =< A =< 31, 0 =< b =< 7
SBIW Rd+1:Rd,K ; d{24,26,28,30}, 0 =< K =< 63
SEI ; NONE
SEN ; NONE
SER Rd ; 16 =< d =< 31
SES ; NONE
SET ; NONE
SEV ; NONE
SEZ ; NONE
SLEEP ; NONE
SPM [Z+]
ST [-]X[+]|[-]Y[+]|[-]Z[+],Rr ; 0 =< r =< 31
STD Y+q|Z+q,Rr ; 0 =< r =< 31 , 0 =< q =< 63 
STS k,Rr ; 0 =< r =< 31, 0 =< k =< 65535 | 0x40 =< k =< 0xBF
SUB Rd,Rr ; 0 =< d =< 31, 0 =< r =< 31
SUBI Rd,K ; 16 =< d =< 31, 0 =< K =< 255
SWAP Rd ; 0 =< d =< 31
TST Rd ; 0 =< d =< 31 (AND Rd, Rd)
WDR ; NONE

*/




/*
CadenaDePrueba := "Linea de prueba" . LnaFin . "Otra linea de prueba" . LnaFin
ReferenciaResguardar("CMT", CadenaDePrueba, Referencias)
*/


;Gui, Font,, %@TpgFdm% ;Fuente tipográfica fundamental
;Gui, Add, Text, vTtlCdn R1 W%VtnAxlAco% X+3 YM Section, %ApcNbe% %ApcVsn%
;Gui, Font,, %@TpgEdc% ;Fuente tipográfica de edición


/*
V02 := 0
GuiControl, -Redraw, EtiqRfr
GuiControl,, EtiqRfr, |
Loop, % LV_GetCount() ;Para todos los renglones
{
 LV_GetText(V01, A_Index,2) ;Obtener texto de la columna de etiquetas
 If( V01 != "")
 {

  V02++

  GuiControl,, EtiqRfr, %V01%
  GuiControl, Choose, EtiqRfr, %V02%
 }
}
GuiControl, +Redraw, EtiqRfr
*/

/* Versión simple:
EtiquetasReferenciaActualizar:
V01 := ""
Loop, % LV_GetCount() ;Para todos los renglones
{
 LV_GetText(V02, A_Index,2) ;Obtener texto de la columna de etiquetas
 If( V02 != "")
 {
  V01 .= "|" . V02
 }
}
GuiControl, -Redraw, EtiqRfr
GuiControl,, EtiqRfr, %V01%
V01 := ""
GuiControl, +Redraw, EtiqRfr
Return,
*/

/*
TabComentarios:
ToolTip, "%A_Gui%" "%A_GuiControl%" "%A_GuiEvent%" "%A_EventInfo%"
Return,
	Modificar
Etiqueta
Operando
Comentario
*/

/*
ReferenciaResguardar(Codigo, ByRef Texto, ByRef Referencias)
{
 NumeroSiguiente := 1
 global LnaFin, RfrSnl

;Calcular número siguiente de la referencia
 CodigoLongitud := StrLen(Codigo)
 Loop, Parse, Referencias, `n
 {
  If(SubStr(A_LoopField, 1, CodigoLongitud) == Codigo)
  {
   If( SubStr(A_LoopField, 0) == RfrSnl)
   {
    NumeroReferente := SubStr(A_LoopField, CodigoLongitud+1, -1)
    If(NumeroSiguiente <= NumeroReferente)
    {
     NumeroSiguiente := NumeroReferente+1
    }
   }
   Else
   {
    Continue,
   }
  }
 }
 EliminarUltimasLineas(Texto)
 Texto .= LnaFin
 Referencias .= RfrSnl . Codigo . NumeroSiguiente . LnaFin . StrCnt(Texto, LnaFin) . LnaFin . Texto
 Return,
}
*/

/*
ReferenciaCodigoEliminar(Codigo, ByRef CadenaCodigo)
{
 global RfrSnl
 LongitudCodigo := StrLen(Codigo)
 CadenaCodigoNuevo := ""

 Loop, Parse, CadenaCodigo, %RfrSnl%
 {
  If( ( A_LoopField != "" ) && ( Codigo != SubStr(A_LoopField, 1, LongitudCodigo) ) )
  {
   CadenaCodigoNuevo .= RfrSnl . A_LoopField
  }
 }
 CadenaCodigo := CadenaCodigoNuevo
 Return,
}
*/

/*
   If(color == 0)
   {
    Gui, Font, cGreen
    color := 1
   }
   Else
   {
    Gui, Font, cRed
    Color := 0
   }
   GuiControl, Font, LVAsm
*/

/*
;Rutina de ayuda para desarrollo
ToolTip, 
(
A_GuiEvent
%A_GuiEvent%

A_Gui
%A_Gui%

A_GuiControl
%A_GuiControl%

A_EventInfo
%A_EventInfo%
)
, 60, 0, 2
*/
;
;############################
;#!
ReferenciaComentarioObtener(ByRef CadenaCodigo , ByRef Referencias)
{
 ReferenciaComentario := ""
 ComentarioNumero := ReferenciaCodigoNumero("CMT", CadenaCodigo)
 If(ComentarioNumero != 0)
 {
  ReferenciaComentario := ReferenciaObtener("CMT" . ComentarioNumero, Referencias) ;#$
 }
 Return, ReferenciaComentario
}
;
;############################
;#!
ReferenciaObtener(Indice, ByRef Referencias)
{
 global LnaFin, RfrSnl
 Encontrado := 0
, Lineas := 0
, Texto := ""
, IndiceLongitudM1 := StrLen(Indice)+1

 Loop, Parse, Referencias, %LnaFin%
 {
  If(Encontrado == 0)
  {
   If( A_LoopField == RfrSnl . Indice )
   {
    Encontrado := 1
    Continue,
   }
  }
  If(Encontrado == 1)
  {
   If( SubStr(A_LoopField, 1, 1) == RfrSnl )
   {
    Break,
   }
   Texto .= A_LoopField . LnaFin
  }
 }
 Return, Texto
}
;
;############################
;
