Tech Support > Computers & Technology > Programming > assembly code
assembly code
Posted by Bill Cunningham on June 2nd, 2004


I have the following assembly code. I want the program to count from 0
to 10 and then print 10 and stop. I think I've set up the data labels and
such correctly but I need to know how to use the registers. I think I'm also
using C overhead with the main object being a function. This code is for GAS
and I want to use system calls as function to print. Like write() kernel
call to print 10. Does this look so far anything remotely like assembly I
want?
;;code

..data
.type hi@object
.size hi,1
hi:
.byte 0x10
.type lo@object
.size lo,1
lo:
.byte 0
.type avg@object
.size avg,1
avg:
.byte 0
..text
.align 2
..globl main
.type main@function

main:
;okay now what?






Posted by T.M. Sommers on June 3rd, 2004


Bill Cunningham wrote:
This should be, I think,
.type hi, @object

The .size directive is usually only used for functions. The size
of an object should be implicit.

You might as well make this (and the others) an int; you do not
really save anything by making it a byte.

..align 4 would be better, assuming you are on an x86 system.

You do not say what system you are on, so it is hard to say what
goes next. Take a look at http://linuxassembly.org. The FreeBSD
Deveopers' Handbook also has a chapter on assembly programming.

--
Thomas M. Sommers -- tms@nj.net -- AB2SB


Posted by Bill Cunningham on June 3rd, 2004



"T.M. Sommers" <tms@nj.net> wrote in message
news:yKGcnX4FMvzoDiPdUSdV9g@telcove.net...

Bill





Similar Posts