Is it possible to show after dtoa
, the decimal places without writing an ASCII to floating-point conversion?
Includes: Header for prompts.
.DATA radius DWORD ? height DWORD ? volume DWORD ? p1 BYTE "Radius (Enter): ", 0 ; Prompt for a radius input p2 BYTE "Height (Enter): ", 0 ; Prompt for a height input string BYTE 40 DUP (?) ; Simple string variable rL BYTE "Volume (Result): ", 0 ; Result volume prompt vvv BYTE 11 DUP(?), 0 ; Eventually dota conversion, before output .CODE MainProc PROC sub rsp, 120 ; input p1, string, 40 ; Prompt one radius atod string ; Convert prompt one input mov radius, eax ; Move radius, eax input p2, string, 40 ; Prompt two height atod string ; Convert prompt two input mov height, eax ; Move height mov eax, radius ; Move radius mul eax ; Multiply eax mov radius, eax ; Move radius, eax mov eax, 22 ; Move eax mov ebx, radius ; Move ebx, radius mul ebx ; Multiple ebx mov bx, 7 ; Move bx div bx ; Divide bx mov ebx, eax ; Move ebx, eax mov eax, height ; Move eax, height mul ebx ; Multiply ebx mov ebx, eax ; Move ebx, eax mov eax, ebx ; Move eax, ebx mov bx, 3 ; Move bx, 3 div bx ; Divide 3 inc eax ; Increment eax mov volume, eax ; Move volume, eax dtoa vvv, eax ; Possible conversion, without rounding up result? output rL, vvv ; Output prompt result add rsp, 120 ; Add rsp, 120 mov rax, 0 ; mov rax, 0 ret ; Return MainProc ENDP END
Show's volume of a cone. Currently, this just raises, to a nearest whole number. 365.5 will be 370.
Input
Radius: 10 Height: 5
Expected
523.6
Actual
524
https://stackoverflow.com/questions/67352320/showing-decimal-places-ascii-dword-masm-x64-dtoa-conversion May 02, 2021 at 09:45AM
没有评论:
发表评论