Display characters in assembly language

One code implementation

;SAMPLE PROGRAM DISPLAY MESSAGE          ;注释行

 STACK      SEGMENT PARA STACK 'STACK'      ;定义堆栈段
              DB 1024 DUP (0)                ;在存储器的某个区域建立一个堆栈区
 STACK      ENDS

 DATA       SEGMENT                   ;定义数据段
 MESSAGE   DB 'THIS IS A SAMPLE PROGRAM. $'  ;在存储器中存放供显示的数据
DATA        ENDS                                         ;数据段结束

CODE        SEGMENT                          ;定义代码段
MAIN  PROC  FAR                                 ;将程序定义为远过程
             ASSUME  CS:CODE,DS:DATA,SS:STACK  ;告诉汇编程序段范围
 START:  
            PUSH DS
            MOV AX,0                         ;可用XOR AX,AX
            PUSH AX                           ;标准序,以便返回DOS操作系统
            MOV AX,DATA
            MOV DS,AX              ;初始化DS     
            LEA DX, MESSAGE                    ;MESSAGE 地址偏移量给DX
            MOV  AH,9
            INT     21H               ;调用 DOS 9号中断功能显示字符串。
            RET                        ;返回DOS 操作系统
    MAIN      ENDP                                  ;过程结束
      CODE     ENDS                                  ;代码段结束
        END MAIN                    ;整个程序汇编结束



   MAIN  ENDP
      CODE   ENDS
              END  MAIN

Insert picture description here
2. Running result
Insert picture description here
3. Debugging, it
Insert picture description here
Insert picture description here
can be inferred that the address of the AX memory is 0000. By searching and comparing the ASCII code, the content is: THIS IS A SAMPLE PROGRAM. As with the running result, the content displayed on the screen is the same, and the result is correct. .

Guess you like

Origin blog.csdn.net/weixin_43789635/article/details/112981920