修改汇编语言程序,添加功能 使其能完成以下功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改汇编语言程序,添加功能 使其能完成以下功能相关的知识,希望对你有一定的参考价值。

1)输入带符号十进制,转换成十六进制补码显示。
1)输入十六进制补码,转换成带符号十进制真值显示。
DATA SEGMENT
MENU DB 'Please Input your Choice:',0dh,0ah
db '1:Bin -->Dec',0dh,0ah
db '2:Bin -->Hex',0dh,0ah
db '3:Dec -->Bin',0dh,0ah
db '4:Dec -->Hex',0dh,0ah
db'5:Hex -->Dec',0dh,0ah
db '6:Hex -->Bin',0dh,0ah
db '0:Exit. $',0dh,0ah

mess1db 'Please input a Binnumber:$'
mess2db 'Please input a Decnumber:$'
mess3db 'Please input a Hexnumber:$'
mess4db 'Output Bin is: $'
mess5db 'Output Dec is: $'
mess6db 'Output Hex is: $'

TABLE DW L0,L1,L2,L3,L4,L5,L6
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN PROC FAR
PUSH DS
XOR AX,AX
PUSH AX
MOV AX,DATA
MOV DS,AX
LKS:LEA DX,MENU
MOVAH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,39H
JBE LK1
SUB AL,7
LK1:AND AL,0FH
LEA SI,TABLE
MOV AH,0
SHL AX,1
ADD SI,AX
JMP [SI]
L1:CALL INBIN
CALL CRLF
CALL OUTDEC
CALLCRLF
JMP LKS
L2:CALL INBIN
CALL CRLF
CALL OUTHEX
CALL CRLF
JMP LKS

L3:CALL INDEC
CALL CRLF
CALL OUTBIN
CALL CRLF
JMP LKS
L4:CALL INDEC
CALL CRLF
CALL OUTHEX
CALL CRLF
JMP LKS

L5:CALL INHEX
CALL CRLF
CALL OUTDEC
CALL CRLF
JMP LKS
L6:CALL INHEX
CALL CRLF
CALL OUTBIN
CALL CRLF
JMP LKS

L0:RET
MAIN ENDP

CRLF PROC
MOV AH,02H
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
RET
CRLF ENDP

INBIN PROC
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV BX,0
INBL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZ INBEXIT
AND AL,01H
SHL BX,1
OR BL,AL
JMP INBL1
INBEXIT:RET
INBINENDP

INDEC PROC
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV BX,0
INDL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZ INDEXIT
SUB AL,30H
CMP AL,9
JBE INDL2
SUB AL,7
INDL2:MOV AH,0
XCHG AX,BX
MOV CX,10
MUL CX
ADD BX,AX
JMP INDL1
INDEXIT:RET
INDEC ENDP

INHEX PROC
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,0
IHL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZIHEXIT
SUB AL,30H
CMP AL,9
JBEIHL2
SUB AL,7
IHL2:MOV CL,4
SHL BX,CL
OR BL,AL
JMP IHL1
IHEXIT:RET
INHEX ENDP

OUTBIN PROC
LEA DX,MESS4
MOV AH,09H
INT 21H
MOV CX,16
OBL1:ROL BX,1
MOV DL,BL
AND DL,01H
OR DL,30H
MOV AH,02H
INT 21H
LOOP OBL1
RET
OUTBIN ENDP

OUTDECPROC
LEA DX,MESS5
MOV AH,09H
INT 21H
PUSH BX
MOV AX,BX
MOV DX,0;余数
MOV CX,10000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,1000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,100
DIV CX
MOV BX,DX
MOV DL,AL
ORDL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV CL,10
DIV CL
MOV BL,AH
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV DL,BL
OR DL,30H
MOV AH,02H
INT 21H
POP BX
RET
OUTDECENDP

OUTHEXPROC
LEA DX,MESS6
MOV AH,09H
INT 21H
MOV CX,4
OHL1:ROL BX,1
ROL BX,1
ROL BX,1
ROL BX,1
MOV DL,BL
AND DL,0FH
ADD DL,30H
CMP DL,39H
JBE OHL2
ADD DL,7
OHL2:MOV AH,02H
INT 21H
LOOP OHL1
RET
OUTHEX ENDP

CODE ENDS
END MAIN
急用,改好的万分感谢,请私信给我。。。又追加。。

参考技术A 你匿名无法私信,增加了2个新函数INDECS OUTDECS,大多在原函数上改的,改的地方有';'.

DATA SEGMENT
MENU DB 'Please Input your Choice:',0dh,0ah
db '1:Bin -->Dec',0dh,0ah
db '2:Bin -->Hex',0dh,0ah
db '3:Dec -->Bin',0dh,0ah
db '4:Dec -->Hex',0dh,0ah
db '5:Hex -->Dec',0dh,0ah
db '6:Hex -->Bin',0dh,0ah
db '0:Exit. $',0dh,0ah
mess1 db 'Please input a Binnumber:$'
mess2 db 'Please input a Decnumber:$'
mess3 db 'Please input a Hexnumber:$'
mess4 db 'Output Bin is: $'
mess5 db 'Output Dec is: $'
mess6 db 'Output Hex is: $'
TABLE DW L0,L1,L2,L3,L4,L5,L6
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN PROC FAR
PUSH DS
XOR AX,AX
PUSH AX
MOV AX,DATA
MOV DS,AX
LKS:LEA DX,MENU
MOV AH,09H
INT 21H
CALL CRLF ;
MOV AH,01H
INT 21H
CMP AL,39H
JBE LK1
SUB AL,7
LK1:AND AL,0FH
LEA SI,TABLE
MOV AH,0
SHL AX,1
ADD SI,AX
JMP [SI]
L1:CALL INBIN
CALL CRLF
CALL OUTDEC
CALL CRLF
JMP LKS
L2:CALL INBIN
CALL CRLF
CALL OUTHEX
CALL CRLF
JMP LKS
L3:CALL INDEC
CALL CRLF
CALL OUTBIN
CALL CRLF
JMP LKS
L4:CALL INDECS ;
CALL CRLF
CALL OUTHEX
CALL CRLF
JMP LKS
L5:CALL INHEX
CALL CRLF
CALL OUTDECS ;
CALL CRLF
JMP LKS
L6:CALL INHEX
CALL CRLF
CALL OUTBIN
CALL CRLF
JMP LKS
L0:RET
MAIN ENDP
CRLF PROC
MOV AH,02H
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
RET
CRLF ENDP
INBIN PROC
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV BX,0
INBL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZ INBEXIT
AND AL,01H
SHL BX,1
OR BL,AL
JMP INBL1
INBEXIT:RET
INBIN ENDP
INDEC PROC
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV BX,0
INDL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZ INDEXIT
SUB AL,30H
CMP AL,9
JBE INDL2
SUB AL,7
INDL2:MOV AH,0
XCHG AX,BX
MOV CX,10
MUL CX
ADD BX,AX
JMP INDL1
INDEXIT:RET
INDEC ENDP
INHEX PROC
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,0
IHL1:MOV AH,01H
INT 21H
CMP AL,0DH
JZ IHEXIT
SUB AL,30H
CMP AL,9
JBE IHL2
SUB AL,7
IHL2:MOV CL,4
SHL BX,CL
OR BL,AL
JMP IHL1
IHEXIT:RET
INHEX ENDP
OUTBIN PROC
LEA DX,MESS4
MOV AH,09H
INT 21H
MOV CX,16
OBL1:ROL BX,1
MOV DL,BL
AND DL,01H
OR DL,30H
MOV AH,02H
INT 21H
LOOP OBL1
RET
OUTBIN ENDP

OUTDEC PROC
LEA DX,MESS5
MOV AH,09H
INT 21H
PUSH BX
MOV AX,BX
MOV DX,0;余数
MOV CX,10000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,1000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,100
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV CL,10
DIV CL
MOV BL,AH
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV DL,BL
OR DL,30H
MOV AH,02H
INT 21H
POP BX
RET
OUTDEC ENDP
OUTHEX PROC
LEA DX,MESS6
MOV AH,09H
INT 21H
MOV CX,4
OHL1:ROL BX,1
ROL BX,1
ROL BX,1
ROL BX,1
MOV DL,BL
AND DL,0FH
ADD DL,30H
CMP DL,39H
JBE OHL2
ADD DL,7
OHL2:MOV AH,02H
INT 21H
LOOP OHL1
RET
OUTHEX ENDP
INDECS PROC
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV BX,0
INDLS1:MOV AH,01H
INT 21H
CMP AL, '-' ;
JNZ IDL2 ;
MOV BP, 1 ;
JMP INDLS1 ;
IDL2: ;
CMP AL,0DH
JZ INDEXITS
SUB AL,30H
CMP AL,9
JBE INDLS2
SUB AL,7
INDLS2:MOV AH,0
XCHG AX,BX
MOV CX,10
MUL CX
ADD BX,AX
JMP INDLS1
INDEXITS: ;
CMP BP, 1 ;
JNZ INDEXITS1 ;

XOR BX, 0FFFFH ;
ADD BX, 1 ;
XOR BP, BP ;
INDEXITS1: ;
RET
INDECS ENDP

OUTDECS PROC
LEA DX,MESS5
MOV AH,09H
INT 21H
CMP BX, 8000H ;
JB OTL1 ;
MOV DL, '-' ;
MOV AH, 2 ;
INT 21H ;
MOV AX, 0FFFFH ;
SUB AX, BX ;
ADD AX, 1 ;
XCHG AX, BX ;
OTL1: ;
PUSH BX
MOV AX,BX
MOV DX,0;余数
MOV CX,10000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,1000
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV DX,0
MOV CX,100
DIV CX
MOV BX,DX
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV AX,BX
MOV CL,10
DIV CL
MOV BL,AH
MOV DL,AL
OR DL,30H
MOV AH,02H
INT 21H
MOV DL,BL
OR DL,30H
MOV AH,02H
INT 21H
POP BX
RET
OUTDECS ENDP

CODE ENDS
END MAIN追问

菜单怎么显示呀??就是跟我给出的六个一样可以用菜单显示出来??

追答

我调试时能显示出菜单!!!

追问

我调试时只有六个菜单呀!!它是八个转换功能能呀!!就是把你帮我添加的功能再用菜单显示出来!!求解亲。。怎么添加呀。。怎么菜单显示呀???

追答

粗心了我只替换了原来4 5号功能,字符太多传附件里了,没调试看能通过不.- -

追问

亲。。错误太多了。。能不能再改正确。。万分感谢!!!

本回答被提问者采纳

以上是关于修改汇编语言程序,添加功能 使其能完成以下功能的主要内容,如果未能解决你的问题,请参考以下文章

cloudstack 添加新网卡使其能上网

用C语言编写程序,完成如下功能

汇编语言程序从设计到最后执行需经过哪几个步骤

汇编第一章总结

汇编13:int指令

编程语言的种类