Advertisement
obernardovieira

Copy variable value and print

Feb 7th, 2015
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;this is completely by me
  2. ;if you want to know more, visit
  3. ;http://www.oocities.org/codeteacher/x86asm/asml1002.html
  4. ;and
  5. ;http://www.tutorialspoint.com/assembly_programming/assembly_arithmetic_instructions.htm
  6.  
  7. section .data           ;initialized variables
  8.     letraA db 'A',0xa   ;our letter and \n
  9.     lenletraA equ $-letraA  ;length in bits
  10.  
  11. segment .bss            ;uninitialized variables
  12.     letra resw 1    ;reserve memory space for one letter
  13.  
  14. section .text
  15.     global _start
  16.    
  17. _start:
  18.  
  19.     mov ax, [letraA]    ;mov the letter A to ax
  20.     mov [letra], ax     ;mov ax to new variable
  21.     ;we also can use eax, but i use ax because it
  22.     ;use just 16bits and eax use 32
  23.     ;to print without \n you also can use al (8bits)
  24.    
  25.     mov eax, 4      ;sys_write
  26.     mov ebx, 1      ;stdout
  27.     mov ecx, letra      ;our variable to output
  28.     mov edx, lenletraA  ;length of output
  29.     int 0x80        ;call hernel to print
  30.    
  31.     mov eax, 1      ;sys_exit
  32.     mov ebx, 0      ;tell the system it's everything ok
  33.     int 0x80        ;call kernel to finisih program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement