Download Hello World in Assembly

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Santos, Paul Nicholas
9/14/15
Proglan
Assignment # 2
1. Research on "Hello World" in programming. Why is it so famous?
According to Cunningham & Cunningham, Inc. (Hello World, 2014), the hello world
program wants to teach the user how to configure their environment. If the environment is able
to run the hello world program, then it is configured and ready to be used by the user.
Another reason, based on the website, why hello world is famous is because it is a way
of comparing the size of executable each language generates and how much supporting
infrastructure each language needs in order to execute.
Source: http://c2.com/cgi/wiki?HelloWorld
2. Research and compare how "Hello World" is implemented in C, Assembly, Cobol, Visual Basic
and Python.
Hello world in C:
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello World");
}
Source:
http://groups.engin.umd.umich.edu/CIS/course.des/cis400/c/hworld.html
The
based on c,
the line of
or not. The
hello world in C looks similar to the one in java, since java is
but it a little bit more simplified. The code doesn’t state if
code is private or public, static or dynamic, and if it is void
printing also doesn’t need the System.out before the printf.
The other thing that is new from the code that I haven’t seen before
would be the #include<stdio.h>;however, it kind of looks like the include
statement in java, which is connected to the main string.
Hello World in Assembly:
; hello-DOS.asm - single-segment, 16-bit "hello world" program
;
; assemble with "nasm -f bin -o hi.com hello-DOS.asm"
org 0x100
; .com files always start 256 bytes into the segment
; int 21h is going to want...
mov dx, msg
; the address of or message in dx
mov ah, 9
; ah=9 - "print string" sub-function
int 0x21
; call dos services
mov ah, 0x4c ; "terminate program" sub-function
int 0x21
; call dos services
msg db 'Hello, World!', 0x0d, 0x0a, '$' ; $-terminated message
Source: https://montcs.bloomu.edu/Information/LowLevel/Assembly/hello-asm.html
The hello world statement in assembly looks completely different from
the typical or normal programming code that I have seen before. To be honest,
I don’t understand this code.
Based on the comments that are written on the right side of the code,
I can infer that this programming language is an old one. Comparing it to
other programming languages, it is unique in itself.
Hello World in COBOL:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID.
HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
001100 FILE SECTION.
001200
100000 PROCEDURE DIVISION.
100100
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400
DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500
DISPLAY "Hello world!" LINE 15 POSITION 10.
100600
STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800
EXIT.
Source: http://groups.engin.umd.umich.edu/CIS/course.des/cis400/cobol/hworld.html
Looking at the code seen from above, we can see that this programming language is cut into
divisions and under each division there are sections within it.
Looking at the code within it, the string statement is also written within double quotations. The
line numbering is totally different from other programming languages. Each line in the program ends
with a period. Finally, the lines of code in the program are in uppercase letters.
Hello World in Visual Basic:
Private Sub Command1_Click()
MsgBox "Hello, World!"
End Sub
Source: http://www.vb6.us/tutorials/hello-world
Visual Basic is more on interaction with other users by using buttons as a way of interacting with
the user instead of doing it step-by-step from top to bottom. It has a new and unique way of naming
objects, like the message box for hello world.
Other different stuff seen in visual basic would be the message in the message box is not placed
inside the parenthesis. The programming code doesn’t end with a semicolon as well. Finally, the multiline code under the click command is not inside the curly braces.
Hello World in Python:
Type the following text into a single file named ex1.py. Python works best with
files ending in .py.
print "Hello World!"
In Terminal run the file by typing:
python ex1.py
Source: http://learnpythonthehardway.org/book/ex1.html
The python programming language is the simplest among the rest of the
programming languages seen in the list. This programming language simply
contains the commands that the environment needs to execute.
As for the way the code is written, the statement is not under parenthesis. The
program doesn’t end with a period or a semicolon. The name of the whole class is
written as the name of the notepad. Finally, the name of the file or the file type is
under .py.