Rutinas ASM para comparar dos numeros de 16 bit

Estas rutinas han sido hecha por mi y han sido probadas (y)

CBLOCK
REGA_H
REGA_L
REGB_H
REGB_L
BANDERAS
ENDC

#define FLAG_MENOR BANDERAS, 0
#define FLAG_IGUAL BANDERAS, 1
#define FLAG_MAYOR BANDERAS, 2
#define FLAG_IGUAL_MAYOR BANDERAS, 3

IGUAL_MAYOR_A_QUE_B
bcf FLAG_IGUAL_MAYOR
movf REGB_L, W
subwf REGA_L, W
btfss STATUS, C
return
movf REGB_H, W
subwf REGA_H, W
btfsc STATUS, C
bsf FLAG_IGUAL_MAYOR
return

MAYOR_A_QUE_B
bcf FLAG_MAYOR
movf REGB_L, W
subwf REGA_L, W
btfss STATUS, C
return
movf REGB_H, W
subwf REGA_H, W
btfsc STATUS, C
goto son_iguales
goto es_menor
son_iguales call IGUAL_A_QUE_B
btfss FLAG_IGUAL
bsf FLAG_MAYOR
es_menor return

IGUAL_A_QUE_B
bcf FLAG_IGUAL
movf REGB_L, W
subwf REGA_L, W
btfss STATUS, Z
return
movf REGB_H, W
subwf REGA_H, W
btfsc STATUS, Z
bsf FLAG_IGUAL
return

MENOR_A_QUE_B
bcf FLAG_MENOR
movf REGB_H, W
subwf REGA_H, W
btfss STATUS, C
return
movf REGB_L, W
subwf REGA_L, W
btfss STATUS, C
bsf FLAG_MENOR
return
 
Última edición:
Atrás
Arriba