Chinaunix首页 | 论坛 | 博客
  • 博客访问: 675611
  • 博文数量: 156
  • 博客积分: 3402
  • 博客等级: 中校
  • 技术积分: 1639
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-13 14:06
个人简介

业余编程爱好者

文章分类

全部博文(156)

文章存档

2014年(1)

2013年(13)

2012年(46)

2011年(38)

2010年(58)

分类: WINDOWS

2011-12-31 20:16:07

为了编写更强壮的汇编代码,更方便的表述算法,我使用HLA--高阶汇编语言。下面的代码表述了一个强输入函数,接收一个int16型的数字,并返回在屏幕上。若遇到不符合要求的输入,则给出异常提示,继续等待用户输入。

program testBadInput;
#include( "stdlib.hhf" )

static
u: int32;
GoodInteger: boolean;

begin testBadInput;

repeat

mov( false,GoodInteger );
try

stdout.put( "Enter a signed integer:" );
stdin.get( u );
mov( true,GoodInteger );
stdout.put( "You entered: ", u, nl );

 exception( ex.ConversionError )
stdout.put( "Your input contained illegal characters", nl );

 exception( ex.ValueOutOfRange )

   stdout.put( "The value was too large", nl );
endtry;

until( GoodInteger );

end testBadInput;
阅读(1906) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~