转换程序以接受无符号整数

转换程序以接受无符号整数

本文介绍了转换程序以接受无符号整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了此程序来对输入的整数执行ulam猜想,但是当输入数字(例如38836)时,它超出了16位带符号整数的范围.我相信使用无符号整数可以解决我的问题,但是我无法弄清楚如何调整此代码段以接受无符号整数.任何帮助将不胜感激!

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

推荐答案

至少在我而言,此问题已通过使用单独的命令(将输入指定为未签名的命令,称为GETDEC $)解决.这样可以解决此问题,并允许无符号16位(而不是有符号)的整数范围.

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.

这篇关于转换程序以接受无符号整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 12:55