Assembler
![]() |
Hello World | 6502, Apple II (II+, IIe, IIC) | Steve Hawley |
; Uses S-C Assembler variant. ; .or is origin ; .as is ASCII String ; .hs is Hex String .or $300 main ldy #$00 .1 lda str,y beq .2 jsr $fded ; ROM routine, COUT, y is preserved iny bne .1 .2 rts str .as "HELLO WORLD" .hs 0D00 |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | IBM Assembler/370 (VM/CMS) | B. Bora Bali |
TITLE 'Hello World for IBM Assembler/370 (VM/CMS)' HELLO START BALR 12,0 USING *,12 * WRTERM 'Hello World!' * SR 15,15 BR 14 * END HELLO |
Gibt "Hello World" auf dem Bildschirm
aus. |
Squares | IBM Assembler/370 (VM/CMS) | B. Bora Bali |
TITLE 'Squares from 1 to 10 - IBM Assembler/370 (VM/CMS)' * SQUARE START BALR 12,0 USING *,12 * LA 4,1 * Start value = 1 LR 2,4 * Increment by 1 LA 3,10 * Range value = 10 * LOOP EQU * LR 7,4 * Copy the loop value MR 6,7 * Multiply by itself * CVD 7,DW * Convert it to decimal MVC WORKAREA,PATTERN * Copy edit pattern EDMK WORKAREA,DW * Convert decimal value to character WRTERM WORKAREA,16 * Display * BXLE 4,2,LOOP * Iterate until R4 <= R3 * SR 15,15 BR 14 * DW DS D WORKAREA DS XL16 PATTERN DC X'40202020202020202020202020202120' * END SQUARE |
Gibt die Quadrate von 1 bis 10
aus. |
Hello World | Intel 80x86 (DOS, MASM) | Brad Coomer |
.MODEL tiny .CODE ORG 100h HELLO PROC MOV AH,09h LEA DX,msg INT 21h ;Display Hello World MOV AX,4C00h ;Exit to DOS INT 21h HELLO ENDP msg DB 'Hello World$' END HELLO |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | Intel 80x86 (DOS, TASM) | Michael Neumann |
; WRITTEN IN TASM (Turbo Assembler) .MODEL TINY CODE SEGMENT ASSUME CS:CODE, DS:CODE ORG 100h START: mov ah,9 mov dx,OFFSET Msg int 21h int 20h Msg DB 'Hello World',13,10,'$' CODE ENDS END START |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | Intel 80x86 (gas/NetBSD) | Michael Neumann |
/* * Hello World in gas/NetBSD * AT/T-Syntax * * Compile: * gas hw.s * ld -s -o hw a.out */ .data msg: .string "Hello World\n" len: .long . - msg .text .globl _start _start: push $len /* Laenge */ push $msg /* Adresse */ push $1 /* Stdout */ movl $0x4, %eax /* write */ call _syscall addl $12, %esp /* Stack bereinigen */ push $0 movl $0x1, %eax /* exit */ call _syscall _syscall: int $0x80 ret |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | Intel 80x86 (nasm/NetBSD(aout)) | Michael Neumann |
; ; Hello World in nasm/NetBSD(aout) ; ; Compile: ; nasm -f aoutb hw.asm ; ld -s -o hw hw.o section .text _start: push dword len ; Länge push dword msg ; Adresse push dword 1 ; Stdout mov eax, 0x4 ; write call _syscall add esp, 12 ; Stack bereinigen push dword 0 mov eax, 0x1 ; exit call _syscall _syscall: int 0x80 ret msg db "Hello World",0xa len equ $ - msg |
Gibt "Hello World" auf dem Bildschirm
aus. |
Fast and Good Hash Function | Intel 80x86 (nasm) | Michael Neumann |
;; ;; A Fast and Good Hash Function ;; ;; Algorithm by Bob Jenkins, December 1996 ;; (see http://burtleburtle.net/bob/c/lookupa.c for C version) ;; ;; Implemented by Michael Neumann, June 2002. ;; ;; Requires NASM - the Netwide Assembler. ;; global s_lookup section .text %macro mix_line 6 ;;; parameters: r x y shift temp direction(left|right) ;;; r -= x; r -= y; r ^= (y(>>|<<)shift) ; r -= x sub %1, %2 ; r -= y sub %1, %3 ; r ^= (y>>shift) mov %5, %3 %ifidni %6,left shl %5, %4 %else shr %5, %4 %endif xor %1, %5 %endmacro %macro mix 4 ;;; parameters: a b c temp ;;;a -= b; a -= c; a ^= (c>>13); mix_line %1, %2, %3, 13, %4, right ;;;b -= c; b -= a; b ^= (a<<8); mix_line %2, %3, %1, 8, %4, left ;;;c -= a; c -= b; c ^= (b>>13); mix_line %3, %1, %2, 13, %4, right ;;;a -= b; a -= c; a ^= (c>>12); mix_line %1, %2, %3, 12, %4, right ;;;b -= c; b -= a; b ^= (a<<16); mix_line %2, %3, %1, 16, %4, left ;;;c -= a; c -= b; c ^= (b>>5); mix_line %3, %1, %2, 5, %4, right ;;;a -= b; a -= c; a ^= (c>>3); mix_line %1, %2, %3, 3, %4, right ;;;b -= c; b -= a; b ^= (a<<10); mix_line %2, %3, %1, 10, %4, left ;;;c -= a; c -= b; c ^= (b>>15); mix_line %3, %1, %2, 15, %4, right %endmacro jump_table: dd case0, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10, case11 ; unsigned long s_lookup(void *key, int length, int level) s_lookup: %define temp edx ; temporary register: edx %define a ecx ; a %define b ebx ; b %define c eax ; c %define len edi ; len %define key esi ; key push ebp mov ebp, esp push esi push edi push ebx push ecx push edx ; -------------------------------------------------------- mov key, [ebp+8] ; first argument (key) ; Set up the internal state ;;; len = length mov len, [ebp+12] ; second argument (length) ;;; a = b = 0x9e3779b9 mov a, 9e3779b9h mov b, a ;;; c = level mov c, [ebp+16] ;;; while (len >= 12) while: cmp len, 12 jl near end_while ; exit if len < 12 ;;; a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); add a, [key] ;;; b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); add b, [key+4] ;;; c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); add c, [key+8] mix a, b, c, temp add key, 12 sub len, 12 jmp near while end_while: ;;; c += length; add c, [ebp+12] ;; jump table jmp [jump_table+len*4] case11: add a, [key] ; cases 1,2,3,4 add b, [key+4] ; cases 5,6,7,8 mov temp, [key+8] ; cases 9,10,11 shl temp, 8 add c, temp jmp ende case10: add a, [key] ; cases 1,2,3,4 add b, [key+4] ; cases 5,6,7,8 mov temp, [key+8] ; cases 9,10 shl temp, 8 and temp, 0FFFFFFh add c, temp jmp ende case9: add a, [key] ; cases 1,2,3,4 add b, [key+4] ; cases 5,6,7,8 mov temp, [key+8] ; cases 9 shl temp, 8 and temp, 0FFFFh add c, temp jmp ende case8: add a, [key] ; cases 1,2,3,4 add b, [key+4] ; cases 5,6,7,8 jmp ende case7: add a, [key] ; cases 1,2,3,4 mov temp, [key+4] ; cases 5,6,7 and temp, 0FFFFFFh add b, temp jmp ende case6: add a, [key] ; cases 1,2,3,4 mov temp, [key+4] ; cases 5,6 and temp, 0FFFFh add b, temp jmp ende case5: add a, [key] ; cases 1,2,3,4 mov temp, [key+4] ; cases 5 and temp, 0FFh add b, temp jmp ende case3: mov temp, [key] and temp, 0FFFFFFh add a, temp ; cases 1,2,3 jmp ende case2: mov temp, [key] and temp, 0FFFFh add a, temp ; cases 1,2 jmp ende case1: mov temp, [key] and temp, 0FFh add a, temp ; cases 1 jmp ende ;; the last case should be the most often occuring one (so we can save one jump instruction) case4: add a, [key] ; cases 1,2,3,4 case0: ende: mix a, b, c, temp ; return value in eax %ifnidni c,eax mov eax, c %endif ; -------------------------------------------------------- pop edx pop ecx pop ebx pop edi pop esi pop ebp ret |
Generates 32-bit hash values from a
given string. |
Hello World | MIDAS PDP-10 (MIT Incompatible Timesharing System) | Rob Austein |
;; Hello world in MIDAS title hello start: .open [.uao,,'tty ? 0 ? 0] .lose %lsfil move 1, [440700,,[asciz "Hello, world "]] loop: ildb 2,1 skipn 2 .logou 1, .iot 2 jrst loop end start |
Gibt "Hello World" auf dem Bildschirm
aus. |
Squares | MIDAS PDP-10 (MIT Incompatible Timesharing System) | Rob Austein |
;; Squares of integers 1..10 in MIDAS title squares p==17 .vector pdl(lpdl==200) ttyo==:5 start: move p, [-lpdl,,pdl-1] .open ttyo, [.uao,,'tty ? 0 ? 0] .lose %lsfil move 1, [-12,,1] loop: hrrz 2, 1 imul 2, 2 pushj p, print movei 2, 15 .iot ttyo, 2 movei 2, 12 .iot ttyo, 2 aobjn 1, loop .logou 1, print: idivi 2, 12 push p, 3 skipe 2 pushj p, print pop p, 2 addi 2, "0 .iot ttyo, 2 popj p, end start |
Gibt die Quadrate von 1 bis 10
aus. |
Hello World | MIPS R2000 | Christian Heinig |
.data # Datensegment str: .asciiz "Hello World!\n" # String ablegen .text # Codesegment main: li $v0, 4 # 4 = Print_string la $a0, str # Adresse des Strings übergeben syscall # Systemfunktion aufrufen li $v0, 10 # 10 = Quit syscall # Programm beenden |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | Motorola 68000 (ATARI) | Michael Neumann |
start: ; Message-String ausgeben move.l #msg,-(a7) move.w #9,-(a7) trap #1 addq.l #6,a7 ; auf Taste warten move.w #1,-(a7) trap #1 addq.l #2,a7 ; Programm beenden clr -(a7) trap #1 msg: dc.b "Hello World",10,13,0 |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World | VAX | Daniel Lundin |
LL0: .data .text L .align 1 .globl _main _main: .word L12 jbr L14 L15: .data 1 L17: .ascii "Hello, world.2" .text pushl $L17 calls $1,_puts ret .set L12,0x0 L14: jbr L15 .data |
Gibt "Hello World" auf dem Bildschirm
aus. |