当前位置:首页 » 编程软件 » 汇编编程题

汇编编程题

发布时间: 2024-07-20 11:40:27

㈠ 姹傛眹缂栬瑷缂栫▼

;================================
ASSUME CS: C, DS: D
;--------------------------------
D SEGMENT
MSG1 DB 10, 13, 'Please input a num: $'
MSG2 DB 10, 13, 'Zheng Sum = $'
MSG3 DB 10, 13, ' FU Num = $'
FU DB 0
ZH DB 0
D ENDS
;--------------------------------
C SEGMENT ;浠g爜娈
START:
MOV AX, D
MOV DS, AX
;--------------------------------
MOV CX, 10
IN_X:
LEA DX, MSG1
MOV AH, 9 ;鏄剧ず瀛楃︿覆
INT 21H

MOV AH, 7 ;杈揿叆鍗曚釜瀛楃
INT 21H

CMP AL, '-'
JE IN_F ;璐熸暟
CMP AL, '0'
JB IN_X ;灏忎簬'0'锛屼笉鏄鏁板瓧
CMP AL, '9'
JA IN_X

MOV DL, AL
MOV AH, 2 ;鏄剧ず
INT 21H
MOV AL, DL

SUB AL, '0' ;杩桦师涓烘暟瀛
ADD ZH, AL ;姹傚拰
JMP IN_E
;--------------------------------
IN_F:
MOV DL, AL
MOV AH, 2 ;鏄剧ず
INT 21H
MOV AH, 7 ;杈揿叆鍗曚釜瀛楃.
INT 21H
CMP AL, '0'
JB IN_X ;灏忎簬'0'锛屼笉鏄鏁板瓧.
CMP AL, '9'
JA IN_X
MOV DL, AL
MOV AH, 2 ;鏄剧ず
INT 21H
INC BYTE PTR FU ;涓鏁板姞涓
IN_E:
LOOP IN_X
;--------------------------------
LEA DX, MSG2
MOV AH, 9 ;鏄剧ず瀛楃︿覆
INT 21H
MOV AL, ZH
MOV AH, 0
CALL DISP

LEA DX, MSG3
MOV AH, 9 ;鏄剧ず瀛楃︿覆
INT 21H
MOV AL, FU
MOV AH, 0
CALL DISP

MOV AH, 4CH ;鍒版ょ粨𨱒
INT 21H
;--------------------------------
DISP:
MOV BX, 10
MOV CX, 0
D_1:MOV DX, 0
DIV BX
ADD DL, '0'
PUSH DX
INC CX
CMP AX, 0
JNE D_1
MOV AH, 2
D_2:POP DX
INT 21H
LOOP D_2
RET
;--------------------------------
C ENDS
END START
;================================

绋嫔簭镓ц屽悗锛屾樉绀哄备笅锛

c:\masm510>M2

Please input a num: 2
Please input a num: 5
Please input a num: -5
Please input a num: -8
Please input a num: 6
Please input a num: 9
Please input a num: 4
Please input a num: 6
Please input a num: 0
Please input a num: 2
Zheng Sum = 34
FU Num = 2

;================================

㈡ 姹囩紪棰 姹傞珮镓

绗涓棰桡细涓嫔垪鍗佸叚杩涘埗鏁板垎鍒琚鐪嬩綔鏄琛ョ爜琛ㄧず镄勬湁绗﹀彿鏁板拰镞犵﹀彿鏁版椂锛屽畠浠镓琛ㄧず镄勫崄杩涘埗鏁版槸澶氩皯锛
鈶37H 55D 55D
鈶FDH -3D 253D
鈶A9H -87D 169D
鈶88H -120D 136D
绗浜岄桡细鎸囧嚭涓嫔垪鎸囦护涓镄勯敊璇锛
锛1锛塎OV DS锛0100H;绔嫔嵆鏁颁笉鑳界洿鎺ラ佹靛瘎瀛桦櫒
锛2锛塎OV BP锛孉L;灏哄镐笉鍖归厤
锛3锛塐UT 100H锛孉L;瓒呰繃255镄勭鍙e彿闇淇濆瓨鍦―X涓
锛4锛塎OV [BX+CX]锛2130H;1.CX涓嶈兘鐢ㄤ簬瀵勫瓨鍣ㄥ诲潃锛2.娌℃湁纭瀹氭搷浣沧槸瀛楄妭/瀛楁搷浣
锛5锛堿DD [BX+10]锛孾SI];鍐呭瓨鍗曞厓涔嬮棿涓嶈兘鐩存帴阃氢俊
锛6锛塜CHG AL锛学ORD PTR [BX];灏哄镐笉鍖归厤
锛7锛塕OR BX锛2;8086涓嶆敮鎸侊纴2闇瀛桦叆CL
锛8锛塂IV 100;镞犳硶纭瀹氭搷浣沧槸瀛楄妭/瀛楁搷浣
锛9锛塎OV CS锛孉X;浼间箮娌℃湁璇娉曢敊璇
锛10锛塎AIN PROC FAR

ENDP MAIN;鏄疢AIN ENDP
锛11锛塎OV BX锛孙FFSET VALUE[BX];OFFSET涓嶈兘搴斾粯澶嶆潅镄勫湴鍧琛ㄨ揪寮
锛12锛埘USH AL;PUSH鍙鑳芥槸瀛楁搷浣
锛13锛塁ODE SEGMENT
钬︹
CODEREA ENDS;娈靛悕涓嶅尮閰
锛15锛塎OV WORD_OP1锛学ORD_OP2;鍐呭瓨鍗曞厓涔嬮棿涓嶈兘鐩存帴阃氢俊

热点内容
cmcc怎么改密码 发布:2024-11-26 00:21:52 浏览:958
初学python的书籍 发布:2024-11-26 00:03:56 浏览:52
php大写转小写 发布:2024-11-25 23:52:55 浏览:46
安卓哪里下载游戏安全 发布:2024-11-25 23:51:08 浏览:284
白加黑源码 发布:2024-11-25 23:48:25 浏览:388
上传的壁纸 发布:2024-11-25 23:47:47 浏览:569
如何删除缓存的视频 发布:2024-11-25 23:44:54 浏览:435
编写刷课脚本 发布:2024-11-25 23:43:20 浏览:869
php图片缓存 发布:2024-11-25 23:41:36 浏览:953
android获取sd卡文件 发布:2024-11-25 23:39:34 浏览:151