汇编语言编写一个程序,实现十进制、十六进制和二进制之间的转换 如何用汇编程序实现二进制,十进制,十六进制之间的转换
\u6c47\u7f16\u8bed\u8a00\u5c06\u4e8c\u8fdb\u5236\u8f6c\u5316\u4e3a\u5341\u516d\u8fdb\u5236\u7684\u529f\u80fd \uff0c\u4ee3\u7801\u6bcf\u4e00\u53e5\u5728\u4e8c\u8fdb\u5236\u8f6c\u5316\u4e3a\u5341\u516d\u8fdb\u5236\u4e2d\u8d77\u5230\u4ec0\u4e48\u4f5c\u7528?MAIN PROC FAR
ASSUME CS:A1
START: PUSH DS
SUB AX,AX
PUSH AX
MOV BX,0110 1101 0011 0111B ;6D37H
MOV CH,4
B1: MOV CL,4
ROL BX,CL ;\u5c06BX\u4e2d\u7684\u6570\u5faa\u73af\u5de6\u79fb4\u4f4d,\u4e5f\u5c31\u662f\u628aBX\u6700\u9ad84\u4f4d,\u653e\u5230BX\u7684\u6700\u4f4e4\u4f4d\u4e0a\u53bb\u3002
MOV AL,BL ;\u5c06\u4f4e8\u4f4d\u653e\u5165AL
AND AL,0FH ;\u53d6\u4f4e4\u4f4d
ADD AL,30H ;\u52a0\u4e0a30H \u4ece\u8fd9\u91cc\u5f00\u59cb\u5c064\u4f4d\u4e8c\u8fdb\u5236\u6570\u8f6c\u621016\u8fdb\u5236ASCII\u7801,
;0--\u7684ASCII\u7801\u662f30H\u20269\u662f39H,A\u662f41H,B\u662f42H\u2026F\u662f46H
CMP AL,3AH ;\u52a0\u7ed3\u679c\u662f\u4e0d\u662f\u5c11\u4e8e3A
JL B2 ;\u662f\u7684\u8bdd,\u8868\u793a\u662f0-9\u4e4b\u4e2d\u6570
ADD AL,7H ;\u5426\u5219\u8fd8\u8981\u52a0\u4e0a7,\u53d8\u6210\u5bf9\u5e94\u7684A\u6216B\u3001C\u3001D\u3001E\u3001F
B2: MOV DL,AL ;AL\u662f\u8f6c\u6362\u597d\u7684\u4e00\u4f4d16\u8fdb\u5236\u6570\u7684ASCII\u7801
MOV AH,2
INT 21H ;\u663e\u793a\u5230\u5c4f\u5e55
DEC CH
JNZ B1 ;\u56e0\u4e3aBX\u4e2d\u5176\u67094\u4f4d16\u8fdb\u5236\u6570,\u6240\u4ee5\u8981\u5904\u74064\u6b21\u3002\u8fd9\u91cc\u662f\u5224\u65ad\u5904\u7406\u5b8c4\u6b21\u6ca1,\u5982\u679c\u6ca1\u6709,\u5c31\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u4e2a\u6570
RET
MAIN ENDP
A1 ENDS
END START
\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u529f\u80fd\u662f\u5c06BX\u4e2d\u76840110 1101 0011 0111B(6D37H)\u4ee516\u8fdb\u5236\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002
\u201c\u663e\u793a\u5728\u5c4f\u5e55\u201d\u7684\u51c6\u786e\u8bf4\u6cd5\u662f:\u8f93\u51fa\u5230\u7cfb\u7edf\u6807\u51c6\u63a7\u5236\u53f0\u4e0a\u3002
\u4e0d\u77e5\u9053\u6211\u8bf4\u6e05\u695a\u6ca1,\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60
\u4e8c\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u8f6c\u6362\uff0c\u4e5f\u5c31\u662f\u5c06\u4e8c\u8fdb\u5236\u6309\u56db\u4f4d\u5212\u5206\u4e00\u6bb5\uff0c\u7136\u540e\u7528\u5341\u516d\u8fdb\u5236\u8868\u793a\uff0c\u672b\u5c3e\u52a0\u4e0aH\u5c31\u53ef\u4ee5\u4e86\u3002
\u5341\u516d\u8fdb\u5236\u8f6c\u4e3a\u4e8c\u8fdb\u5236\u5219\u5c06\u5341\u516d\u8fdb\u5236\u7684\u6bcf\u4e00\u4f4d\u7528\u4e8c\u8fdb\u5236\u8868\u793a\uff0c\u4e3a\u56db\u4f4d\u4e00\u6bb5\uff0c\u6309\u987a\u5e8f\u5199\u4e0b\u6765\u672b\u5c3e\u52a0\u4e0aB\u5c31\u662f\u4e86\u3002
\u5341\u8fdb\u5236\u4e48\uff0c\u5c31\u662f\u65e5\u5e38\u7528\u7684\u81ea\u7136\u6570\uff0c\u8ba1\u7b97\u51fa\u4e8c\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u7684\u6570\u503c\uff0c\u5c31\u53ef\u4ee5\u4e86\u3002\u5f53\u7136\u672b\u5c3e\u53ef\u4ee5\u52a0\u4e0aD\u6216\u4ec0\u4e48\u4e5f\u6ca1\u6709\u3002
CODE SEGMENT
ASSUME CS:CODE
STRR DB 18
STRRN DB ?
STRRS DB 18 DUP(?)
START: PUSH CS
POP DS
PUSH CS
POP ES
CALL INPUT
CALL LFCR
CALL LFCR
MOV BX,10
CALL DSPAXX
CALL LFCR
MOV BX,16
CALL DSPAXX
CALL LFCR
MOV BX,2
CALL DSPAXX
MOV AH,4CH
INT 21H
;================================
INPUT PROC NEAR
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH BP
PUSHF
MOV AH,0AH
LEA DX,STRR
INT 21H
LEA SI,STRR
MOV CL,[SI+1]
XOR CH,CH
ADD SI,2
CMP BYTE PTR[SI],'B'
JE @B
CMP BYTE PTR[SI],'H'
JE @H
CMP CX,5
JBE @1
MOV CX,5
@1:
MOV AX,0
@2:
SHL AX,1
MOV BX,AX
SHL AX,1
SHL AX,1
ADD AX,BX
MOV BL,[SI]
AND BL,0FH
XOR BH,BH
ADD AX,BX
INC SI
LOOP @2
JMP @IEND
@B:
DEC CX
INC SI
CMP CX,16
JBE @B1
MOV CX,16
@B1:
MOV AX,0
@B2:
SHL AX,1
MOV BL,[SI]
AND BL,1
XOR BH,BH
ADD AX,BX
INC SI
LOOP @B2
JMP @IEND
@H:
DEC CX
INC SI
CMP CX,4
JBE @H1
MOV CX,4
@H1:
MOV AX,0
@H2:
SHL AX,1
SHL AX,1
SHL AX,1
SHL AX,1
MOV BL,[SI]
CMP BL,'9'
JBE @H3
SUB BL,7
@H3:
AND BL,0FH
XOR BH,BH
ADD AX,BX
INC SI
LOOP @H2
@IEND:
POPF
POP BP
POP DI
POP SI
POP DX
POP CX
POP BX
RET
INPUT ENDP
;================================
; 输出ax的值,输出的进位制在bx中设定,bx=2~16
DSPAXX PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
XOR CX,CX
; MOV BX,16
@DSPAXX_1:
XOR DX,DX
DIV BX
INC CX
OR DX,30H
PUSH DX
CMP AX,0
JNE @DSPAXX_1
MOV AH,2
@DISPAXX_2:
POP DX
CMP DL,3AH
JB @DISPAXX_3
ADD DL,7
@DISPAXX_3:
INT 21H
LOOP @DISPAXX_2
MOV DL,32
INT 21H
POPF
POP DX
POP CX
POP BX
POP AX
RET
DSPAXX ENDP
;===============================
LFCR PROC NEAR
PUSH AX
PUSH DX
MOV AH,2
MOV DL,13
INT 21H
MOV DL,10
INT 21H
POP DX
POP AX
RET
LFCR ENDP
;=================================
DSPAX PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
XOR CX,CX
MOV BX,10
@DSPAX1:
XOR DX,DX
DIV BX
INC CX
OR DX,30H
PUSH DX
CMP AX,0
JNE @DSPAX1
MOV AH,2
@DISPAX2:
POP DX
INT 21H
LOOP @DISPAX2
MOV DL,32
INT 21H
POPF
POP DX
POP CX
POP BX
POP AX
RET
DSPAX ENDP
;==================================
CODE ENDS
END START
人物图(版本三)人物图(版本三)(7)
绛旓細鏈嬪弸,鎴戞潵鍛婅瘔浣犵瓟妗!鍦姹囩紪璇█涓浠ュ崄杩涘埗鏁版樉绀涓涓瀵勫瓨鍣ㄧ殑鍐呭锛岄渶瑕佷緷娆″垎绂诲嚭瀹冪殑涓囥佸崈銆佺櫨銆佸崄銆佷釜浣嶆暟瀛楀苟杞崲涓哄搴旂殑ASCII鐮佹墠鑳芥樉绀恒傛瘮濡傝浠ュ崄杩涘埗鏄剧ずDL涓殑鍐呭鐨绋嬪簭娈典负锛歁OVAL,DLXORAH,AHMOVBL,100DIVBL;AL涓殑鍟嗕负鐧句綅鏁癕OVDL,ALORDL,30H;杞崲涓篈SCII鐮丮OVAL,AHMOVAH,02H;...
绛旓細cmp dl,1;鏍℃鏈楂樹綅 jnz T4 or dl,30h mov [di],dl;鏈夎繘浣,缃1 jmp T5 T4: mov byte ptr [di],20h;鍘绘帀鍓嶅0 T5: ret subs_c: ;[鍘熷垱]澶氫綅鍔犳硶鏍稿績瀛绋嬪簭 mov al,[si];鏈浣庝綅瀵归綈 mov ah,[si+6]and ax,0f0fh add al,ah;鑷姞 add al,dl;鍔犲悗闈㈣繘浣 aam;浜屽寲鍗 mov...
绛旓細浠10杩涘埗褰㈠紡鏄剧ず16杩涘埗鏁 MOV AH,4CH INT 21H LFCR DB 10,13,'$' ;===; 閿洏杈撳叆鏁板兼暟缁勫瓙绋嬪簭锛堟暟缁勫悕涓篴rray锛屽厓绱犱釜鏁板瓨鏀惧湪num涓級 INPUTNUM PROC NEAR PUSH AX PUSH BX PUSH CX ...
绛旓細;灏嗭紙0~9)鍒嗗埆杞寲涓哄ぇ鍐欑殑鑻辨枃瀛楃A~J銆傚搴斿叧绯绘槸0杞崲涓篈锛1杞崲涓築锛2杞崲涓篊锛...渚濇绫绘帹 ;銆備富绋嬪簭鐨勫姛鑳芥槸鎺ユ敹閿洏杈撳叆鐨勫瓧绗︺傛瘡鎺ユ敹涓涓闃挎媺浼暟瀛楀悗灏辫皟鐢ㄦ暟鐮佽浆鎹㈠瓙绋嬪簭锛浠庤屽湪灞忓箷;涓婃樉绀鸿浆鎹㈠悗鐨勫ぇ鍐欒嫳鏂囧瓧绗 ;鐢∕ASM5.0缂栬瘧閫氳繃锛屽洖杞︾粨鏉熺▼搴 data segment CRLF DB 0dh,0ah,...
绛旓細'$' MSG2 DB 10,13,' ','$' BBB: PUSH CS POP DS LEA DX,MSG1 MOV AH,9 INT 21H LEA BX,X MOV AX,0 PUSH
绛旓細0ah int 10h call printBin mov ah,4ch int 21h;read input decimal number;store in bxreadn proc near mov bx,0 mov cx,10 mov si,0r0: mov ah,7 int 21h cmp al,0dh jz r3 cmp al,'0' jb r0 cmp al,'9' ja r0 mov ah,0eh int 10h and al...
绛旓細杈撳叆涓涓澶氫綅鍗佸叚杩涘埗鏁帮紝鏄剧ず绛夊肩殑鍗佽繘鍒躲傝緭鍏ュ瓧绗︼紝闇瑕佸噺鍘 37H 鎴 30H锛屽彉鎹负鍗佸叚杩涘埗鏁板瓧銆傚啀缁勬垚涓涓浣嶆暟銆傛樉绀轰箣鍓嶏紝鍒欓渶瑕佺浉鍙嶇殑鍙樺寲銆傛湰绋嬪簭鍏锋湁瀵硅緭鍏ユ暟鎹繘琛屽悎娉曟у垽鏂殑鍔熻兘銆傝緭鍏ラ潪鍗佸叚杩涘埗鏁扮殑绗﹀彿鏃讹紝鏈▼搴忓皢涓嶅仛鍙嶅簲銆
绛旓細DATA SEGMENT DATA1 DB 32H, 39H, 30H, 35H, 34H DATA2 DB 33H RESULT DB 6 DUP(00H)DATA ENDS STACK SEGMENT STACK鈥橲TACK鈥橲TA DB 30 DUP(?)TOP EQU LENGTH STA STACK ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA, SS:STACK, ES:...
绛旓細鐢ㄦ眹缂栬瑷鎶婁簩杩涘埗鏁拌浆鎹㈡垚鍗佽繘鍒舵暟锛屽洜涓轰笉鐭ラ亾鐢ㄤ粈涔圕PU锛屾墍浠ユ垜鍙兘鎶婄敤姹囩紪璇█鎶婁簩杩涘埗鏁拌浆鎹㈡垚鍗佽繘鍒舵暟鐨勬柟娉曞憡璇変綘锛岀敱浣犺嚜宸辨潵缂栧啓姹囩紪璇█銆傜敤姹囩紪璇█鎶婁簩杩涘埗鏁拌浆鎹㈡垚鍗佽繘鍒舵暟鐨勬柟娉曟槸锛氾紙1锛夋妸瀛樻斁鍗佽繘鍒舵暟BCD鐮佺殑瀵勫瓨鍣ㄦ竻闆躲傦紙2锛夋妸瀛樻斁鍗佽繘鍒舵暟BCD鐮佺殑瀵勫瓨鍣ㄥ唴瀹瑰鍒跺埌鍔犳暟瀵勫瓨鍣ㄣ傦紙3...
绛旓細3. 灏嗗垰鎵嶇殑浣欐暟闄や互100锛屽緱鍒扮殑鍟嗘槸鐧句綅鏁帮紝浣欐暟鏆傚瓨璧锋潵銆傚皢鎵寰楃殑鍟嗚浆鎴怉SCII鐮侊紝杈撳嚭鏄剧ず銆4. 灏嗗垰鎵嶇殑浣欐暟闄や互10锛寰楀埌鐨勫晢鏄崄浣嶆暟锛屼綑鏁版槸涓綅鏁帮紝鏆傚瓨璧锋潵銆傚皢鎵寰楃殑鍟嗚浆鎴怉SCII鐮侊紝杈撳嚭鏄剧ず銆5. 灏嗗垰鎵嶇殑浣欐暟杞垚ASCII鐮侊紝杈撳嚭鏄剧ず銆傝繖涓棶棰樹竴鑸笉鐢ㄥ惊鐜瀹炵幇锛鍥犱负寰幆瀹炵幇骞朵笉鑳借绋嬪簭...