0

I am following a basic tutorial from here: https://www.tutorialspoint.com/assembly_programming/assembly_arithmetic_instructions.htm

And the default code from here: https://www.jdoodle.com/compile-assembler-nasm-online

section .text

global _start

_start:

    mov     eax, [x]
    sub     eax, '0'
    mov     ebx, [y]
    sub     ebx, '0'
    add     eax, ebx
    add     eax, '0'

    mov     [sum], eax

    mov     ecx, msg
    mov     edx, len
    mov     ebx, 1
    mov     eax, 4
    int     0x80

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

    mov     eax, 1
    int     0x80

section .data
    x db '5'
    y db '3'
    msg db  "sum of x and y is "
    len equ $ - msg

segment .bss

    sum resb 1

But once the result is over 9 it refuses to print the result or prints some character (like > ;)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
beatrice
  • 3,684
  • 5
  • 22
  • 49
  • The example doesn't even try to work for results that would be more than 1 decimal digit, so I have to conclude that it isn't meant to work – harold Jul 26 '19 at 22:16
  • same result with sum resb 10, and mov edx,10 – beatrice Jul 26 '19 at 22:19
  • 1
    The method you used only works for single digits. Also, your code is wrong because it's using 4 byte accesses to 1 byte variables. – Jester Jul 26 '19 at 22:24

0 Answers0