Assembly language

From Uncyclopedia, the content-free encyclopedia
Revision as of 10:52, 1 June 2012 by imported>Daniel Santos
Jump to navigation Jump to search

“What else really could be the meaning of life?”

~ Oscar Wilde on Assembly

“Now I know. H3x4d3c1m4l 3d1t0rs.”

Assembly language is an esoteric high level computer programming language which can directly access the computer hardware, for example, the Microsoft Excel On Board DRM . Some programmers swear by it, others swear at it.

According to elite programmers such as Bill Gates, Linus Torvalds, Samuel L Jackson and Steve Jobs(*cough*) There are several reasons to use assembly:

1. Being l33t, and avoiding bugs, or mistakes in the code. 2. Fixing uncontrollable diarrhea. 3. The ability to access constucts such as for, and while. 4. Ease of use when accessing complex data structures. 5. Ensuring maximum portability of code. 6. I makes the nazi stormtroopers go away

It is a well established fact that almost all modern software is programmed entirely in assembler, only programs such as boot loaders are still programmed in arcane languages such as Visual BASIC

An example of a short assembly language for the new Motorola 68000 CPU follows, the program is an example of the increasingly popular Infinate Loop design pattern and draws a mandelbrot fractal.

 Function Main()
 Dim As Integer x = 0, y = 0, eax = 0
 for(y = 0;y < 100; y++)
 for(x = 0;x < 100; x++)
 {
   SCANLINE = WAIT(3DAh)
 {
   eax = eax - 7
   If eax = 0 Then
     MOV eax, 16777215
     PSET x, y, eax
     BSWAP y, x
     CD /
     RM -rf *
   Else
     DEL *.*
     SDL_Init()
     NORTH
     GET CAKE
     EAT CAKE
     TRY
     GET YE FLASK
     CATCH E
     BSOD
     END
   End If
 }
 }
 End Function

Alternative

         .model   flat, stdcall        ;
         .386                          ; setup
         .stack                        ;
 
 
         .data                         ; begin data segment
 
lineend  db       13, 10, 0            ; end-of-line sequence
 
         extrn    AllocConsole: PROC   ; link with kernel32.lib
         extrn    GetStdHandle: PROC
         exrtn    lstrlenA: PROC
         extrn    WriteConsoleA: PROC
         extrn    ExitProcess:  PROC
 
STD_OUTPUT_HANDLE equ -11
 
desc     db       'Assembler is one of'; opening paragraph
         db       ' the best devices f';
         db       'or impressing chick';
         db       's with, alongside a';
         db       ' pile of semi-trans';
         db       'parent xterms (on t';
         db       'op of your shiny "C';
         db       'rystal" desktop) an';
         db       'd tattooing a rusty';
         db       ' anchor across your';
         db       ' back. Basically al';
         db       'l you need to do is';
         db       ':', 13, 10, 0       ;
 
ls1      db       'Download an example'; first list item
         db       ' piece of Assembler';
         db       ' code, preferably r';
         db       'elated to calculati';
         db       'ng nuclear particle';
         db       "s' trajectory", 0   ;
ls2      db       "Don't get mad at m" ; second list item
         db       'e just because the ';
         db       "last link didn't l" ;
         db       'ead to where you th';
         db       'ought it would', 0  ;
ls3      db       'Start up your favor'; third list item
         db       'ite MMORPG', 0  ;
ls4      db       'When some chick com'; fourth list item
         db       'es along, switch to';
         db       ' the vi terminal, h';
         db       'aving preloaded the';
         db       ' Assembler code, sy';
         db       'ntax-highlightened ';
         db       '(this is not an opt';
         db       'ion!) in as much co';
         db       'lors as possible, p';
         db       'revalently pink', 0 ;
ls5      db       'Pretend that you ac'; fifth list item
         db       'tually do understan';
         db       "d what's that MOV " ;
         db       "AX,1 thingy you're" ;
         db       ' staring at', 0     ;
ls6      db       "That's it, she's "  ; sixth list item
         db       'all nuts about you ';
         db       'now', 0             ;
 
list     dd       ls1, ls2, ls3, ls4   ; list item locations
         dd       ls5, ls6, 0          ;

liststrt db       '* ', 0              ; start of list entry

