⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiafachengxu.txt

📁 可实现简单的加法运算功能 范围-32768~~~32767
💻 TXT
字号:
; This sample gets two numbers
; from the user, calculates the
; sum of these numbers,
; and prints it out.

#make_COM#

include 'emu8086.inc'

ORG     100h

; skip variable declaration:
JMP     START

; declaration of variable:
num  DW ?

START:

; get first number:
CALL    PTHIS
DB 13, 10, 'Calculation Range: [-32768..32767]', 13, 10
DB 13, 10, 'Enter first number: ', 0

CALL    scan_num

; keep first number:
MOV     num, CX

; get second number:
CALL    PTHIS
msg2 DB 13, 10, 'Enter second number: ', 0

CALL    scan_num


; add numbers:
ADD     num, CX
JO      overflow


; print the result:
CALL    PTHIS
DB 13, 10, 'The sum is: ', 0

MOV     AX, num
CALL    print_num

JMP     exit

; process overlow error:
overflow:
   
   PRINTN 'We have overflow!'


exit:

RET

;=================================
; here we define the functions
; from emu8086.inc

; SCAN_NUM reads a
; number from the user and stores
; it in CX register.

DEFINE_SCAN_NUM

; PRINT_NUM prints a signed
; number in AX.
; PRINT_NUM_UNS prints an unsigned
; number in AX (required by 
; PRINT_NUM):

DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS

; PTHIS prints NULL terminated
; string defined just after
; the CALL PTHIS instruction:
DEFINE_PTHIS

;=================================
END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -