Each .pbpmod (module file) can have multiple commands in them.
In this case, we'll add a DECR (decrement) command to go along with INCR (increment).
Essentially, you just duplicate the INCR command and modify it to do a decrement.
Add the USERCOMMAND line, create the basic subroutine ...
Code:
GOTO Over_INCR ; Jump over the code USERCOMMAND "INCR" ; Create a command called INCR USERCOMMAND "DECR" ; Create a command called DECR #IF __LONG__ = 1 ; if using LONG version of PBP TempVar VAR LONG ; Tempvar is a LONG #ELSE TempVar VAR WORD ; otherwise it's a WORD #ENDIF ;----[Main Code - Called by the macros]------------------------------------- Increment: TempVar = TempVar + 1 RETURN Decrement: TempVar = TempVar - 1 RETURN
Code:
ASM ;----[Decrement a Byte]----------------------------------------------------- DECR?B macro Bin MOVE?BB Bin, _TempVar ; copy user var to TempVar L?CALL _Decrement ; run the decrement subroutine MOVE?BB _TempVar, Bin ; copy result back to user var endm ;----[Decrement a Word]----------------------------------------------------- DECR?W macro Win MOVE?WW Win, _TempVar ; copy user var to TempVar L?CALL _Decrement ; run the decrement subroutine MOVE?WW _TempVar, Win ; copy result back to user var endm ;----[Decrement a Long]----------------------------------------------------- DECR?N macro Nin MOVE?NN Nin, _TempVar ; copy user var to TempVar L?CALL _Decrement ; run the decrement subroutine MOVE?NN _TempVar, Nin ; copy result back to user var endm ;----[Constant]------------------------------------------------------------- DECR?C macro Cin ERROR You cannot decrement a constant endm ;----[String]--------------------------------------------------------------- DECR?S macro Cin ERROR You cannot decrement a String endm ;----[Label]---------------------------------------------------------------- DECR?L macro Cin ERROR You cannot decrement a Label endm ;----[Bit]------------------------------------------------------------------ DECR?T macro Regin, Bitin ERROR Decrementing a BIT is not supported endm ENDASM
To use it, just INCLUDE the module, and the new commands are available.
Code:
INCLUDE "INCR_DECR.pbpmod"
Leave a comment: