CMPC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Assembly code

4 posters

Go down

Assembly code Empty Assembly code

Post by Corey Mon Jan 25, 2010 2:30 am

If you're thinking about using assembly to write programs, don't. If you don't believe me, here's a "Hello World" program.
Code:

.intel_syntax noprefix
#obscured
.section .text
.balign 16
_fb_ctor__hi:
.Lt_0001:
push 1
push 12
push offset _Lt_0003
call _fb_StrAllocTempDescZEx@8
push eax
push 0
call _fb_PrintString@12
push -1
call _fb_Sleep@4
.Lt_0002:
ret
#obscured
.section .data
.balign 4
_Lt_0003:   .ascii   "hello world!\0"
.section .ctors
.int _fb_ctor__hi
.section .fbctinf
.byte 16
.byte 1
.byte 6
.ascii "user32\0"
.byte 0
.byte 0


And a slightly nicer-looking one:
Code:
   
.intel_syntax noprefix
#obscured
.section .text
.balign 16
_fb_ctor__hi:
.Lt_0001:
push 0
push 0
push 0
push 8
push 18
call _fb_GfxScreen@20
push 1
push 12
push offset _Lt_0003
call _fb_StrAllocTempDescZEx@8
push eax
push 0
call _fb_PrintString@12
push -1
call _fb_Sleep@4
.Lt_0002:
ret
#obscured
.section .data
.balign 4
_Lt_0003:   .ascii   "hello world!\0"
.section .ctors
.int _fb_ctor__hi
.section .fbctinf
.byte 16
.byte 1
.byte 5
.ascii "fbgfx\0"
.byte 6
.ascii "user32\0"
.byte 5
.ascii "gdi32\0"
.byte 5
.ascii "winmm\0"
.byte 0
.byte 0

See what I mean?
Corey
Corey
Mod

Posts : 462

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Admin Mon Jan 25, 2010 3:45 am

lol i used assembly code to run my small personal robot (i built it over the summer). I used BASIC to program the basic stamp 2. it was fun but even though my code was good, my robot sucked because i lacked metal/building parts / good wheels / sensors / etc etc... LONG LIST.

I'm gonna try and do it again soon. Possibly for a senior project? Idk anything nice would do for the senior project.
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Unchained Mon Jan 25, 2010 6:10 am

Actually according to Angie, while assemble sucks it teaches you a bunch about programming, especially for embedded systems.
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Corey Mon Jan 25, 2010 6:14 am

Ok, ok. I meant for the beginners...
Corey
Corey
Mod

Posts : 462

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Unchained Mon Jan 25, 2010 6:15 am

Oh yea, totally not a first language by any stretch.
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Paul Tue Jan 26, 2010 1:08 am

I almost prefer Perl to Assembly Wink
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

Assembly code Empty Re: Assembly code

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum