Сборка на базе Intel Lang. Вывод из стека

Итак, на данный момент мой выход:

Площадь: 17 | Очки: 1 | Вероятность: 64 / 134519798

когда это должно быть:

Площадь: 1 | Очки: 17 | Вероятность: 1 / 64

Значения, помещенные в стек, идут от первого к последнему:

64

1

17

1

Итак, первым должен быть 1, затем 17...1....64. Похоже, что первая цифра игнорируется, поэтому я попытался исследовать ее, чтобы увидеть, что я могу найти, но у меня не получается. Я проверил значение переменной, которую я помещаю в стек.

%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

любая помощь будет оценена.

0 ответов

Другие вопросы по тегам