flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
JohnFound
I am not very sure how "printf" works, but I can't see how the values from variables "regEAX".... etc. are read and displayed by printf. There is no reference to these variables in the invoke clause of printf.
|
|||
![]() |
|
fasmnewbie
JohnFound wrote: I am not very sure how "printf" works, but I can't see how the values from variables "regEAX".... etc. are read and displayed by printf. There is no reference to these variables in the invoke clause of printf. Oops, my bad. Actually I used my old example. Thank you for that! here is how the macro PrintRegs looks like Code: macro PrintRegs { invoke printf, prtGP, regEAX, regEBX, regECX, regEDX invoke printf, prtID, regEDI, regESI, regEBP, regESP invoke printf, prtSG, regCS, regDS, regSS } Thank you. |
|||
![]() |
|
typedef
use ccall for printf not invoke, also for formatting try using unsigned int format specifier : %u.
enclose the dw/dd variables in square brackets when passing them to printf also. |
|||
![]() |
|
revolution
typedef wrote: use ccall for printf not invoke ... |
|||
![]() |
|
DOS386
> 1. Are the values printed were the real content of the registers
YES (but they are neither too global nor too persistent ![]() > Can't seem to find how to print the EIP Code: call @ff @@: pope eax mov dword [regEIP], eax Code: call @ff @@: pope dword [regEIP] _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
![]() |
|
Fred
I tried this, and it's pretty neat now that I got it to work. One thing though... is it possible to show reg values as floats? Changing %u to %f only prints zeroes, not really sure what's wrong, or if it's even supposed to work.
![]() |
|||
![]() |
|
Picnic
fasmnewbie wrote:
Hi, Check out these examples. http://board.flatassembler.net/topic.php?p=13916#13916 http://board.flatassembler.net/topic.php?t=10183 http://board.flatassembler.net/topic.php?p=68658#68658 (DOS) Fred wrote: is it possible to show reg values as floats? Try this way Fred, Code: proc printfloat reg locals fmt db "%.2f",0 ans dq 0.0 endl pushad lea edx, [fmt] fild dword [reg] fstp qword [ans] cinvoke printf, edx, double [ans] popad ret endp [edit]polishing code a bit[/edit] Last edited by Picnic on 04 Jul 2011, 19:11; edited 1 time in total |
|||
![]() |
|
Fred
That worked, thanks.
![]() Why the qword? Edit: I also realized that I really wanted to do something else. ![]() I have a file that I load which contains floats. For example, 0.86599994 is stored as 2C B2 5D 3Fh. How do I get these "back to floats"? Do I have to convert them or is it simpler than that? |
|||
![]() |
|
Picnic
It should be qword, printf f format requires 2 dwords.
|
|||
![]() |
|
Fred
Aha, ok.
Knowing this, I solved my problem: Code: mov eax,[hstats] movss xmm0,[eax+136] cvtss2sd xmm0,xmm0 movsd [reg],xmm0 cinvoke printf,usefloat,double [reg] Where hstats is a pointer to some file data. Probably not the best solution, but hey, it works, haha. ![]() |
|||
![]() |
|
garystampa
Hopefully they're not "random" values.
![]() |
|||
![]() |
|
typedef
...1 year later...
garystampa resurrected an old post...lol ![]() |
|||
![]() |
|
asmMe
Considering the fact that the OP only joined in March this year typedef, you may perhaps be looking at join dates and not post dates
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.