image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old August 5th, 2004, 03:18 PM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chrislee8 is on a distinguished road
assembly gcc on Mac question.

Code:
.data                       ; section declaration - variables only

msg:
  .ascii    "Hello, world!\n\0"
  len = . - msg		    ; length of our dear string

.text                       ; section declaration - begin code

  .globl _main
_main:

# write our string to stdout

  li      r0, 4         ; syscall number (sys_write)
  li      r3, 1         ; first argument: file descriptor (stdout)
			; second argument: pointer to message to write
  lis     r4, ha16(msg); load top 16 bits of &msg
  addi    r4, r4,lo16(msg)   ; load bottom 16 bits
  li      r5, len       ; third argument: message length
  sc			; call kernel

# and exit

  li      r0, 1		; syscall number (sys_exit)
  li      r3, 1		; first argument: exit code
  sc			; call kernel
this is the assembly code, then I do this at the root prompt:
gcc helloworld.s -o helloworld, it compiles and create the helloworld, i thought the will be executable to run, so I run it, it says helloworld command not found.

so what the process of having the executable to run and display 'hello world' as my program does?

thanks
Reply With Quote
  #2  
Old August 5th, 2004, 05:02 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
could it just be that it's not in your path? Does it work if you explicitly say ./helloworld ?
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #3  
Old August 5th, 2004, 08:22 PM
Captain Code's Avatar
Moderator
 
Join Date: Aug 2001
Location: Ontario, Canada
Posts: 3,108
Thanks: 0
Thanked 1 Time in 1 Post
Captain Code will become famous soon enough
You might have to do chmod +x helloworld to make it executable, but I think gcc will do that for you.

Then you'll have to do the ./helloworld to run it.
__________________
MacBook Pro 2.16GHz Core2Duo 3GB RAM, G4 1.4GHz OSX Tiger 1.25GB RAM, Dual 2GHz G5 OSX Tiger 2GB RAM (freakin shweet)
Athlon 64 Windoze XP for school work (programming) 1GB RAM
dferns@macosx.com
Reply With Quote
  #4  
Old August 5th, 2004, 09:08 PM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chrislee8 is on a distinguished road
i found out export PATH = ${PATH}:. work for me. thanks guys
Reply With Quote
  #5  
Old August 6th, 2004, 11:11 AM
lurk's Avatar
Mitä?
 
Join Date: Mar 2002
Location: Land o' skeeterz
Posts: 2,076
Thanks: 0
Thanked 0 Times in 0 Posts
lurk is on a distinguished road
Just for reference putting . in your path like you did above is a security risk. A common account hijack is to write a program called something like "cd" which squirrels away the access privileges of someone who executes it and the does the cd. Now this is obviously only really a problem on multiuser systems but it is a good habit to get into of typing ./foo to execute foo in the current directory and not sticking . in your path.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 11:32 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.