我正在编写一个简单的代码,以查找数组中的最大数量,我设法找到了最大数量,但某些内容不适用于打印,程序可以打印,但它可以打印其他内容,尽管正确的号码存储在AX中。我正在添加代码,如果您对我有任何提示,我将不胜感激。谢谢很多!
.MODEL SMALL
.STACK 100h
.DATA
ARR DW 1234h, 5678h, 0ff11h, 1111h, 2222h, 3333h, 4444h, 5555h, 6666h, 7777h, 8888h
N DW 11
temp DW 0
ten DW 10
ResultStr DB 'Max for unsign array is: ',13,10,'$' ; Result Str.
.CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, OFFSET ARR
MOV AX, [SI]
MOV CX, 10
;Loop to checks the unsignhed max
Checkmax:
MOV BX, [SI]
ADD SI, 2
CMP BX, AX
JA updateMax
LOOP Checkmax
ADD CX, 5
MOV SI, OFFSET ResultStr
ADD SI, 24
;Bloack for printing the max unsighned
printStr: ; Prints the final str needed for the program.
MOV DX, 0
DIV ten
ADD dx,'0'
MOV [SI], dl ; Pointer to the print place in the str.
INC SI
LOOP printStr
;Prints the str
MOV AH,9
MOV DX,OFFSET ResultStr
INT 21h
JMP endInput
;Block to update the unsighn max.
updateMax:
MOV AX, BX
JMP checkmax
endInput:
MOV AH,4Ch ; Set terminate option for int 21h
INT 21h ; Return to DOS (terminate program)
END