7月8日

    今天,学习了一下汇编,编了个小程序:计算 5+3=8

DATAS         SEGMENT                                                        ;定义数据段
FIVE              DB                 5                                                  ;定义FIVE字节单元内容为5
DATAS         ENDS                                                                 ;结束数据段定义
STACKS      SEGMENT    STACK                                       ;定义堆栈段
                      DB                  128  DUP(?)                             ;定义堆栈大小为128字节
STACKS      ENDS                                                                 ;结束堆栈段定义
CODES       SEGMENT                                                         ;定义代码段
                     ASSUME          CS:CODES,DS:DATAS          ;指示段寄存器应有的值
START: MOV     AX,DATAS                                                    ;DS初始化,数据段地址To AX
       MOV     DS,AX                                                                    ;AX内容To DS寄存器
       MOV     AL,FIVE                                                                 ;5 To AL
       ADD     AL,3                                                                       ;AL+3=05H+03H=08H To AL
       ADD     AL,30H                                                                  ;转换08H为ASCII码38H To AL
       MOV     DL,AL                                                                     ;DOS的INT21H功能调用中的
       MOV     AH,2                                                                        ;2号功能,显示1个字符    
       INT     21H                                                                          ;DOS的21H功能调用
       MOV     AH,4CH                                                                  ;返回DOS
       INT 21H                                                           
CODES  ENDS                                                                          ;结束代码段定义
       END START                                                                        ;START指明程序执行的入口地址

 

你可能感兴趣的:(汇编,dos)