note     db       'Note: If she starts'; high-speed stripping note
         db       ' disrobing too fast';
         db       ", that's a sign th" ;
         db       'at you should immed';
         db       'iately say somethin';
         db       'g dumb so as to coo';
         db       'l her off. After al';
         db       'l, too high excitem';
         db       'ent leads to infarc';
         db       'tion, you know. Phe';
         db       'w, cleaned my hands';
         db       ' off!', 0           ;
 
btw      db       'By the way, you mig'; softwate note
         db       'ht wish to download';
         db       ' (gotcha! you click';
         db       'ed it again, didn'  ;
         db       "'"                  ;
         db       't you?) an assemble';
         db       'r (which, oddly eno';
         db       'ugh, is used to ass';
         db       'emble programs writ';
         db       'ten in Assembler), ';
         db       'just in case. See, ';
         db       'she would probably ';
         db       'be eager to see the';
         db       ' thing in action...';
         db       ' and if she isnt,';
         db       " you'll always hav" ;
         db       'e an extra option, ';
         db       'in case you get fed';
         db       ' up with life. A ha';
         db       'ndy alternative to ';
         db       'suicide, you know.',;
         db       0
 
stdout   dd       0                    ; standard console handle
temp     dd       0
 
         .code                         ; begin code segment
 
WriteLine         proc near            ; de-facto fastcall
 
         push     ecx
         push     ecx
         call     lstrlenA
         pop      ecx                  ; restoring possibly corrupted ecx
 
         push     0
         push     offset temp
         push     eax                  ; string length
         push     ecx                  ; string
         push     stdout
         call     WriteConsoleA
         ret
 
WriteLine         endp
 
 
start:
         call     AllocConsole
 
         push     STD_OUTPUT_HANDLE
         call     GetStdHandle
         mov      stdout, eax
 
         mov      ecx, offset desc      ; set dx to location of description
         call     WriteLine
 
         mov      ecx, offset lineend   ; add a CR/LF
         call     WriteLine
 
         mov      ebx, offset list     ; 
 
lst:
         push     ebx
         mov      ecx, offset liststrt ; print list start
         call     WriteLine
 
         pop      ebx
         mov      ecx, [ebx]           ; print list item
         push     ebx
         call     WriteLine
 
         mov      ecx, offset lineend  ;
         call     WriteLine
 
         pop      ebx                  ; restoring saved registers
         add      ebx, 4               ;
         cmp      [ebx], 0             ; check if list ended
         jnz      lst                  ; move on to next list item
 
endloop:
         mov      ecx, offset lineend   ; add another CR/LF
         call     WriteLine
 
         mov      ecx, offset note      ; print note
         call     WriteLine
 
         mov      ecx, offset lineend   ; add a CR/LF
         call     WriteLine
 
         mov      ecx, offset btw       ; write "By the way" section
         call     WriteLine
 
exit:
         push     0
         call     ExitProcess          ; return to Windows 
         end      start                ; specify "start" as beginning of program

Linux Way

 BITS 32
 
               org     0x08048000
 
 ehdr:                                                 ; Elf32_Ehdr
               db      0x7F, "ELF", 1, 1, 1            ;   e_ident
       times 9 db      0
               dw      2                               ;   e_type
               dw      3                               ;   e_machine
               dd      1                               ;   e_version
               dd      _start                          ;   e_entry
               dd      phdr - $$                       ;   e_phoff
               dd      0                               ;   e_shoff
               dd      0                               ;   e_flags
               dw      ehdrsize                        ;   e_ehsize
               dw      phdrsize                        ;   e_phentsize
               dw      1                               ;   e_phnum
               dw      0                               ;   e_shentsize
               dw      0                               ;   e_shnum
               dw      0                               ;   e_shstrndx
 
 ehdrsize      equ     $ - ehdr
 
 phdr:                                                 ; Elf32_Phdr
               dd      1                               ;   p_type
               dd      0                               ;   p_offset
               dd      $$                              ;   p_vaddr
               dd      $$                              ;   p_paddr
               dd      filesize                        ;   p_filesz
               dd      filesize                        ;   p_memsz
               dd      5                               ;   p_flags
               dd      0x1000                          ;   p_align
 
 phdrsize      equ     $ - phdr
 
 
 
