Link to home
Create AccountLog in
Avatar of william007
william007

asked on

Assembly language vs C programming

I am researching a small operating system, visopsys on how it works,
the source code can be downloaded here:
http://visopsys.org/files/visopsys/visopsys-0.63-src.zip

There are some file(with .s extension) in writtern in assembly language in the folder
visopsys-0.62-src/src/osloader
May I know
(i) What are the main functions of the software in this directory?
(ii) Why can the code not be written in C?

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of william007
william007

ASKER

Thanks, but what are the mechanism that make all the .s file to run?
Assembly is nothing but mnemonics for machine instructions ... An assembler would easily convert it to machine code.
a)If I am in Fedora, am I right that there is a build in assembler(Nasm or something else), and I just need to type
./myAssembly.s
and it can be run directly even do not need to compile it?
b)Is there a command in C that allows us to run an assembly file?
(I am very new to assembly, please bear with my ignorance)
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thanks...you have given my a clearer picture...
Following is the snippet of make file
//**********start snippet*********
AS            = nasm
CC            = gcc355
WARNOPTS      = -w+orphan-labels
SECTOPTS      = -f bin ${WARNOPTS}
LDROPTS            = -f aout ${WARNOPTS}
LINKOPTS      = -mcpu=pentium -Wl,-warn-common,-X,--oformat,binary,-e,loaderMain,-Ttext,0x00000000
STDDEPEND      = loader.h Makefile
OBJS            = obj/loaderMain.o \
            obj/loaderVideo.o \
            obj/loaderDetectHardware.o \
            obj/loaderLoadFile.o \
            obj/loaderLoadKernel.o \
            obj/loaderDiskError.o \
            obj/loaderPrintRoutines.o

all: target-dirs bootsectors ${LOADERBUILDDIR}/vloader

target-dirs:
      mkdir -p obj ${BOOTBUILDDIR} ${LOADERBUILDDIR}

bootsectors: ${BOOTBUILDDIR}/mbr.simple ${BOOTBUILDDIR}/mbr.bootmenu ${BOOTBUILDDIR}/bootmenu ${BOOTBUILDDIR}/bootsect.fat ${BOOTBUILDDIR}/bootsect.fat32 ${BOOTBUILDDIR}/bootsect.fatnoboot ${BOOTBUILDDIR}/bootsect.fatnoboot32

#
# MBRs and Boot sectors
#

${BOOTBUILDDIR}/mbr.simple: mbr-simple.s ${STDDEPEND}
      ${AS} ${SECTOPTS} $< -o $@
//**********end snippet*********

Seems like it is using nasm <something> to compile the assembly...
Am I run that after compiling we can run it like any other executable on command line
./executable
?
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thanks=)