Advertisement
LincolnArantes

Somando 8 bytes e mostrando na tela

Dec 6th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Soma de 8 bytes
  2. ;Lincoln Cesar dos Reis Arantes
  3. ;https://www.tutorialspoint.com/compile_asm_online.php
  4.  
  5. section .text
  6.    global _start        ;must be declared for using gcc
  7.  
  8. _start:                 ;tell linker entry point
  9.  
  10.    mov     esi, 8       ;pointing to the rightmost digit
  11.    mov     ecx, 8       ;num of digits
  12.    clc
  13. add_loop:  
  14.    mov  al, [numero1 + esi]
  15.    adc  al, [numero2 + esi]
  16.    aaa
  17.    pushf
  18.    or   al, 30h
  19.    popf
  20.    
  21.    mov  [soma + esi], al
  22.    dec  esi
  23.    loop add_loop
  24.    
  25.    mov  edx,len         ;message length
  26.    mov  ecx,msg         ;message to write
  27.    mov  ebx,1           ;file descriptor (stdout)
  28.    mov  eax,4           ;system call number (sys_write)
  29.    int  0x80            ;call kernel
  30.    
  31.    mov  edx,9           ;message length
  32.    mov  ecx,soma            ;message to write
  33.    mov  ebx,1           ;file descriptor (stdout)
  34.    mov  eax,4           ;system call number (sys_write)
  35.    int  0x80            ;call kernel
  36.    
  37.    mov  eax,1           ;system call number (sys_exit)
  38.    int  0x80            ;call kernel
  39.  
  40. section .data
  41. msg db 'A soma é:',0xa
  42. len equ $ - msg        
  43. numero1 db '22389001'
  44. numero2 db '23456211'
  45. soma db  '        '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement