MASM32で3234567890に5を追加しようとしています。完全なサンプルコードは次のとおりです。
;--------------------------------------------------------------------------
include \masm32\include\masm32rt.inc
.data
;--------------------------------------------------------------------------
.code
start:
call main ; branch to the "main" procedure
exit
main proc
local pbuf: DWORD
local buffer[32]: BYTE
mov pbuf, ptr$(buffer)
mov ecx, uval("5") ; converting string to unsigned dword and storing in ecx
mov ebx, uval("3234567890") ; converting string to unsigned dword and storing in ebx
invoke udw2str, ebx, pbuf ; converting unsigned value to string and storing results in pbuf
print pbuf, 13,10 ; everything is fine so far - 3234567890
add ecx, ebx
invoke udw2str, ebx, pbuf ; once again coverting
print pbuf, 13,10 ; negative number
ret
main endp
end start ; Tell MASM where the program ends
符号なしのdwordに何かを追加する正しい方法は何ですか?現在、負の数を取得しており、期待される結果は3234567895です。
更新: 問題は実際に使用されたMACROのどこかにありました。サンプルを最小限に編集しましたが、正しく機能しました。ここに謎はありません。:)
;--------------------------------------------------------------------------
include \masm32\include\masm32rt.inc
.data
;--------------------------------------------------------------------------
.code
start:
call main ; branch to the "main" procedure
exit
main proc
local pbuf: DWORD
local buffer[40]: BYTE
local nNumber: DWORD
mov pbuf, ptr$(buffer)
mov ecx, 5 ; no need to convert anything at this point
mov ebx, 3234567890 ; no need to convert anything at this point
add ebx, ecx
invoke udw2str, ebx, pbuf ; now converting result in ebx to the string (pointed by pbuf)
print pbuf, 13, 10 ; printing pbuf, success
ret
main endp
end start ; Tell MASM where the program ends
みんな、ありがとう!