Converting a program to accept unsigned integer

拥有回忆 提交于 2019-12-31 05:49:12

问题


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<-----

回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!