1、编制子程序:把AL寄存器内的二进制数用十六进制形式在屏幕上显示。(要求用简化段汇编语言实现) 如何使用汇编语言将BX寄存器内的二进制数用十六进制数的形式在...
\u6c47\u7f16\u5c0f\u95ee\u9898 \u4e00\u4e2a\u7a0b\u5e8f\u8981\u6c42\u7f16\u5236\u4e00\u4e2a\u7a0b\u5e8f\u628aBX\u5bc4\u5b58\u5668\u5185\u7684\u4e8c\u8fdb\u5236\u6570\u7528\u5341\u516d\u8fdb\u5236\u6570\u7684\u5f62\u5f0f\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u51fa\u6765\u8fd9\u4e2a\u65b9\u5f0f\uff0c\u662f\u5728DOS 2.0\u4e4b\u524d\uff0c\u8fd8\u6ca1\u6709\u51fa\u73b04CH\u53f7\u529f\u80fd\u8c03\u7528\u4e4b\u524d\u6240\u7528\u7684\u65b9\u5f0f\u3002
\u90a3\u65f6\u5019\uff0c\u9000\u51faDOS\u7a0b\u5e8f\uff0c\u7528\u7684\u662f INT 20H \u53f7\u4e2d\u65ad\u3002
\u4f46\u8fd9\u4e2a\u4e2d\u65ad\u80fd\u6b63\u786e\u6267\u884c\u7684\u524d\u63d0\uff0c\u662fCS\u5fc5\u987b\u662f\u7a0b\u5e8f\u52a0\u8f7d\u65f6\u7684PSP\u524d\u7f00\u7684\u6bb5\u5730\u5740\u3002
\u8fd9\u5bf9.com\u683c\u5f0f\u7684\u7a0b\u5e8f\uff0c\u6ca1\u6709\u95ee\u9898\u3002\u5b83\u52a0\u8f7d\u540eCS\u5c31\u662fPSP\u6240\u5728\u7684\u6bb5\u3002
\u5bf9.exe\u683c\u5f0f\u7684\u6587\u4ef6\uff0c\u52a0\u8f7d\u65f6CS\u88ab\u6307\u5411\u4e86\u7a0b\u5e8f\u5165\u53e3\u4ee3\u7801\u7684\u6bb5\u5730\u5740\uff0c\u76f4\u63a5\u7528 INT 20H\u5c31\u4e0d\u5bf9\u4e86\u3002
\u4e3a\u4e86\u89e3\u51b3EXE\u683c\u5f0f\u7684\u7a0b\u5e8f\u6b63\u786e\u8fd4\u56deDOS\u7684\u95ee\u9898\uff0c\u5c31\u4ea7\u751f\u4e86\u4f60\u63d0\u5230\u7684\u8fd9\u79cd\u7a0b\u5e8f\u6846\u67b6\u3002
\u9996\u5148\uff0c\u8981\u77e5\u9053\u4e24\u70b9\u9884\u5907\u77e5\u8bc6\uff1a
1. EXE\u7a0b\u5e8f\u52a0\u8f7d\u65f6\uff0cDS\u662f\u6307\u5411PSP\u524d\u7f00\u7684\u3002
2. PSP\u524d\u7f00\u603b\u957f100H\u4e2a\u5b57\u8282\uff0c\u5b83\u6700\u524d\u9762\u504f\u79fb\u5730\u5740\u4e3a0\u5904\u7684\u7b2c\u4e00\u6761\u4ee3\u7801\u6b63\u662f INT 20H
\u6846\u67b6\u662f\u8fd9\u6837\u7684\uff1a
MAIN PROC FAR ;\u8fd9\u91cc\u5fc5\u987b\u5c06\u8fc7\u7a0b\u5c5e\u6027\u5b9a\u4e49\u6210\u8fdc\u8c03\u7528\uff0c\u662f\u4e3a\u4e86\u4fdd\u8bc1\u6700\u540e\u7684RET\u662f\u8fdc\u8fd4\u56de
PUSH DS ; \u8fd9\u91cc\u5165\u6808\u7684DS\uff0c\u5c31\u662fPSP\u7684\u6bb5\u5730\u5740
SUB AX, AX ;
PUSH AX ; \u8fd9\u91cc\u5165\u6808\u7684 0 \u7528\u6765\u4f5c\u4e3a\u6307\u5411PSP\u7b2c\u4e00\u6761\u6307\u4ee4 INT 20H\u7684\u504f\u79fb\u5730\u5740\u4f7f\u7528
; \uff08\u8fd9\u91cc\u662f\u7a0b\u5e8f\u4e3b\u4f53\uff09
RET ; \u7531\u4e8e\u6bb5\u5c5e\u6027\u662fFAR\uff0c\u6240\u4ee5\u8fd9\u4e2a\u8fd4\u56de\u662f\u8fdc\u8fd4\u56de\u3002
; \u8fdc\u8fd4\u56de\uff0c\u662f\u4ece\u6808\u4e2d\u5f39\u51fa\u4e24\u4e2a\u5b57\uff0c\u9001IP\u548cCS\u3002
; \u56e0\u6b64\uff0c\u8fd9\u5c31\u662f\u5c06\u7b2c\u4e00\u6761\u6307\u4ee4\u7684\u90a3\u4e2aDS\u9001CS\uff0c\u4fdd\u8bc1\u4e86CS\u6307\u5411\u7a0b\u5e8f\u52a0\u8f7d\u65f6PSP
; \u800c\u4ece\u6808\u4e2d\u5f39\u51fa\u9001\u5165 IP \u7684\u5c31\u662f\u4e0a\u9762\u5165\u6808\u7684\u90a3\u4e2a0
;\u8fd9\u6837\uff0cRET \u6307\u4ee4\u6267\u884c\u540e\uff0c\u4e0b\u4e00\u6761\u6307\u4ee4 \u5c31\u662f PSP \u5934\u90e8\u7684\u90a3\u6761 INT 20H\uff0c\u4e14CS\u6b63\u786e\u3002
MAIN ENDP
\u8fd9\u91cc\uff0c\u6211\u6ca1\u6709\u5199\u51fa\u6bb5\u5b9a\u4e49\u90e8\u5206\uff0c\u4ee5\u53caASSUME\u7b49\u3002
\u6700\u540e\uff0cEND \u4f2a\u64cd\u4f5c\u540e\u9762\u8ddfMAIN\uff0c\u5c06MAIN \u6307\u5b9a\u4e3a\u7a0b\u5e8f\u7684\u5165\u53e3\u3002
\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0c\u8fd9\u79cd\u6846\u67b6\uff0c\u662f\u65e9\u5c31\u5e94\u5f53\u88ab\u6dd8\u6c70\u7684\u3002
\u6709\u4e864CH\u53f7DOS\u7cfb\u7edf\u529f\u80fd\u8c03\u7528\u4ee5\u540e\uff0c\u6839\u672c\u5c31\u4e0d\u5e94\u8be5\u518d\u4f7f\u7528\u8fd9\u79cd\u7e41\u7410\u3001\u6613\u51fa\u9519\u7684\u6846\u67b6\u3002
\u53ea\u662f\uff0c\u7f16\u5199\u6559\u6750\u7684\u4eba\uff0c\u5168\u662f\u4e00\u4e9b\u6284\u88ad\u6210\u6027\u3001\u4e0d\u8d1f\u8d23\u7684\u61d2\u4e1c\u897f\u3002 \u7b2c\u4e00\u4e2a\u4eba\u6284\u539f\u59cb\u7684\u624b\u518c\uff0c\u7b2c\u4e8c\u4e2a\u4eba\u6284\u7b2c\u4e00\u4e2a\u4eba\u7684\uff0c\u7b2c\u4e09\u4e2a\u4eba\u6284\u7b2c\u4e8c\u4eba\u4eba\u7684\u2026\u2026\u7ed3\u679c\uff0c\u76f4\u5230\u73b0\u5728\uff0c\u6211\u4eec\u8fd8\u80fd\u5728\u67d0\u4e9b\u4e66\u4e0a\u770b\u5230\u8fd9\u79cd\u5df2\u6210\u4e3a\u5783\u573e\u7684\u539f\u59cb\u4ee3\u7801\u3002
`
\u7a0b\u5e8f\u6ca1\u9519\u5440\uff0c\u6211\u76f4\u63a5\u590d\u5236\u8fc7\u6765\uff0c\u7528masm6.15\u7f16\u8bd1\u6210\u529f\uff0c\u8fd0\u884c\u6b63\u786e\u3002
.model small
.code
start:
mov al,2DH
mov ch,2
mov cl,4
mov ah,2
mov bl,al
p0:
rol bl,cl
mov dl,bl
and dl,0fh
cmp dl,9
jbe p1
add dl,7
p1:
add dl,30h
int 21h
dec ch
jnz p0
mov ah,4ch
int 21h
end start
绛旓細.model small.codestart: mov al,2DH mov ch,2 mov cl,4 mov ah,2 mov bl,alp0: rol bl,cl mov dl,bl and dl,0fh cmp dl,9 jbe p1 add dl,7p1: add dl,30h int 21h dec ch jnz p0 mov ah,4ch int 21hend start ...
绛旓細;disp_al瀛愮▼搴灏瀵勫瓨鍣ˋL涓殑鏁板间互鍗佸叚杩涘埗鏄剧ず鍑烘潵disp_al: mov dh, al mov bx, 2 ;bx鐢ㄤ簬寰幆,涓涓瓧鑺傛渶澶氬彲浠ユ樉绀烘垚涓や釜瀛楃,鎵浠ュ惊鐜鏁版槸2娆 mov cl, 4 ;棣栧厛鏄剧ず楂4浣,鍦ㄤ笅娆″惊鐜繘鍐嶆樉绀轰綆4浣 shr al, clagain: and al, 0fh cmp al, 9 ja hex add al, '0' ;濡傛灉灏忎簬9,鍔犱笂瀛楃...
绛旓細START:MOV AL, 0FH ;鍦ㄨ繖閲屽彲鍐 00H~0FH锛岃繖灏辨槸涓浣16杩涘埗鏁 AND AL, 0FH ;鏃犵敤浣嶆竻闆讹紝淇濈暀璇ユ暟瀛 ;涓嬮潰鏄彉鎴怉SCII鐮 CMP AL, 0AH JB NEXT ADD AL, 07H NEXT:ADD AL, 30H ;涓嬮潰鏄樉绀鸿緭鍑 MOV DL, AL ;閫佸埌DL MOV AH, 2 ;鏄剧ず鍗曚釜瀛楃 INT 21H ...
绛旓細clc lop: SHR al JNC ZZ INC DX ZZ: ROL DX DEC CL LOOP LOP SHR DX MOV AL,DL
绛旓細1.鐢ㄤ笁绉嶆柟娉曞疄鐜扮疮鍔犲櫒A涓瀵勫瓨鍣B鐨勫唴瀹逛氦鎹紵(1)XCH A,B (2)PUSH A PUSH B POP A POP B (3)MOV R0,A MOV A,B MOV B,R0 2.鐗囧唴RAM40H寮濮嬬殑鍗曞厓涓湁10涓簩杩涘埗鏁帮紝缂栫▼鎵惧嚭鍏朵腑鏈澶у煎苟瀛樹簬50H鍗曞厓涓.ORG 0000H MOV R0,#40H MOV R7,#10 MOV R2,#0;鏈澶у兼殏瀛 LOOP:MOV ...
绛旓細(1)鎶夾L瀵勫瓨鍣鐨勬渶鍚庝袱浣嶇疆0锛嶏紞锛岮ND AL锛1111 1100B (2)鎶夾L瀵勫瓨鍣ㄧ殑鏈鍚庝袱浣嶇疆1锛嶏紞锛峅R銆AL锛0000 0011B (3)鎶夾L瀵勫瓨鍣ㄧ殑鏈鍚庝袱浣嶅彇鍙嶏紞锛嶏紞XOR銆AL锛0000 0011B 鍙﹀锛氶鐩腑鐨勨滄渶鍚庝袱浣嶁濓紝涓嶇‘鍒囥傘搴旇璇粹滄渶浣庝袱浣嶁濄傚彟澶栵細棰樼洰涓殑 AL=45H锛岃繖鏉′欢锛屽苟娌℃湁鐢ㄥ銆
绛旓細xor ah, ah ;灏哸h鍒濆鍖栦负0 cmp al, 48 ;灏哸l涓'0'姣旇緝 jl exitc ;灏忎簬'0'鍒欒烦杞鍑 cmp al, 57 ;鍐嶅皢al涓'9'姣旇緝 ja exitc ;澶т簬'9'鍒欒烦杞鍑 ret ;杩斿洖 inc ah ;ah鍙樻垚1 exitc:ret ;杩斿洖 ...
绛旓細mov al, [2000h]sub al, 0fah pushf mov [3000h], al mov al, [1000h]popf sbb al, 0 mov [3001h], al
绛旓細1.XOR AL,0F0H OR AL,0FH 2.XOR AX,AX
绛旓細mov al,[0]鏄妸褰撳墠娈靛湴鍧涓亸绉诲湴鍧涓篬0]鐨勬暟鎹乤l瀵勫瓨鍣╩ov [0],al鏄鎶奱l瀵勫瓨鍣涓殑鏁版嵁閫佸綋鍓嶆鍦板潃涓亸绉诲湴鍧涓篬0]鐨勫湴鍧 杩欎袱涓兘娌¢敊娈靛瘎瀛樺櫒鍜屽瓨鍌ㄥ櫒涔嬮棿鏁版嵁鏄彲浠ョ浉浜掍紶閫佺殑骞朵笉鏄崟鍚戜紶閫 妤间富涓嶇悊瑙0]鍏跺疄[0]骞朵笉鏄崟鐙簡[0]鑰屾槸褰撳墠榛樿娈靛瘎瀛樺櫒鐨刐0]鍙峰亸绉诲湴鍧 ...