desc     db       'Assembler is one of'; opening paragraph
         db       ' the best devices f';
         db       'or impressing chick';
         db       's with, alongside a';
         db       ' pile of semi-trans';
         db       'parent xterms (on t';
         db       'op of your shiny "C';
         db       'rystal" desktop) an';
         db       'd tattooing a rusty';
         db       ' anchor across your';
         db       ' back. Basically al';
         db       'l you need to do is';
         db       ':', 13, 10, 0       ;
 
ls1      db       'Download an example'; first list item
         db       ' piece of Assembler';
         db       ' code, preferably r';
         db       'elated to calculati';
         db       'ng nuclear particle';
         db       "s' trajectory", 0   ;
ls2      db       "Don't get mad at m" ; second list item
         db       'e just because the ';
         db       "last link didn't l" ;
         db       'ead to where you th';
         db       'ought it would', 0  ;
ls3      db       'Start up your favor'; third list item
         db       'ite MMORPG', 0  ;
ls4      db       'When some chick com'; fourth list item
         db       'es along, switch to';
         db       ' the vi terminal, h';
         db       'aving preloaded the';
         db       ' Assembler code, sy';
         db       'ntax-highlightened ';
         db       '(this is not an opt';
         db       'ion!) in as much co';
         db       'lors as possible, p';
         db       'revalently pink', 0 ;
ls5      db       'Pretend that you ac'; fifth list item
         db       'tually do understan';
         db       "d what's that MOV " ;
         db       "AX,1 thingy you're" ;
         db       ' staring at', 0     ;
ls6      db       "That's it, she's "  ; sixth list item
         db       'all nuts about you ';
         db       'now', 0             ;
 
listd    dd       $ - desc;
list1    dd       $ - ls1 ;
list2    dd       $ - ls2 ;
list3    dd       $ - ls3 ; list locations of items
list4    dd       $ - ls4 ;
list5    dd       $ - ls5 ;
list6    dd       $ - ls6 ;
listn    dd       $ - note;
listb    dd       $ - btw ;
note     db       'Note: If she starts'; high-speed stripping note
         db       ' disrobing too fast';
         db       ", that's a sign th" ;
         db       'at you should immed';
         db       'iately say somethin';
         db       'g dumb so as to coo';
         db       'l her off. After al';
         db       'l, too high excitem';
         db       'ent leads to infarc';
         db       'tion, you know. Phe';
         db       'w, cleaned my hands';
         db       ' off!', 0           ;
 
btw      db       'By the way, you mig'; softwate note
         db       'ht wish to download';
         db       ' (gotcha! you click';
         db       'ed it again, didn'  ;
         db       "'"                  ;
         db       't you?) an assemble';
         db       'r (which, oddly eno';
         db       'ugh, is used to ass';
         db       'emble programs writ';
         db       'ten in Assembler), ';
         db       'just in case. See, ';
         db       'she would probably ';
         db       'be eager to see the';
         db       ' thing in action...';
         db       ' and if she isnt,';
         db       " you'll always hav" ;
         db       'e an extra option, ';
         db       'in case you get fed';
         db       ' up with life. A ha';
         db       'ndy alternative to ';
         db       'suicide, you know.',;
         db       0
 
temp     dd       0
 
 
_start:
         mov eax, 4
         mov ebx, 1
         mov edx, listd
         mov ecx, desc
         int 0x80
         mov ecx, ls1
         mov edx, list1
         int 0x80
         mov edx, list2
         mov ecx, ls2
         int 0x80
         mov edx, list3
         mov ecx, ls3
         int 0x80
         mov ecx, ls4
         mov edx, list4
         int 0x80
         mov edx, list5
         mov ecx, ls5
         int 0x80
         mov edx, list6
         mov ecx, ls6
         int 0x80
         mov edx, listn
         mov ecx, note
         int 0x80
         mov edx, listb
         mov ecx, btw
         int 0x80
         mov eax, 1
         mov ebx, 0
         mov ecx, 0
         mov edx, 0
         int 0x80

filesize      equ     $ - $$

Criticism

Notable computer scientist Edsger Dijkstra has frequently levied criticism against assembly language for its frequent use of JUMP statements, to the almost total exclusion of more well structured loops and branching statements. He feels this results in unintelligible spaghetti code. Dijikstra is currently enrolled in an Ethnic Sensitivity course for this derogatory remark against the Italian peoples.

See Also