flat assembler
Message board for the users of flat assembler.
Index
> DOS > Print ing a number Goto page 1, 2 Next |
Author |
|
baldr 09 Aug 2012, 03:10
davetheant,
There are many ways, you may import printf() from MSVCRT.DLL if you're Windows-fancy, or use various itoa() equivalents that are plenty here. |
|||
09 Aug 2012, 03:10 |
|
mindcooler 09 Aug 2012, 04:30
Do you want to do it in "fasm", or do you mean (fasm) assembly?
This macro displays a four-digit number in fasm. It can be used as pseudocode if you want to write a converter in assembly. Code: macro print description,number { display description value=number pos=1000 repeat 4 digit=value/pos value=value-(digit*pos) pos=pos/10 display ('0'+digit) end repeat display $d,$a } _________________ This is a block of text that can be added to posts you make. |
|||
09 Aug 2012, 04:30 |
|
baldr 10 Aug 2012, 08:11
mindcooler,
The key phrase was "a number in EAX". |
|||
10 Aug 2012, 08:11 |
|
mindcooler 10 Aug 2012, 10:55
Is that some internal fasm variable?
|
|||
10 Aug 2012, 10:55 |
|
AsmGuru62 10 Aug 2012, 12:17
I found some old DOS code -- maybe it will help.
It prints AX however, not EAX. And it does not consider negative numbers - all unsigned. Code: PrintAX: ; ; Assumption: all segments are set to the same value (COM program) ; pusha sub sp, 16 ; Reserve 16 character buffer on stack lea di, [sp + 15] ; DI = address of a last character mov byte [di], '$' ; This is for AH=9 INT 21H mov cx, 10 ; Will be dividing DX:AX by this @@: xor dx, dx div cx ; Divide DX:AX by 10 dec di ; Avoiding AGI add dl, '0' ; Convert to a digit mov [di], dl ; And store it into buffer test ax, ax ; Check if there is more to divide? jnz @r ; Yes. Divide again. mov dx, di ; Dump string to console mov ah, 9 int 21h add sp, 16 ; Restore stack and return popa ret |
|||
10 Aug 2012, 12:17 |
|
freecrac 18 Aug 2012, 08:46
I made some little dos applicaton for to converting 32 bit values.
Dez2bit Dez2hex Hex2bit Hex2dez (including routine for printing decimal values of eax) www.alice-dsl.net/freecracmaps/Tool/Zahlswap.zip Dirk |
|||
18 Aug 2012, 08:46 |
|
bitshifter 02 Nov 2012, 09:59
maybe this work for you? (i didnt test it...)
Code: ;assumes ds=es itoa: ;in: ax = value ; bx = base ; di -> buffer cmp bx,10 jne utoa test ax,ax jns utoa neg ax mov byte[ds:di],'-' inc di ;jmp utoa utoa: ;in: ax = value ; bx = base ; di -> buffer xor dx,dx div bx push dx test ax,ax jz .purge call utoa .purge: pop ax and al,0x0F cmp al,0x0A sbb al,0x69 das stosw dec di ret |
|||
02 Nov 2012, 09:59 |
|
DOS386 04 Nov 2012, 13:33
davetheant wrote: Hello everyone Welcome to FASM (oops, 3 moths later) Quote: tried searching for the answer to this in the forums but I couldn't seem to find anything.. I have a number in EAX that I'd like to print This had been discussed already 1'000'000'000'000 times. Quote: things in other forums about repeatedly dividing by 10 and printing digit by digit, but I was unsure if this is the way to do it in FASM Definitely YES : see Main FAQ Group "E. MATH" http://board.flatassembler.net/topic.php?t=2530 > There are many ways, you may import printf() > from MSVCRT.DLL if you're Windows-fancy This is an inferior way to to on Windows and a NO-GO in DOS EDIT : moved part of post content into the FAQ _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug Last edited by DOS386 on 29 Apr 2013, 07:38; edited 3 times in total |
|||
04 Nov 2012, 13:33 |
|
lamer 24 Apr 2013, 12:28
lol, just registered to ask same question... im reading tajga fasm tutorial started to make my own simple apps to practice and realized theres noway to print numbers... i can print string but cant numbers?! why theres no 'print number' interupt? Thats weird...
|
|||
24 Apr 2013, 12:28 |
|
AsmGuru62 24 Apr 2013, 13:31
There should be a lot of code posted here over time for that purpose.
Did you view the links posted in previous post? |
|||
24 Apr 2013, 13:31 |
|
revolution 24 Apr 2013, 14:56
lamer wrote: why theres no 'print number' interupt? It is usually easier just to program what you need for the job at hand, rather than have the OS/BOIS provide some sort of uber-mega-ultra-bloated-number-to-text conversion routine. |
|||
24 Apr 2013, 14:56 |
|
lamer 25 Apr 2013, 00:58
revolution wrote:
not so many. you just make it sound bad but you actually wrote all the cases of a basic number printing interupt. no need to go crazy about it making it phinary and whatevernary. if you point it that way theres no need for a string printing interupt because everything can be coded from scratch 'easier' |
|||
25 Apr 2013, 00:58 |
|
revolution 25 Apr 2013, 02:21
lamer wrote: not so many. you just make it sound bad but you actually wrote all the cases of a basic number printing interupt. no need to go crazy about it making it phinary and whatevernary. if you point it that way theres no need for a string printing interupt because everything can be coded from scratch 'easier' Besides I didn't mention all cases above. There are plenty more, including, but not limited to, character set selection, internationalisation for digit grouping, negative representation (accounting requirements), leading/trailing zeros, left/right justification, out of scope numbers (infinity, NaNs, etc.), etc. etc. etc. |
|||
25 Apr 2013, 02:21 |
|
lamer 25 Apr 2013, 11:27
revolution wrote:
I dont know what internationalisation you talk about DOS only cares about USA. Anyway, there's printf function in C lib, same interupt could be made. And that could be a basic number printing interupt. And when you talk about accounting and stuff that goes beyond basic so it should be coded from scratch. Everything can be made complicated, i cant print cyrillic letters with DOS interupt for example according to you logic string printing interupt is useless because of that and should not be made. |
|||
25 Apr 2013, 11:27 |
|
revolution 25 Apr 2013, 12:47
lamer wrote: ... according to you logic string printing interupt is useless because of that and should not be made. |
|||
25 Apr 2013, 12:47 |
|
DOS386 28 Apr 2013, 14:32
> internationalisation for digit grouping
That's what the world really badly needs ... a crucial feature that distinguishes professional operating systems from toys > DOS has long since stopped being developed by MS True but irrelevant ... get FreeDOS (but you still will have to divide by 10 yourself ...) PS: You'll get 18'446'744'073'709'551'615 Byte's of bloat if you add everything into your OS > lol, just registered to ask same question... Look at the FAQ at forum top before asking (doesn't cost registration) http://board.flatassembler.net/topic.php?t=2530 |
|||
28 Apr 2013, 14:32 |
|
Just4fasm 29 Apr 2013, 15:29
A person asked a question then you apesh people are often giving a lame moronic replies!!!.
What is wrong with this person's question???!!! Quote: Hello everyone. I tried searching for the answer to this in the forums but I couldn't seem to find anything.. I have a number in EAX that I'd like to print out. I've seen things in other forums about repeatedly dividing by 10 and printing digit by digit, but I was unsure if this is the way to do it in FASM. Thanks! If you are were normal people with a real basic knowledge of asm and pc! then you are can give this proper answer to him! davetheant, you skipped what you looking for or you confused because of less knowledge! Yes you can! dividing by 10 and printing digit by digit, this is the way to do it in ANY ASM!!!. I pity you assemblers, moderators! You are look like some kind of poorly programmed bot!. I know, you are a real humans! but you are natively have logic stupidity and lack of knowledge of real things!. Obviously, you are Black Homosapein Orangutang's supporters!. Black Orangutang can easily trick you and you are very close minded apes next to him!. Black Orangutang is half human and half animal! You know he is resident evil internationally United States of Apes!!!. baldr!!! NO C!!! Because it is all about ASM!!!!!!!. Lamer! there's no need 'print number' interrupt! if you point it a string printing because everything can be coded very easily!. And you can print cyrillic letters in DOS!. DOS is DOS! DOS doesn't cares about USA or International!!!. freecrac! Only you have a human brain but sadly only 60%!!! rest of 40% ape!!!. DON'T SUPPORT microsoft!!! cos you often using crap MS-DOS 21h interrupts on very unusual things!!!. revolution!!! MS-DOS stands for Money Swindle from Disk Operating System! Microsoft is stole moneys from DOS! that's why they stopped long time ago! since they can't steal anymore!. You merely knows about the MIGHTY DOS!!!. And you have lack of human brain!!! Your ape brain level is higher than your human brain level. DOS is powerful than shit thief microsoft OSes!!!. Anything is possible on DOS!. Windows OS will be die! DOS is never ever dies!!!. DOS is the champion of the speed!. _________________ Assembly language is machine instruction so don't make fake assembly languages other than actual CPU instruction code!. Fuck stupid Microsoft! for faking instruction codes!!!. |
|||
29 Apr 2013, 15:29 |
|
revolution 29 Apr 2013, 15:39
Just4fasm wrote: revolution!!! MS-DOS stands for Money Swindle from Disk Operating System! Microsoft is stole moneys from DOS! that's why they stopped long time ago! since they can't steal anymore!. You merely knows about the MIGHTY DOS!!!. And you have lack of human brain!!! Your ape brain level is higher than your human brain level. |
|||
29 Apr 2013, 15:39 |
|
AsmGuru62 29 Apr 2013, 16:29
When this thread started -- I politely asked if the thread starter looked at any of posted links.
Still waiting for results. Because I can write a small function for DOS, which will print the 16-bit integer. |
|||
29 Apr 2013, 16:29 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.