我寫了一個例程(作爲代碼的一部分),即使它必須ret也不會回退。爲什麼程序不停止(ret)而在循環中繼續? [assembly]
這是例行:
rout3: lea SI,strtxt ;put the array in indirect addressing register
add SI,counter ;add a counter (starts from 0)
mov CL,[SI] ;move the character in counter location in the
array to CL register
mov char,CL ;move the character from the register to an operand
inc counter ;increase counter for the next character (next location)
lea BX,arr ;new counter array (size: 256 ascii characters).
put the array in the register
mov CL,char ;instead of the counter, the ascii value of the
character is the location
add BX,CX ; add the location (the ascii value- up to 256)
inc [BX] ;increase the value of the ascii location (in the array) by one
mov CL,strlen ;move the length of the first array (strtxt) to CL register
cmp counter,CX ;compare the currect location of the character
to the full length of it
jb rout3 ;if the location is smaller than the strtxt array length,
go to the next character. if not- ret.
ret
我與"jb rout 3"
的一部分,並與ret
一個問題。即使計數器等於或大於strlen(數組的長度),程序也會重新啓動。 請幫助我,當你幫我時,我花了很長時間才寫出瞭解釋你的理解的代碼。
謝謝你,美好的一天!
從我所看到的JB中可以看出,JB使用2個操作數。如果第一個操作數中指定的位的值爲1,則JB指令分支到第二個操作數中指定的地址。被測試的位未被修改。沒有標誌受此指令的影響。[來自[8051指令集手冊](http://www.keil.com/support/man/docs/is51/is51_jb.htm) – MikeT
)如果不是8051,但是80x86可以顯示更多有可能。如果在下面,JB是jmp。計數器(從0開始並遞增)可能不會低於CX(從未使用80x86,所以不確定,但我懷疑這是問題所在)。 – MikeT
@MikeT:根據所有的說明,這看起來像8086/8088 –