|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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
~~ lingon
__________________
Because your desktop should be cool! |
|
#2
|
|||
|
|||
|
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 PostNeed help? Did you try Google? Take a look over at my current work in progress http://crispycrisp.org |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
|||
|
|||
|
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 ![]() |
|
#5
|
||||
|
||||
|
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 =)
|
|
#6
|
||||
|
||||
|
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?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > FASM beginner needs help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|