Skip to content

Instantly share code, notes, and snippets.

@sanjibnarzary
Created January 11, 2012 12:53
Show Gist options
  • Save sanjibnarzary/1594520 to your computer and use it in GitHub Desktop.
Save sanjibnarzary/1594520 to your computer and use it in GitHub Desktop.
Character Input Output in ASM using NASM in UBUNTU Linux
;Author : Sanjib Narzary
;Institute: NIT Calicut
;Email: [email protected]
;Assembly Code
section .data
;New line string
NEWLINE: db 0xa, 0xd
LENGTH: equ $-NEWLINE
section .bss
INPT: resd 1
section .text
global _start
_start:
;Read character
mov eax, 0x3
mov ebx, 0x1
mov ecx, INPT
mov edx, 0x1
int 80h
;print character
mov eax, 0x4
mov ebx, 0x1
mov ecx, INPT
mov edx, 0x1
int 80h
;Print new line after the output
mov eax, 0x4
mov ebx, 0x1
mov ecx, NEWLINE
mov edx, LENGTH
int 0x80
;Terminate
mov eax, 0x1
xor ebx, ebx
int 0x80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment