Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Assembly Language
This is the forum to discuss the Wrox book Professional Assembly Language by Richard Blum; ISBN: 9780764579011
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Assembly Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 28th, 2007, 12:21 PM
Registered User
 
Join Date: Jan 2007
Location: Glasgow, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Integer I/O in assembly

This might sound like a stupid question but is there a way to output integer values just using assembly and linux system calls without having to use the printf command and by extension the c library functions.

This is part of a project at university and we would like to have assembly that performs calculations and gets a 32 bit integer result and then output that result to standard output. The project group would prefer to do it without having to link it with the c libraries.

If this can be done I'd appreciate it, some help on how to do it. If it can't be done I'd appreciate being told that too, and I'll just use printf.

Thanks in advance

  #2 (permalink)  
Old May 10th, 2007, 05:15 PM
Registered User
 
Join Date: May 2007
Location: Calgary, AB, Canada.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First make sure that you can write a byte to stdio. Put 65 in a register and print it. You should see a 'A' on the screen.

What you need to do is divide the number by the radix (presumably 10) and save the remainder and the quotient. save the remainder on a stack. Divide the new quotient by the radix - save the new remainder. Repeat until the quotient is 0.

What you have now is numbers between 0 and 9 saved in a stack. For each element on the stack add 0x30 (ascii 0) to that value and print it. The stack is conveniently contained in the call stack if you make this a recursive function.;)

When you have that mastered then you can try to create a function that will print float/doubles.

Have fun!

  #3 (permalink)  
Old May 11th, 2007, 05:00 AM
Registered User
 
Join Date: Jan 2007
Location: Glasgow, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks lewkor.

Unfortunately the projects finnished now. We went with the C-library functions option. We got great marks on the project though for anyone interested (probably no-one).

I'll definatley look into this though, while to late for the project, great to know for the rest of my life in programming

Thanks once again



Similar Threads
Thread Thread Starter Forum Replies Last Post
text vs integer paul20091968 Access VBA 2 February 13th, 2007 10:50 PM
Converting .NET 2.0 Assembly to .Net 1.x Assembly pskaushik .NET Framework 2.0 1 November 25th, 2006 01:51 PM
testing integer rjonk XSLT 2 July 27th, 2006 03:11 PM
integer overflow partaola Beginning VB 6 2 March 17th, 2004 09:01 AM
Testing for integer MattLeek Excel VBA 8 March 7th, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.