;
;
;判断x+y是否溢出
; author: wangguolaing
; date: revised 4/14
.386
.MODEL FLAT
INCLUDE io.h
includelib Kernel32.lib
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
cr EQU 0dh
Lf EQU 0ah
.STACK 4096
.DATA
xnumber WORD ?
ynumber WORD ?
lable1 BYTE cr,Lf,Lf,'Overflow',0
lable2 BYTE cr,Lf,Lf,'No Overflow'
.CODE
_start:
;mov xnumber,67000000 ;大测试数据,证明溢出
;mov ynumber,870000
mov xnumber,670 ;小测试数据,证明无溢出
mov ynumber,8700
mov ax,xnumber
add ax,ynumber
jo noo
mov ax,0
jmp endth
noo:
;mov ax,1 ;产生了溢出
output lable1
jmp quit
endth :
output lable2
quit: INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code