Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 7th, 2007, 07:42 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
Red face FASM beginner needs help

Hi all, i just recently begann programming in fasm and want to make a simple subtraction program, but in order to print the output to the console window i need to convert it from a number to a string, and I dont know how to do that, google did'nt really help me
Heres my code so far
Code:
;bara blaj
include '%fasminc%/win32ax.inc'

.data
        value1 DW ?
        value2 DW ?
        in_handle DD ?
        out_handle DD ?
        written DD ?
        buf1 DD ?
        buf2 DD ?
        endline DB 10

.code
        start:
                invoke AllocConsole
                invoke GetStdHandle, STD_INPUT_HANDLE
                mov [in_handle], eax
                invoke GetStdHandle, STD_OUTPUT_HANDLE
                mov [out_handle], eax
                invoke WriteConsole, [out_handle], "Enter an number: ", 17, written, 0
                invoke ReadConsole, [in_handle], buf1, 4, written, NULL
                invoke WriteConsole, [out_handle], "Enter a nother number: ", 23, written, 0
                invoke ReadConsole, [in_handle], buf2, 3, written, NULL
                mov eax, [buf1]
                sub eax, [buf2]
                invoke WriteConsole, [out_handle], "The first number minus the second is: ", 38, written, 0
                invoke WriteConsole, [out_handle], eax, 10, written, 0 ;NEEDS TO BE CONVERTED FIRST!!
                invoke WriteConsole, [out_handle],endline, 1, written, 0
                invoke ReadConsole, [in_handle], buf1, 1, written, NULL
                invoke ExitProcess, 0

.end start      
The preoblem is that WriteConsole only can write strings, any help will be greatly appreciated.

~~ lingon

Reply With Quote
  #2  
Old March 8th, 2007, 06:04 AM
xnemesis64 xnemesis64 is offline
Google's No1 Supporter!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2007
Location: irc.superirc.info
Posts: 569 xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 15 h 48 m 12 sec
Reputation Power: 145
Send a message via MSN to xnemesis64 Send a message via Yahoo to xnemesis64 Send a message via Google Talk to xnemesis64 Send a message via Skype to xnemesis64
It's been a while since I've used ASM, let alone fasm. But here goes. I believe movesx is your friend. This allows you to converts a byte, word, or double word to another. And a link that should keep your more than happy for a while is fasm's official documentation, here.

Hope this helps
__________________
Did this post help? Please Click The Next To My Post
Need help? Did you try Google?
Take a look over at my current work in progress http://crispycrisp.org

Reply With Quote
  #3  
Old March 8th, 2007, 10:29 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
Thank you for answering, just one question tho, even if I can convert a byte to a word how does that help me convert the number 65 to the string '65' ?
BTW, are there other ways of writing to a console window without using the winapi?

Reply With Quote
  #4  
Old March 8th, 2007, 08:37 PM
xnemesis64 xnemesis64 is offline
Google's No1 Supporter!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2007
Location: irc.superirc.info
Posts: 569 xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 15 h 48 m 12 sec
Reputation Power: 145
Send a message via MSN to xnemesis64 Send a message via Yahoo to xnemesis64 Send a message via Google Talk to xnemesis64 Send a message via Skype to xnemesis64
I believe you can writeconsole a word. As I said it's been a while, especially with FASM. Try that suggestion, then writing the result. Get an error move to my next suggestion.

I have scoured and scoured the internet. It seems that they are happy to simply MOV from one type to another. I've seen examples that MOV eax,pMessage. pMessage being of type ptr, this type will be accepted by consolewrite. I don't think this is correct or will work, but it's what I've seen, so give it a go. Got an error? Move on

Now i'm hoping that if you are this far this one will work, as I've just been reading FASMs documentation. (And I quote) "stos places the value of AL, AX, or EAX into the destination string element." I presume consolewrite will accept this. If it's not convenient to do it when it's in one of those registers, there is another command (quote)"ins transfers a byte, word, or double word from an input port addressed by DX register to the destination string element. The destination operand should be memory addressed by DI or EDI, the source operand should be the DX register."

If none of them work, let me know. Hope this helps

Reply With Quote
  #5  
Old March 9th, 2007, 10:11 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
Wow cool answer, thank you ! I will be away over the weekend so I cant try it out right now, but as soon as i'll come back I'll let you know the resultus. Once again, thx =)

Reply With Quote
  #6  
Old March 14th, 2007, 09:49 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
I've bgun to make DOS apps (16 bits) now and i wonder if there isn't just a interrupt call that prints the number not the string to the screen, or a interrupt that converts from number to string and vice versa?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > FASM beginner needs help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway