|
From: Robert Redelmeier on 21 Apr 2008 10:25 In alt.lang.asm Frank Kotler <spamtrap(a)crayne.org> wrote in part: > I'm not familiar with Fortran. How do they do it? FORTRAN (FORmula TRANslation) is the oldest wide-spread HLL, dating from 1957. It is still used for scientific coding. >From an ASM PoV, FORTRAN is call-by-address (not the `c` call by value), usually callee pop if the stack is used at all (many of the early machines did not have hardware stack instructions. > Unless I'm mistaken, changing ".model flat stdcall" to ".model flat C" > would automatically adjust your code... with certain assemblers... It could if the calls are implemented via a macro like `invoke`. If the reg/stack load is done manually, then the assembler is going to have to guess or fiddle with code more than many people around here would find acceptable. -- Robert
From: James Van Buskirk on 21 Apr 2008 13:46 "Frank Kotler" <spamtrap(a)crayne.org> wrote in message news:OyVOj.3194$y63.2632(a)trndny02... > Yeah... it's different in Windows. A "hello world in a window" is as > complicated as the X version, or worse. Something simpler will suffice. I > can't find a Windows example that's "right" - "push -11" is *not* right, > we're supposed to push -11 and call GetStandardHandle and use the return > from *that* as a handle. This worked anyway, in win98, IIRC. It'll do... > push dword 0 ; ??? unicode flag??? > push dword num_chars ; return value > push dword MSGLEN > push dword msg > push dword -11 ; can this be right??? > call WriteFile As you pointed out above, this isn't right. A 64-bit Windows example in GAS: C:\gfortran\test\gas>type hello.s ...text _main: sub $40, %rsp movl $-11, %ecx # STD_OUTPUT_HANDLE call _GetStdHandle movq %rax, %rcx # hFile leaq lpBuffer(%rip), %rdx # lpBuffer movl nNumberOfBytesToWrite(%rip), %r8d # nNumberOfBytesToWrite leaq lpNumberOfBytesWritten(%rip), %r9 # lpNumberOfBytesWritten andq $0, 32(%rsp) # lpOverlapped call _WriteFile xorl %ecx, %ecx call _ExitProcess add $40, %rsp # Should never be reached ret ...data lpBuffer: .ascii "Hello, world." .byte 13, 10 nNumberOfBytesToWrite: .long . - lpBuffer ...align 4 lpNumberOfBytesWritten: .long 0 C:\gfortran\test\gas>as hello.s -ohello.o C:\gfortran\test\gas>ld hello.o -ohello.exe -lkernel32 -luser32 C:\gfortran\test\gas>hello Hello, world. Examples may be found on the GoAsm web pages: http://www.jorgon.freeserve.co.uk/GoasmFrame.htm Jeremy Gordon has 32-bit and 64-bit Windows examples in the appendices, both console and Windows programs. For documentation on the Win32 API functions, it's hard to beat msdn. I think your example won't work well because you are not sending a handle given you by Windows for the file handle. -- write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, & 6.0134700243160014d-154/),(/'x'/)); end
From: Josef Moellers on 22 Apr 2008 03:44 Robert Redelmeier wrote: > In alt.lang.asm Frank Kotler <spamtrap(a)crayne.org> wrote in part: >> I'm not familiar with Fortran. How do they do it? > > FORTRAN (FORmula TRANslation) is the oldest wide-spread HLL, > dating from 1957. It is still used for scientific coding. > >>From an ASM PoV, FORTRAN is call-by-address (not the `c` call > by value) AFAIR you could manage to "change the value of 5"(*) on some early compilers by calling a function which modifies one of its arguments, with the constant as an argument ;-) (*) A question from the "Hacker Test". No, I never did that, but I did program while intoxicated ;-) -- These are my personal views and not those of Fujitsu Siemens Computers! Josef M�llers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize (T. Pratchett) Company Details: http://www.fujitsu-siemens.com/imprint.html
From: Josef Moellers on 22 Apr 2008 03:42 Frank Kotler wrote: > Terence wrote: >> A misunderstanding Frank! >> I know the posting is about the use of Linux. >> And an ASM program written as a main can call named sub-programs, >> whether service or otherwise. >> >> But this same main program can be used with Windows as long as what >> its calls are valid for a Windows environment. >> >> And here is the point. >> When you write a 32-bit algorithm in ASM for an Intel chip, the main >> code is valid whether for Windows or Linux, EXCEPT the calls to >> services. >> >> And I write for DOS and Windoss and change the subprogram library I >> link with to match. >> But I have also to match the calling convention or use a common one. >> And FOrytran and C, as example, use different stack conventions. > > I'm not familiar with Fortran. How do they do it? Neither am I. But I recall that for one, Fortran doesn't support recursion, and, as Robert pointed out, not all early machines had a proper stack, parameters might be passed in a fixed location. The best thing to do would be to compile a Fortran program and look at the object code. -- These are my personal views and not those of Fujitsu Siemens Computers! Josef M�llers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize (T. Pratchett) Company Details: http://www.fujitsu-siemens.com/imprint.html
From: Terence on 22 Apr 2008 18:18 On Apr 22, 5:42�pm, Josef Moellers <spamt...(a)crayne.org> wrote: >.... But I recall that for one, Fortran doesn't support > recursion, and, as Robert pointed out, not all early machines had a > proper stack, parameters might be passed in a fixed location. > > The best thing to do would be to compile a Fortran program and look at > the object code. > Oh NO!, Fortran DOES support recursion!
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Linking TASM objs with current C++ stuff and linkers Next: Port binding under linux in ASM |