Advertisement
LincolnArantes

Somando valores e mostrando na tela

Dec 5th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Somando dois valores e mostrando na tela
  2. ; Lincoln Cesar dos Reis Arantes
  3. ; 32 Bits - https://www.tutorialspoint.com/compile_asm_online.php
  4.  
  5.  
  6. section .text
  7.    global _start     ;must be declared for linker (gcc)
  8.    
  9. _start:          ;tell linker entry point
  10.  
  11.  
  12.    ;Primeiro valor 
  13.    mov eax, '7'
  14.    sub eax, '0'
  15.    ;Segundo valor  
  16.    mov ebx, '2'
  17.    sub ebx, '0'
  18.  
  19.    ;soma abaixo
  20.    add eax, ebx
  21.    ;adicione '0' para converter a soma de decimal para ASCII
  22.    add eax, '0'
  23.  
  24.    ;gravando o resultado na variavel resultado
  25.    mov [resultado], eax
  26.  
  27.    ; mostrando o resultado da soma (printando na tela)
  28.    mov eax, 4      
  29.    mov ebx, 1
  30.    mov ecx, resultado        
  31.    mov edx, 1        
  32.    int 0x80
  33.    
  34.    
  35.    mov  eax,1    ;system call number (sys_exit)
  36.    int  0x80     ;call kernel
  37.    
  38. section .bss
  39.  
  40. resultado resb 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement