前の質問へのフォローアップ。私はx86に2つの手続きを書こうとしています。 1つのプロシージャは、特定のベースの整数(ReadInteger)を読み込み、次に別のベースに書き込むもの(WriteInteger)を読み込みます。私が苦労しているところは、実際のコードよりも解決策に関連しています。x86アセンブリベース番号の変換
最初に、ReadIntegerは任意のベースから数値を取り込むことができます(例1234、ベース5)。その後、WriteIntegerは、その整数をeaxで、新しい基本値をblで取り、それを新しいベースに変換できなければなりません。私が質問しているところでは、ReadIntegerプロシージャーや別のプロシージャーのすべてを共通のベース(小数点以下)に変換し、WriteIntegerの整数と新しい基本値しか取り込めないので変換する必要がありますか?私が行方不明の別の方法がありますか?私はそれを行うための他の方法は考えられないようですが、それよりも単純なように割り当てが読み込まれます。
ここまでは私のコードです。レジスタ内の
;-----------------------------------------------------
ReadInteger PROC
;
; ReadInteger is passed one argument in bl representing the base of the number to be input.
; Receives: bl register (original base)
; Returns: EAX
;-----------------------------------------------------
nextChar:
mov edx, 0 ; prepare for divide
mov base, ebx
call ReadChar ; Get the next keypress
call WriteChar ; repeat keypress
call AsciiToDigit
div base
shl ebx,1 ; shift to make room for new bit
or ebx,base ; set the bit to eax
cmp al, 13 ; check for enter key
jne nextChar
mov eax, ebx ; place integer value in eax for return
ret
ReadInteger ENDP
;-----------------------------------------------------
WriteInteger PROC
;
; Will display a value in a specified base
; Receives: EAX register (integer), bl (new base)
; Returns: nothing
;-----------------------------------------------------
mov ecx, 0 ; count the digits
nextDigit:
mov edx, 0 ; prepare unsigned for divide
div ebx
push edx ; remainder will be in dl
inc ecx ; count it!
cmp eax, 0 ; done when eax becomes 0
jne nextDigit
; pop them off and convert to ASCII for output
outDigit:
pop eax ; digits come off left to right
add eax, '0' ; add 0 to get ASCII
call WriteChar
loop outDigit
call Crlf
ret
ret
WriteInteger ENDP
最初に高水準言語でそれを行う方法を知りませんか? x86アセンブラは、数学的アルゴリズムをプロトタイプ化するのに適した言語ではありません –