The first program in IBM(hello world)
反思:
-
D
S
DS
DS一定要弄好
- 字符串以美元符号结尾。
S1 SEGMENT STACK
DW 40H DUP(?)
TOP LABEL WORD
S1 ENDS
S2 SEGMENT
hello DB 'Hello World$' ;rember to add '$'
CRLF DB 0DH,0AH,24H
S2 ENDS
S3 SEGMENT
ASSUME CS:S3, DS:S2, SS:S1
P4 PROC FAR
MOV AX, S1
MOV SS, AX
LEA SP, TOP
MOV AX, S2
MOV DS, AX
LEA DX, CRLF
MOV AH, 9H
INT 21H
LEA DX, hello
MOV AH, 9H
INT 21H
MOV AH,4CH
INT 21H
S3 ENDS
END P4
The second program in IBM(对于一个数,之后以2进制输出)
S1 SEGMENT STACK
DW 30H DUP(?)
TOP LABEL WORD
S1 ENDS
S2 SEGMENT
V3 DW 27452
S2 ENDS
S5 SEGMENT
ASSUME CS:S5, DS:S2, SS:S1
P6 PROC FAR
MOV AX,S1
MOV SS,AX
MOV SP, OFFSET TOP
MOV AX, S2
MOV DS,AX
MOV CX, 16
MOV BX, V3
XOR DX, DX
L7: ROL BX,1
MOV DL,1
AND DL,BL
ADD DL,30H
MOV AH, 2
INT 21H
LOOP L7
MOV AH,4CH
INT 21H
P6 ENDP
S5 ENDS
END P6
第3个程序(求平均数)
S1 SEGMENT STACK
DW 40H DUP(?)
TOP LABEL WORD
S1 ENDS
S2 SEGMENT
LIST DW 10,10000,7
DW 21020,-30,3213
DW 389,213,5435
AVER DW ?
S2 ENDS
S3 SEGMENT
ASSUME CS:S3, DS:S2, SS:S1
MAIN PROC FAR
MOV AX, S1
MOV SS, AX
MOV AX, S2
MOV DS, AX
LEA SI, LIST
MOV CX, [SI]
ADD SI, 2
XOR BX, BX
MOV BP, BX
L4: MOV AX, [SI]
CWD ;this is expand the digit of the half res digits
ADD BP, AX
ADC BX, DX
ADD SI, 2
LOOP L4
MOV DX, BX
MOV AX, BP
IDIV [LIST]
MOV [AVER], AX ; the lowbit put consult
MOV DX, AX
; BINARY OUTPUT in decimal
MOV AH, 4CH
INT 21H
S3 ENDS
END MAIN