B
B
biso2020-06-11 15:09:51
assembler
biso, 2020-06-11 15:09:51

When you try to add 14 and 3.08 in place of the correct answer, it gives out letters and replaces some characters. How to fix?

ps If you set a number and the answer is less than 10, then the answer gives normally 5ee21ea124e7c342096140.png5ee21eac34a3b503175284.png

The code itself:

section .text
global _start

_start: 
    mov eax,'14'
    sub eax, '0'

    mov ebx, '3.08'
    sub ebx, '0'
    add eax, ebx
    add eax, '0'
    
    mov [sum], eax
    mov ecx,0
    mov edx,1
    mov ebx,1 
    mov eax,4 
    int 0x80 

    mov ecx,sum
    mov edx, 6
    mov ebx,1 
    mov eax,4 
    int 0x80 

    mov eax,1 
    int 0x80 

section .data
segment .bss
sum resb 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-06-11
@galaxy

What kind of nightmare is this, anyway? Who taught you how to convert a string to a number:

mov eax,'14'
sub eax, '0'

?
Yes, it will work for single digits, for two or more digits it will be complete nonsense ( here it is approximately written why).
Well, adding floats in the same way - you have to think of it ... You know about the existence of FPU, don't you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question