1: character output
LDA AX, BUffer: offset address of the associated address buffer was added to the AX register, hexadecimal 80868088 register 20-bit physical address
MOV AX, BUffer; Similarly, it will be the 16-bit buffer address into the AX register
SEGMENT the DATAS STRS DB ' the Hello World! ' , 13 is , 10 , ' $ ' ; defines a string, reference is STRING, which is the address of the first character string. ; DB is represented by each character in the string is one byte, plus 1 for each next time, the address offset plus 1. ; 13 is CR carriage ; 10 wrap the LF ; $ as the end character string not the end of the output will be garbled DATAS eNDS STACKS SEGMENT Stack STACKS eNDS the ASSUME CS: CODE, DS: DATAS, SS: STACKS CODE SEGMENT main: MOV AX, DATAS ; initialization code MOV DS, AX ; initialization code The LEA the DX, STRS ; the offset address register is loaded with data STRS MOV the AH, . 9 ; . 9 of the output code the INT 21H ; execute interrupt MOV the AH, 4CH the INT 21H ; CODE ENDS End main
2: sequence control
Sequence control is one of the core conditions constitute the program, particularly the main explain here:
Z = ((3X + Y-5) / 2 wherein X = 15HY = 10H
The DATAS SEGMENT ; defined Z = ((3X + Y- 5) / 2 wherein X-= 15H the Y = 10H X-DW 15H the Y DW 10H ? The Z DW the DATAS ENDS the ASSUME the CS: CODE, the DS: the DATAS CODE SEGMENT main: MOV AX, the DATAS ; initialization code MOV the DS, AX ; initialization code MOV AX, X- SHL AX, . 1 the ADD AX, X- the ADD AX, the Y the SUB AX, . 5 SAR AX, . 1 MOV the Z, AX the LEA the DX, the Z MOV the AH, 02H; display output INT 21H MOV AH,4CH INT 21H; CODE ENDS end main
3: Basic Process Control
Psw representatives need to understand the status register mean, here only need to focus on the zero flag ZF
Where X is 2;
The DATAS SEGMENT ; defined X-= 2 X-DB 2 the Y DB? The DATAS ENDS the ASSUME the CS: CODE, the DS: the DATAS CODE SEGMENT main: MOV AX, the DATAS ; initialization code MOV the DS, AX ; initialization code the CMP X-, 0 the JGE that Lable1 ; > = 0 MOV the Y, - . 1 the JMP Next that Lable1: JZ lable2 ; = 0 MOV the Y, . 1 ; the JMP Next lable2: MOV the Y,0 next: MOV AX,0 MOV AH,4CH INT 21H; CODE ENDS end main