I have written this program to perform ulam's conjecture on an entered integer, however when entering a number such as 38836, it exceeds the bounds for a 16 bit signed integer. I believe using unsigned would fix my issue, however I cannot figure out how to adjust this code segment to accept an unsigned integer. Any Help would be very much appreciated!
DOSSEG
.MODEL SMALL, BASIC, FARSTACK
EXTRN GETDEC:FAR
EXTRN NEWLINE:FAR
EXTRN PUTDEC:FAR
EXTRN PUTSTRNG:FAR
.STACK 256
.DATA
NUM DW ?
CNT DW 0
PROMPT DB 'Enter an integer: '
TOTAL DB 'Number Total: '
FLOWMSG DB 'OVERFLOW '
.CODE
ULAMS:
MOV AX,SEG DGROUP
MOV ES,AX
LEA DI,PROMPT
MOV CX,18
CALL PUTSTRNG
CALL GETDEC
MOV NUM,AX
MOV CNT,0
--->Rest of program cut for brevity<-----
At least in my case, this issue was fixed by using a seperate command that specified the input as unsigned, called GETDEC$. This fixed the issue and allowed the range of integers for unsigned 16 bit, rather than signed.
来源:https://stackoverflow.com/questions/32978767/converting-a-program-to-accept-unsigned-integer