- 1、本文档共32页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
汇编语言程序设计例子(国外英文资料)
汇编语言程序设计例子(国外英文资料)
A typical case of assembly language programming
Sequential programming
Example: input two Numbers (0-9) from the keyboard to output them. X1 has been validated. P41
CODE SEGMENT
ASSUME CS: CODE
ORG 100 h
Main: MOV AH, 1
INT 21 h
MOV BL, AL
MOV AH, 2
MOV DL, 0 dh
INT 21 h
MOV DL, 0 ah
INT 21 h
MOV AH, 1
INT 21 h
SUB AL, 30 h
SUB BL, 30 h
The MUL BL
MOV BL, 10
DIV BL
The ADD AX, 3030 h
MOV BX, AX
MOV AH, 2
MOV DL, 0 dh
INT 21 h
MOV DL, 0 ah
INT 21 h
MOV DL, BL
MOV AH, 2
INT 21 h
MOV AH, 2
MOV DL, 0 dh
INT 21 h
MOV DL, 0 ah
INT 21 h
MOV DL, BH
MOV AH, 2
INT 21 h
MOV AH, 4 ch
INT 21 h
CODE ENDS
END the Main
Binary program
1 simple branch
Example: there is a 16-bit unsigned number in AX, and there is an 8-bit unsigned number in BL, 1P50
Write the program that adds them to the DX.
Two road branch
Example: write a program that puts a large unsigned number of BX and DX into a AX. (X2 has been validated) 1P51
The DATA SEGMENT
BUF1 DW? ,?
The DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
LEA SI, BUF1
MOV BX, [SI]
INC SI
MOV DX, [SI]
CMP BX, DX
JA Lab1
MOV AX, DX
JMP Lab2
Lab1: MOV AX, BX
4 ch Lab2: MOV AH,
INT 21 h
CODE ENDS
END the START
Branch of complex conditions
Example: read two figures from the keyboard and print the product. P52 (X1 validated)
CODE SEGMENT
ASSUME CS: CODE
ORG 100 h
MOV AH, 1; Read the first number from the keyboard
INT 21 h
CMP AL, 0
JB Lab1
CMP AL, 9
JA Lab1
MOV BL, AL
MOV AH, 2
MOV DL, 13 h
INT 21 h
MOV DL, 10 h
INT 21 h
MOV AH, 1; Read the second number from the keyboard
INT 21 h
CMP AL, 0
JB Lab1
CMP AL, 9
JA Lab1
SUB AL, 30 h; Restore the number of ASCALL codes to Numbers
SUB BL, 30 h; Restore the number of ASCALL codes that are read in first
MUL BL; Two number
MOV BL, 10;
DIV BL; The tens place and the ones place
The ADD AX, 3030 h; Product into ASCALL yards
MOV BX, AX
MOV AH, 2
MOV DL, 13 h; enter
INT 21 h
MOV DL, 10 h; A newline
INT 21 h
MOV DL, BL; Output display ten
MOV AH, 2
INT 21 h
MOV
文档评论(0)