Mail Archives: cygwin/2010/03/21/10:44:22
>On 16/03/2010 17:08, Stephan Mueller wrote:
> Brandon Chase wrote:
> " DaveK wrote:
> " " Brandon, Cygwin isn't compatible with Linux at the assembler-code l=
evel,=20
> " So I cannot compile assembly language with Cygwin? Do I need a linux sh=
ell?
>=20
> No, that's not what anyone said. You can use the assembler on Cygwin to =
generate
> binaries that run on Cygwin (which is I think what you're looking for), b=
ut your
> assembly source code won't work as is -- you will need to make changes of=
the
> sort that DaveK and cgf state in the paragraphs above.
Exactly. Like so, for example:
> $ cat max.s
> .section .data
>=20
> data_items: #These are the data items
> .long 3,67,34,222,45,75,54,34,44,33,22,11,66,0
>=20
> .section .text
>=20
> .globl _main
>=20
> _main: movl $0, %edi # move 0 into the index register
> movl data_items(,%edi,4), %eax # load the first byte of data
> movl %eax, %ebx # since this is the first item, %=
eax is
> # the biggest
> start_loop: # start loop
> cmpl $0, %eax # check to see if we've hit the e=
nd
> je loop_exit
> incl %edi # load next value
> movl data_items(,%edi,4), %eax
> cmpl %ebx, %eax # compare values
> jle start_loop # jump to loop beginning if the n=
ew
> # one isn't bigger
> movl %eax, %ebx # move the value as the largest 32
>=20
> jmp start_loop # jump to loop beginning
> loop_exit:
> # %ebx is the status code for the exit system call
> # and it already has the maximum number
> # movl $1, %eax #1 is the exit() syscall
> # But we don't have linux syscalls! Instead, we do
> # a c-style call to the exit() function by pushing it
> # onto the stack!
> push %ebx
> call _exit
> # won't return.
>=20
> $ gcc max.s -o max.exe
>=20
> $ ./max.exe ; echo $?
> 222
>=20
> $
> Note use of the gcc driver to compile it, rather than invoking the assem=
bler
>and linker directly, in order to let it get all the C runtime support link=
ed
>in correctly.
>
> cheers,
> DaveK
Thanks a lot! So I need to do all c-style syscalls for Cygwin?=20
Brandon
=20=09=09=20=09=20=20=20=09=09=20=20
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/210850553/direct/01/
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -