Programming and Graphics

(Kiana) #1

16 Introduction to C++ Programming and Graphics


is explained in Section 1.7. An assembly code implementing the bubble-sort
algorithm for sorting a list of numbers or names reads:


bs proc array:DWORD,len:DWORD
mov ecx,len
mov edx,array
bs_o:
xor ebp,ebp
bs_i:
mov eax,DWORD PTR [edx+ebp*4+4]
cmp DWORD PTR [edx+ebp*4],eax
jb @F
xchg eax,DWORD PTR [edx+ebp*4]
mov DWORD PTR [edx+ebp*4+4],eax
@@:
add ebp,1
cmp ebp,ecx
jb bs_i
loop bs_o
pop ebp
retn 8
bs endp

(See: http://www.codecodex.com/wiki/index.php?title=Bubblesort)..) Try
explaining this code to a relative! The assembly language is esoteric, to say the
least, let alone notoriously difficult to debug. Today, assembly programming
is used for writing BIOS, real-time applications such as programs initializing
television sets, and device drivers.


It is much more convenient to work with high-level symbolic languages
that employ English words and standard mathematical notation. Examples are:



  • TheBasiclanguage (Beginner’s All-purpose Symbolic Instruction Code)
    developed in the mid 1960s and still surviving.

  • The fabulousFortran(FORmula TRANslator) developed in the mid
    1950s and still thriving.

  • The UCSD Pascal introduced in the early 1970s.

  • The C language developed in the mid 1970s.

  • The C++ language developed in the mid 1980s.


A plethora of other languages have been developed for general and special-
purpose applications. Because C and C++ allow the manipulation of bits,
bytes, and memory addresses, they are considered mid-level languages, half a
step above the assembler. The ranking of these computer languages in terms
of efficiency and convenience can be the subject of great debate.

Free download pdf