输出不以其全文显示[8086装配] [英] The output is not displayed in its entirety [8086 assembly]
问题描述
;The number of repetition of each character in the string
.MODEL small
.STACK 100h
.DATA
msg3 db 13,10,'Enter a string up to 200 characters:$'
msg4 db ' $'
msg5 db 13,10,'Hit any key to exit',13,10,'$'
crlf db 13,10,'$'
char db 0
repet db 0
mone1 dw 0
mone2 dw 0
dig1 db 0
dig2 db 0
dig3 db 0
arr db 256 dup(0)
str db 200
strlen db 0
strtxt db 200 dup(0)
.CODE
mov AX,@data
mov DS,AX
call GetString
call UpdateArr
call Repetitions
call EndProject
GetString: lea DX,msg3 ;Show msg3 on screen
mov AH,09h
int 21h
lea DX,str ;Accept a string
mov AH,0ah
int 21h
lea DX,crlf ;New line for the output
mov AH,09h
int 21h
UpdateArr: xor CX,CX ;Nullify CX register
mov CL,strlen
cmp mone1,CX ;Compare the location of the character in str
string to the full length of str
jb Below ;If below, jump Below
ret
Below: lea SI,strtxt ;Reach a character in str string
add SI,mone1
mov CL,[SI]
mov char,CL ;Move the character from CL to char operand
inc mone1 ;Increase mone1 in one
lea BX,arr ;Nullify CX register
mov CL,char
add BX,CX
inc [BX] ;Increace the ascii value place of the character
in arr counter array in one
jmp UpdateArr
Repetitions: lea BX,arr ;Reach the several iterations of each ascii
character
add BX,mone2
xor CX,CX
mov CL,[BX]
mov repet,CL ;Move the several iterations from CL to repet
operand
inc mone2
cmp repet,0 ;Compare repet to zero
je Repetitions ;If there is no repetition at all, jump to
Repetitions
xor AX,AX ;Nullify AX register
xor BX,BX ;Nullify BX register
mov AL,repet
mov BL,10 ;Divide AL by 10, result in AL, rest in AH
div BL
mov dig3,AH ;Move the rest of the devision in AH to dig3
operand
mov AH,0 ;Nullify AH
mov BL,10 ;Divide the result in AL by 10, new result in AL,
rest in AH
div BL
mov dig2,AH ;Move the rest of the devision in AH to dig2
operand
mov dig1,AL ;Move the result of the devision in AL to dig1
operand
add dig1,'0' ;Change digit from binary to ascii
add dig2,'0'
add dig3,'0'
lea BX,msg4 ;Put address of msg4 in BX
dec mone2 ;Decreace mone2 in one
mov AX,mone2
mov [BX],AL ;Put mone2 (the ascii character) in msg4
inc mone2 ;Increace mone2 in one
mov AL,'('
mov [BX+1],AL ;Put '(' in msg4
mov AL,dig1
mov [BX+2],AL ;Put dig1 in msg4
mov AL,dig2
mov [BX+3],AL ;Put dig2 in msg4
mov AL,dig3
mov [BX+4],AL ;Put dig3 in msg4
mov AL,')'
mov [BX+5],AL ;Put ')' in msg4
lea DX,msg4 ;Show output line msg4
mov AH,09h
int 21h
cmp mone2,256 ;Compare mone2 to 256
jle Repetitions ;If not all the ascii characters were checked,
jump to Repetitions
ret
EndProject: lea DX,msg5 ;show msg5 on screen
mov AH,09h
int 21h
mov AH,01h ;read a char
int 21h
mov AH,4CH ;end program
int 21h
ret
END
输入是一个字符串,最多200个字符(STR)。它那张串并increace计数器阵列(ARR)中的字符串中的每个字符的ASCII值位置。
输出是每个ASCII字符[256字符(计数器阵列的长度)]的几次迭代。
例如:
The input is a string up to 200 characters ("str"). It goes on the string and increace the ascii value location of each character in the string in the counter array ("arr"). The output is the several iterations of each ascii character [256 characters (the length of the counter array)]. For example:
A(005)3(016)%,(109)
a(005)3(016)%(109)
问题是,如果我写超过五个字符,它会显示只有五人,而不是其余的(全部)。
什么是在code中的问题?
The problem is that if I write more than five characters, it displays just five of them and not the rest (all of them). What is the problem in the code?
重要的细节 -
mone1
表示C1与 mone2
表示计数器2
mone1
means counter1 and mone2
means counter2
感谢您!
推荐答案
您子程序的GetString:
缺少 RET
指令。因此落空至 UpdateArr:
这不返回,但随后再次调用,所以谁知道有效果,我不打算去探索,看它是否满足观察到的行为。
Your subroutine GetString:
lacks a ret
instruction. So it falls through to UpdateArr:
which does return, but is then called again, so who knows what effect that has, I am not going to explore to see if it satisfies the observed behaviour.
这篇关于输出不以其全文显示[8086装配]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!