Servus-Woid-Programm

S' **"Servus-Woid"-Programm** is a Tradition in da Litaratur iaba Programmiersprachn. Do hoasts in deitsche Biacha "Hallo-Welt-Programm" und in de englischn "Hello-World-Program". S' is a oanfachs Programm, des den Text "Servus Woid" aufn Buidschirm schreibt. Ma ko damit zoang, was ma auf jedn Foi in da jeweilign Sproch bracht um iabahaupt a lauffähigs Programm zum schreim. Normalaweis stehts in am jedn Lehrbuach iabas Programmiern glei ganz am Ofang. S'wead a gern heagnumma um zum iabapriafn ob a Compiler oda Interpreter iabahaupt richtig funktioniad.
De Tradition gehd aufn Kernighan Brian zruck, ders 1974 in am internen Handbuach iaba C bei Bell Laboratories gschribn hod.
In da Effntlichkeit is aba eascht bekannt worn, ois da Kernighan Brian zsamad mit'm Ritchie Dennis as Buach *The C Programming Language* rausbracht hod. Do inna drin wurd de Schreibweis „hello, world“ vawendt.
S' Servus-Woid-Programm ghead eingle a zum Liafaumfang vo a jedn Programmiersprach, do findt mas bei de Beispui-Quelltext.

## Beispui
Wia ma an de Beispui sigt, is des manchmoi gor ned so oafach an Text aufn Buidschirm zbringa. Wobei des Beispui "Windows API" scho a bissal mera biet, do kriagt ma a richtigs Fensta, des ma umanandaschiam ko und Gress ändern ko ma a.

### [[Assembler]]
#### [[x86]]-[[CPU]], [[Disk Operating System|DOS]], [[MASM]]


```asm
.MODEL Small
.STACK 100h
.DATA
 HW   DB   'Servus Woid!$'
.CODE

start:
 MOV AX,@data
 MOV DS,AX
 MOV DX, OFFSET HW
 MOV AH, 09H
 INT 21H
 MOV AH, 4Ch
 INT 21H
end start
```


#### [[x86]]-[[CPU]], [[Disk Operating System|DOS]], [[FASM]]


```asm
; Kompiliert: "FASM HELLO.ASM HELLO.COM" 
 org $100
 use16  
 mov ah,9
 mov dx,hello
 int $21  ; Textausgob
 mov ah,$4C
 int $21  ; Programm beendn
hello db 'Servus Woid!$'
```


#### [[x86]]-[[CPU]], [[Linux]]


```asm
# Kompiliert mid "as -o hallo.o hallo.s; ld -o hallo hallo.o"
  .section .data
  s: .ascii "Servus Woid!\n"
  .section .text
  .globl _start
  _start:
  movl $4,%eax   # Syscall-ID 4 (= __NR_write) 
  movl $1,%ebx   # Ausgabe-Filedeskriptor STDOUT (= 1)
  movl $s,%ecx   # Adresse des erstn Zeichns dea Zeichnkettn
  movl $12,%edx   # Länge dea Zeichenkettn (12 Zeichn)
  int $0x80     # Softwäreinterrupt 0x80 um Syscall (write(1,s,12))auszführn
  movl $1,%eax   # Syscall-ID 1 (= __NR_exit)
  movl $0,%ebx   # Rückgobewert 0 (= alles ok)
  int $0x80     # Softwäreinterrupt 0x80 um Syscall (exit(0)) auszführn
```


### [[BASIC]]


```qbasic
10 PRINT "Servus Woid!"
```


### [[C (Programmiersprache)|C]]

```c
#include <stdio.h>

int main(void)
{
  printf("Servus Woid!\n");
  return 0;
}
```


### [[C++]]

```cpp
#include <iostream>
using namespace std;

int main() {
cout<<"Servus Woid"<<endl;
return 0;
}
```


### [[JavaScript]]


```javascript
document.write("Servus Woid!");
```


### [[MS-DOS Batch]]


```dos
@echo Servus Woid!
```


### [[BASH]]


```bash
echo "Servus Woid!"
```


### [[Object Pascal]] (Delphi)


```delphi
program ServusWoid;
{$APPTYPE CONSOLE}

begin
 writeln('Servus Woid!');
end.
```


### [[PHP]]


```php
<?php
  echo "Servus Woid!";
?>
```


### [[Python]] (bis Version 3)


```python2
print "Servus Woid!"
```


### [[Python]] (ab Version 3)


```python3
print("Servus Woid!")
```


### [[Perl]]


```perl
print "Servus Woid!\n";
```


oda


```perl
say "Servus Woid!";
```


### [[Seed7]]

 $ include "seed7_05.s7i";
 
 const proc: main is func
  begin
   writeln("Servus Woid!");
  end func;

### [[Smalltalk]]


```smalltalk
Transcript show: 'Servus Woid!'.
```


### [[Windows API]] (in C)


```c
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
 MessageBox(0, "Servus Woid!", "Mei ersts Programm", MB_OK);
 return 0;
}
```


Oder mit am eignem Fensta


```c
#include <windows.h>

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

char szClassName[] = "MainWnd";
HINSTANCE hInstance;

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
 HWND hwnd;
 MSG msg;
 WNDCLASSEX wincl;

 hInstance = hInst;

 wincl.cbSize = sizeof(WNDCLASSEX);
 wincl.cbClsExtra = 0;
 wincl.cbWndExtra = 0;
 wincl.style = 0;
 wincl.hInstance = hInstance;
 wincl.lpszClassName = szClassName;
 wincl.lpszMenuName = NULL; //No menu
 wincl.lpfnWndProc = WindowProcedure;
 wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); //Color of the window
 wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon
 wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon
 wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor

 if (!RegisterClassEx(&wincl))
    return 0;

 hwnd = CreateWindowEx(0, //No extended window styles
    szClassName, //Class name
    "", //Window caption
    WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
    CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top positions of the window
    120, 50, //Width and height of the window,
    NULL, NULL, hInstance, NULL);

 //Make the window visible on the screen
 ShowWindow(hwnd, nCmdShow);

 //Run the message loop
 while (GetMessage(&msg, NULL, 0, 0))
 {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
 }
 return msg.wParam;
}

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 PAINTSTRUCT ps;
 HDC hdc;
 switch (message)
 {
 case WM_PAINT:
    hdc = BeginPaint(hwnd, &ps);
    TextOut(hdc, 15, 3, "Servus Woid!", 13);
    EndPaint(hwnd, &ps);
    break;
 case WM_DESTROY:
    PostQuitMessage(0);
    break;
 default:
    return DefWindowProc(hwnd, message, wParam, lParam);
 }
 return 0;
}
```


### [[SQL]] ([[Oracle]])


```sql
select 'Servus Woid!' from dual;
```


## Im Netz