DogFlu66
Member
These are a group of functions for working with signed integers. If you have a lot of memory it is better to work with long type variables. However, functions are included to work with the other types of variables to use less memory if necessary.
I also leave the result of the simulation of the program.
I also leave the result of the simulation of the program.
Code:
'*********************************************
'Functions to work with signed integers.
'By COS, 02/2023, Basic PSI compiler18 v4.37
'*********************************************
Include "_FuncionesEnterosConSigno.bas"
AllDigital
Hseropen 4800 'Initialize serial port
main:
'Declare variables
Dim _byte As Byte
Dim _word As Word
Dim _long As Long
Dim _string As String
'Assigns value to signed variables
_byte = _sigset("-", 10, _asbyte)
_word = _sigset("-", 1000, _asword)
_long = _sigset("-", 100000, _aslong)
'Send the signed integer variable to the serial port
Hserout #_byte, " -> ", _sigtostring(_byte, _asbyte), CrLf
Hserout #_word, " -> ", _sigtostring(_word, _asword), CrLf
Hserout #_long, " -> ", _sigtostring(_long, _aslong), CrLf
Hserout CrLf 'Next line
'Division
Hserout _sigtostring(_word, _asword), " / ", _sigtostring(_byte, _asbyte), " = "
Hserout _sigtostring(_sigdiv(_word, _asword, _byte, _asbyte), _asword), CrLf
Hserout CrLf 'Next line
'Addition
Hserout _sigtostring(_byte, _asbyte), " + ", _sigtostring(_word, _asword), " = "
Hserout _sigtostring(_sigadd(_byte, _asbyte, _word, _asword), _aslong), CrLf
Hserout CrLf 'Next line
'Subtraction
Hserout _sigtostring(_long, _aslong), " - ", _sigtostring(_byte, _asbyte), " = "
Hserout _sigtostring(_sigsub(_long, _aslong, _byte, _asbyte), _aslong), CrLf
Hserout CrLf 'Next line
'Multiplication
Hserout _sigtostring(_byte, _asbyte), " * ", _sigtostring(_long, _aslong), " = "
Hserout _sigtostring(_sigmul(_byte, _asbyte, _long, _aslong), _aslong), CrLf
End