私はルーチンを(コードの一部として)書きましたが、retを取らなければならないときにも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は2つのオペランドを_によって使用します。第1オペランドで指定されたビットの値が1の場合、JB命令は第2オペランドに指定されたアドレスに分岐します。この命令の影響を受けるフラグはありません._ [8051命令セットマニュアル](http://www.keil.com/support/man/docs/is51/is51_jb.htm) – MikeT
8051ではなく80x86のように見えますおそらく。以下の場合、JBはjmpです。カウンター(0から始まってインクリメントされる)がCX以下になることはほとんどありません(80x86を使用したことはありませんが、問題はどこにあるのでしょうか)。 – MikeT
@MikeT:これはすべての指示に基づいています。8086/8088 –