LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2010, 01:19 AM   #1
rhklinux
Member
 
Registered: Jan 2010
Location: india/pune
Distribution: Arch Fedora20
Posts: 126

Rep: Reputation: 18
Question i want to write a simple character printing program using NASM plz help !


I am a newbie is asm !
i tried a code to accept a character and print the same !
i can accept it with following code but its not working with printing that character
i use NASM version 2.07
code:
Code:
segment .data
msg1: db 'Enter a key',10
msg1len: equ $-msg1

msg2: db 'the key entred is',10
msg2len: equ $-msg2



segment .text
global _start

_start:

mov eax,4
mov ebx,1
mov ecx,msg1
mov edx,msg1len
int 80h

call getchar
call putchar

mov eax,1
mov ebx,0
int 80h

getchar:

pushad 

pushfd 

mov eax, 3 

mov ebx, 0 

mov ecx, esi 

mov edx, 2 

int 80h 

popfd 

popad 

ret 

putchar:

pushad

pushfd

mov eax,4
mov ebx,1
mov ecx,esi
mov edx,2
int 80h

popfd

popad

ret
 
Old 07-27-2010, 02:01 AM   #2
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
I'm not familiar with system call parameters under Linux, so can't help you with most of your program, but what are the "mov ecx,esi"'s for? YOu don't do anything with ESI in the rest of the program, as far as I can see - are you hoping it'll have some particular value which the "int 80h" will need?
 
Old 07-27-2010, 08:53 AM   #3
rhklinux
Member
 
Registered: Jan 2010
Location: india/pune
Distribution: Arch Fedora20
Posts: 126

Original Poster
Rep: Reputation: 18
actually i got this code from a forum !
 
Old 07-28-2010, 01:52 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
so, answer my question

(and also answer the email I sent you )
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A small useful program written in NASM for a bash session. dakoder LinuxQuestions.org Member Success Stories 3 03-30-2010 06:03 PM
printing a character to file Completely Clueless Linux - Newbie 23 08-16-2009 11:10 AM
How to write a simple C program in Linux to download a web page? rajeshcurl Linux - Software 3 04-09-2009 07:55 AM
CUPS not printing character JMJ_coder Linux - Software 6 03-23-2007 02:36 PM
Simple mathmatics written in Assembly code using nasm amon Programming 3 01-24-2007 12:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration