所以目前我的输出是:
面积:17 | 点数:1 | 概率:64 / 134519798
什么时候应该:
面积:1 | 点数:17 | 概率:1 / 64
压入堆栈的值从第一个到最后一个:
64
1
17
1
所以首先应该是 1,然后是 17...1....64。似乎第一个 1 被忽略了,所以我试图研究它,看看我能找到什么,但我做不到。我已经验证了我推入堆栈的变量有一个值。
%include "asm_io.inc"
;
;
segment .data
display db "Area: %d | Points: %d | Probability: %d / %d",10,0
number db "", 0
;
;
segment .bss
;
radius1 resd 1 ;Radius
radius2 resd 1
radius3 resd 1
radius4 resd 1
points1 resd 1 ;Points
points2 resd 1
points3 resd 1
points4 resd 1
compArea1 resd 1 ;Computed Area
compArea2 resd 1
compArea3 resd 1
compArea4 resd 1
pie1 resd 1 ;radius*radius
pie2 resd 1
pie3 resd 1
pie4 resd 1
pb1 resd 1 ;Probability
pb2 resd 1
pb3 resd 1
pb4 resd 1
eo resd 1 ; Expected Outcome
extra resd 1
;
;
segment .text
global asm_main
extern printf
asm_main:
enter 0,0
pusha
mov eax, number
call print_string
call read_int
mov [radius1], eax
mov eax, number
call print_string
call read_int
mov [radius2], eax
mov eax, number
call print_string
call read_int
mov [radius3], eax
mov eax, number
call print_string
call read_int
mov [radius4], eax
;****************Radius End****************
mov eax, number
call print_string
call read_int
mov [points1], eax
mov eax, number
call print_string
call read_int
mov [points2], eax
mov eax, number
call print_string
call read_int
mov [points3], eax
mov eax, number
call print_string
call read_int
mov [points4], eax
;****************Points End****************
mov eax, [radius1]
imul eax, [radius1]
mov [pie1], eax
mov eax, [radius2]
imul eax, [radius2]
mov [pie2], eax
mov eax, [radius3]
imul eax, [radius3]
mov [pie3], eax
mov eax, [radius4]
imul eax, [radius4]
mov [pie4], eax
;***************Area End*******************
mov eax, [radius1]
mov [compArea1], eax
mov eax, [pie2]
sub eax, [pie1]
mov [compArea2], eax
mov eax, [pie3]
sub eax, [pie2]
mov [compArea3], eax
mov eax, [pie4]
sub eax, [pie3]
mov [compArea4], eax
;***************Computed Area Ends*********
mov eax, [compArea1]
imul eax, [points1]
mov [pb1], eax
mov eax, [compArea2]
imul eax, [points2]
mov [pb2], eax
mov eax, [compArea3]
imul eax, [points3]
mov [pb3], eax
mov eax, [compArea4]
imul eax, [points4]
mov [pb4], eax
;******************************************
mov eax, [pb1]
add eax, [pb2]
add eax, [pb3]
add eax, [pb4]
mov [eo], eax
;***************Expected Outcome Ends******
sub esp, 10h
push dword [pie4]
push dword [compArea1]
push dword [points1]
push dword [radius1]
mov dword [esp], display
call printf
add esp, 10h
popa
mov eax, 0
leave
ret
任何帮助,将不胜感激。