试用汇编语言编写一个程序,把存放在BX寄存器内的值(二进制数)用十六进制数的形式在屏幕上显示出来。 如何使用汇编语言将BX寄存器内的二进制数用十六进制数的形式在...
\u8bd5\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\u3002(\u6c47\u7f16\u8bed\u8a00)mov ax,bx
call asc16
;.............................
.exit
asc16:push ax
mov al,ah
call asc8;\u663e\u793aal
pop ax
asc8:push ax
shr al,4
call asc4;\u663e\u793aal\u4f4e4\u4f4d
pop ax
asc4:and al,0fh
add al,'0'
cmp al,'9'
jbe asc1
add al,7;\u53d8\u6362\u5230A-F
asc1:mov dl,al
mov ah,2
int 21h;\u663e\u793a1\u4e2aascii
ret
\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
DATA SEGMENTSTR DB 'H',0AH,0DH,'$'
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV BX,1111110111100001B
MOV CH,4 ;循环四次
LOP: MOV CL,4
ROL BX,CL ;每次循环环左移四位
MOV DX,BX
AND DL,0FH ;每次取低四位,来表示一个十六进数
ADD DL,30H ;转化成为ASSIC码
CMP DL,3AH ;判断DL是否大于10的ASSIC码(A+30H)
JB NEXT
ADD DL,7 ;大于10再加上7
NEXT: MOV AH,2
INT 21H
DEC CH
JNZ LOP
MOV DX,OFFSET STR
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
;怎么你们问的都是相同的一些问题?
;16进制数输出,用MASM5.0编译通过
data segment
s1 db 4 DUP(0)
S2 db '$'
data ends
code segment
assume cs:code, ds:data
main proc far
start:
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
;-------------------------
MOV BX,0E78BH ;这里可改成任意16进制数
MOV DI,OFFSET S2
MOV CH,4
NEXT:
PUSH BX
CALL CZR
DEC DI
MOV [DI],BL
POP BX
MOV CL,4
SHR BX,CL
DEC CH
JNZ NEXT
MOV AH,09 ;
MOV DX,OFFSET S1
INT 21H
RET
MAIN ENDP
;----------------------
CZR PROC NEAR
AND BX,0FH
CMP BL,9
JG IS_AF
ADD BL,30H
JMP N1
IS_AF:
ADD BL,40H-9
N1:
RET
CZR ENDP
;-----------------------
code ends
end main
绛旓細璇曠敤姹囩紪璇█缂栧啓涓涓▼搴,鎶瀛樻斁鍦˙X瀵勫瓨鍣ㄥ唴鐨勫(浜岃繘鍒舵暟)鐢ㄥ崄鍏繘鍒舵暟鐨勫舰寮忓湪灞忓箷涓婃樉绀哄嚭鏉ャ 榫欑伂铏 | 娴忚4293 娆 |涓炬姤 鎴戞湁鏇村ソ鐨勭瓟妗堟帹鑽愪簬2017-12-15 13:21:23 鏈浣崇瓟妗 DATA SEGMENT STR DB 'H',0AH,0DH,'$'CODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV...
绛旓細DATM: MOV DPTR,#2000H CLR C MOV A,40H SUBB A,41H JC DATM1 MOV A,41H MOVX @DPTR,A INC DPTR MOV A,40H MOVX @DPTR,A RETDATM1锛 MOV A,40H MOVX @DPTR,A INC DPTR MOV A,41H MOVX @DPTR,A RET ...
绛旓細MOV DPTR,#1000HMOVX A,@DPTRANL A,#0FHMOV B,AMOV DPTR,#1001HMOVX A,@DPTRANL A,#0F0HORL A,BMOV P2,A
绛旓細浣跨敤MOVS鎸囦护锛屽鍒跺唴瀛樺崟鍏冦侱S:SI鎸囧悜婧愶紝ES:DI鎸囧悜鐩爣 渚嬶細DATA SEGMENT BUFA db 'abcdefgh',0DH,0AH,'$'BUFB db 8 dup(?),0DH,0AH,'$'DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA, ES:DATA START:MOV AX,DATA MOV DS,AX MOV ES,AX MOV CX,8 MOV SI,OFFSE...
绛旓細LEA SI,BUFF1 MOV AL,[SI]LEA SI BUFF2 MOV [SI],AL
绛旓細MOV DPTR, #0000H MOV R0, #20H LP:MOVX A, @DPTR MOV @R0, A INC DPTR INC R0 CJNE R0, #71H, LP SJMP END
绛旓細functionPrintBXinHEX:mov cx,12 ;浠庨珮浣嶅紑濮嬭緭鍑,鏈楂樹綅闇瑕佸彸绉12浣 push bx ;淇濆瓨BX loop1:rcr bx,cl ;閫氳繃鍙崇Щ,灏嗛渶瑕佽緭鍑虹殑4涓2杩涘埗浣嶇Щ鍒癇X鐨勬渶浣4浣嶄笂 loop2:and bx,0fh ;鍙朆X鐨勪綆4浣 add bx,30h ;鍔犱笂30H,鎹㈢畻鎴愮浉搴旂殑ASCII鐮 cmp bx,3ah ;鏄笉鏄9浠ヤ笅...
绛旓細; 鏈绋嬪簭閫氳繃缂栬瘧锛岃繍琛屾纭 Code Segment Assume CS:Code,DS:Code CR equ 000DH LF equ 000AH KBBack equ 0008H Name_Len equ 18 ;鐢ㄦ埛鍚嶆渶澶ч暱搴 Pass_Len equ 8 ;瀵嗙爜鏈澶ч暱搴 ; 锛嶏紞锛 ; 灏嗙敤鎴峰悕鍜屽瘑鐮佸畾涔変负涓涓缁撴瀯绫诲瀷 User Struc ; 鎴愮哗鍗曠粨鏋勭被鍨 Use...
绛旓細sumdw10 dup(?)dseg ends cseg segment assume ds:dseg, cs:cseg START:mov ax, dseg mov ds, ax mov cx, lengthof array1 lea bx, array1 lea si, array2 lea di, sum loopadd:mov ax, [bx]add ax, [si]mov [di], ax add bx, 2 add si, 2 add di, 2 loop loopadd mov...
绛旓細杩欎釜杩樹笉绠鍗#include<stdio.h>void main(){ float a,b,c,s;/*瀹氫箟鏁版嵁绫诲瀷锛屾暟鎹垵濮嬪寲*/s=(a*b+c)/a;/*璁$畻骞舵妸璁$畻缁撴灉璧嬪肩粰s*/printf("s=%f\n",s);/*杈撳嚭璁$畻缁撴灉*/}