HLA高级汇编 进入高级汇编语言的世界 第一篇

成败成屡败兰兰白绿回百汇

1,HLA标识符以下划线,字母开头,后面接0个或多个字母,数字字符下划线,HLA标识符是区分大小写的,HLA不能声明只存在大小写差异的两个名称。

2,hellworld程序

program helloworld;

#include("stdlib.hhf")

begin helloworld;

stdout.put("helloworld, assembly of all world",nl);

end helloword;


3,静态变量的声明:

static:

   i8:    int8             :=0;

   i16:   int16         :=1600;

   i32:   int32          :=320000;

变量的声明通常在主程序开始之前

stdput.put允许有多个参数,如果指定了一个整形值,那么在输出时候,stdout.put会把这个值转换成它的   字符串  形式

stdin.get(i8)该语句从键盘读入一个值,把他转换成 i8 的形式,存储到i8中

4,HLA使用一个字节来表示布尔值,可以使用任何可以直接操作8位值的任何指令来处理他们。

5,基本指令: mov(源,目的)它只是复制,源操作数和目的操作数长度相同。。。                                      add(源,目的)  sub(源,目的)

6,if语法

if(表达式)then   。。。。。。 elseif(表达式)then 。。。。else。。。。endif

7,布尔操作时候的&&,||,!

操作符&&采用从左到右的方式求值,,,逻辑与操作符比逻辑或的优先级高,!操作符只能做寄存器或者布尔变量的前缀:不能作为更大表达式的一部分,,想要实现时得加括号,,,HLA也提供了&和|操作符 他们和&&,|||完全不同

8,while(表达式)do。。。。。。。endwhile

循环体执行完语句后,重新在执行直到表达式为false为止

9,for(式子)do。。。。。。endfor

10,repeat。。。。。until(表达式)

如果表达式为false,则重复循环

11,break  和breakif(表达式)

12,forever。。。endfor该语句创建了一个无限循环

forever

      stdout.put("enter a interger less than 10:");

      stdin.get(i);

      breakif(i<10);

      stdout.put("this value need less to 10",nl);

     endfor;

13,try .......exception.......endtry

如果try和第一个exception之间的语句(受保护的模块)在执行过程中没有出现问题,则直接执行endtry后面的.

保护程序,不接受错误用户的输入

repeat

   mov (false,goodinteger);

   try

     stdout.put("enter a integer:");

     stdin.get(i);

     mov (true,goodeinterfer);

     exception(ex.concersionerror);

     stdout.put("illegal numeric value,please re_enter,",nl);

     exception(ex.valueoutofrange);

     stdout.put("illegal numeric value,please re_enter,",nl);

     endtry;

 until(goodinteger);

 
excepts.hhf头文件提供了很多异常处理的情况。
http://tech.163.com/06/0328/10/2D9VS3U100091SBR.html

http://blog.sina.com.cn/s/blog_6b136940010129hl.html

14,stdout.newln向标准输出设备输出一个换行序列,在功能上于stdout.put(nl);等效

15,stdout.putiX将一个参数作为带符号的整数值输出

stdout.puti8(-123);

stdout.puti16(dx);

16,stdout.putiXSIZE将指定的值作为带符号整形常量输出到标准设备,但是指定域宽,和填充字符

stdout.puti8Size(value8,width,padchar);

width为负数则左对齐,不然右对齐,padchar是一个字符值,字符常量通常用单引号括起来

使用stdout.puti32Size以表列形式输出值

    program   haha

  #include("stdlib.hhf")

   var   

     i32:   int32;

    colcnt: int8;

begin   haha ;

    mov(96,i32);

    mov (0,colcnt);

    while(i32>0)do

         if(colcnt=8) then

         stdout.newln();

         mov(0,colcnt);

         endif;  

   stdout.puti32Size(i32,5,'  ');

   sub(1,i32);

   add(1,colcnt);

   endwhile();

 stdout.newln();

end haha;

17,使用stdout.put也可以输出时候指定域宽stdout.put(i32:5);但是不能指定填充字符,默认为空格字符

18,stdin.getc()从标准输入设备的输入缓冲区读取下一个字符,他将该字符返回给cpu的al寄存器、

19,stdin.getiX,分别从标准输入设备读取8位,16位,32位的带符号整形值,并将它们返回到al,ax,eax中

20,调用stdin.getc()或者stdin.geti32()样输入历程时,程序不必从用户那里读取数据,而是HLA从从用户那里读取一整行文本,并将输入内容存入缓冲区,对于输入历程会从缓冲区读取数据,知道缓冲区为空为止。

21,hla标准库提供了stdin.readLn(),stdin.flushIuput()可以控制标准输入缓冲区。stdin.radln()表示放弃输入缓冲区的内容,直接要求用户输入一行新的文本,stdin.flushinput()表示仅仅放弃缓冲区的内容。。。。通常在标准输入历程之前,,,而在标准输入之后调用stdin.flushinput();

22,stdin.get

stdin.get(intval,anotherintval);   stdin.get将输入数据直接存储到参数列表制定的参数列表中,它并不将值返回给寄存器,除非指定了一个寄存器作为参数。stdin.get参数必须是变量或寄存器

23,try..endtry产生异常存放在eax寄存器中,于exception中的异常ID进行比较

 

 

 




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值