diff --git a/a/Assembler 6502.asm b/a/Assembler 6502.asm index ed62163..cf3bfc1 100644 --- a/a/Assembler 6502.asm +++ b/a/Assembler 6502.asm @@ -1,21 +1,17 @@ -; goodbyeworld.s for C= 8-bit machines, ca65 assembler format. -; String printing limited to strings of 256 characters or less. - -a_cr = $0d ; Carriage return. -bsout = $ffd2 ; KERNAL ROM, output a character to current device. +a_cr = $0d +bsout = $ffd2 .code - ldx #0 ; Starting index 0 in X register. + ldx #0 printnext: - lda text,x ; Get character from string. - beq done ; If we read a 0 we're done. - jsr bsout ; Output character. - inx ; Increment index to next character. - bne printnext ; Repeat if index doesn't overflow to 0. + lda text,x + beq done + jsr bsout + inx + bne printnext done: - rts ; Return from subroutine. - + rts .rodata text: diff --git a/a/Assembler 6502appleII.asm b/a/Assembler 6502appleII.asm index 5b37e36..741d07e 100644 --- a/a/Assembler 6502appleII.asm +++ b/a/Assembler 6502appleII.asm @@ -1,4 +1,4 @@ -STROUT EQU $DB3A ;OUTPUTS AY-POINTED NULL TERMINATED STRING +STROUT EQU $DB3A LDY #>HELLO LDA # wait for end of scanline) + REPEAT 3 + sta WSYNC REPEND lda #0 - sta VSYNC ; Signal vertical sync by clearing the bit + sta VSYNC -PreparePlayfield: ; We'll use the first VBLANK scanline for setup - lda #$00 ; (could have done it before, just once) - sta ENABL ; Turn off ball, missiles and players +PreparePlayfield: + lda #$00 + sta ENABL sta ENAM0 sta ENAM1 sta GRP0 sta GRP1 - sta COLUBK ; Background color (black) - sta PF0 ; PF0 and PF2 will be "off" (we'll focus on PF1)... + sta COLUBK + sta PF0 sta PF2 - lda #$FF ; Playfield collor (yellow-ish) + lda #$FF sta COLUPF - lda #$00 ; Ensure we will duplicate (and not reflect) PF + lda #$00 sta CTRLPF - ldx #0 ; X will count visible scanlines, let's reset it - REPEAT 37 ; Wait until this (and the other 36) vertical blank - sta WSYNC ; scanlines are finished + ldx #0 + REPEAT 37 + sta WSYNC REPEND - lda #0 ; Vertical blank is done, we can "turn on" the beam + lda #0 sta VBLANK Scanline: - cpx #174 ; "HELLO WORLD" = (11 chars x 8 lines - 1) x 2 scanlines = - bcs ScanlineEnd ; 174 (0 to 173). After that, skip drawing code - txa ; We want each byte of the hello world phrase on 2 scanlines, - lsr ; which means Y (bitmap counter) = X (scanline counter) / 2. - tay ; For division by two we use (A-only) right-shift - lda Phrase,y ; "Phrase,Y" = mem(Phrase+Y) (Y-th address after Phrase) - sta PF1 ; Put the value on PF bits 4-11 (0-3 is PF0, 12-15 is PF2) + cpx #174 + bcs ScanlineEnd + txa + lsr + tay + lda Phrase,y + sta PF1 ScanlineEnd: - sta WSYNC ; Wait for scanline end - inx ; Increase counter; repeat untill we got all kernel scanlines + sta WSYNC + inx cpx #191 bne Scanline Overscan: - lda #%01000010 ; "turn off" the beam again... - sta VBLANK ; - REPEAT 30 ; ...for 30 overscan scanlines... + lda #%01000010 + sta VBLANK + REPEAT 30 sta WSYNC REPEND - jmp StartFrame ; ...and start it over! + jmp StartFrame Phrase: - .BYTE %00000000 ; H + .BYTE %00000000 .BYTE %01000010 .BYTE %01111110 .BYTE %01000010 .BYTE %01000010 .BYTE %01000010 .BYTE %00000000 - .BYTE %00000000 ; E + .BYTE %00000000 .BYTE %01111110 .BYTE %01000000 .BYTE %01111100 @@ -83,7 +80,7 @@ Phrase: .BYTE %01000000 .BYTE %01111110 .BYTE %00000000 - .BYTE %00000000 ; L + .BYTE %00000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01000000 @@ -91,14 +88,14 @@ Phrase: .BYTE %01000000 .BYTE %01111110 .BYTE %00000000 - .BYTE %00000000 ; L + .BYTE %00000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01111110 - .BYTE %00000000 ; O + .BYTE %00000000 .BYTE %00000000 .BYTE %00111100 .BYTE %01000010 @@ -107,7 +104,6 @@ Phrase: .BYTE %01000010 .BYTE %00111100 .BYTE %00000000 - .BYTE %00000000 ; white space .BYTE %00000000 .BYTE %00000000 .BYTE %00000000 @@ -115,7 +111,8 @@ Phrase: .BYTE %00000000 .BYTE %00000000 .BYTE %00000000 - .BYTE %00000000 ; W + .BYTE %00000000 + .BYTE %00000000 .BYTE %01000010 .BYTE %01000010 .BYTE %01000010 @@ -123,7 +120,7 @@ Phrase: .BYTE %01011010 .BYTE %00100100 .BYTE %00000000 - .BYTE %00000000 ; O + .BYTE %00000000 .BYTE %00111100 .BYTE %01000010 .BYTE %01000010 @@ -131,7 +128,7 @@ Phrase: .BYTE %01000010 .BYTE %00111100 .BYTE %00000000 - .BYTE %00000000 ; R + .BYTE %00000000 .BYTE %01111100 .BYTE %01000010 .BYTE %01000010 @@ -139,7 +136,7 @@ Phrase: .BYTE %01000100 .BYTE %01000010 .BYTE %00000000 - .BYTE %00000000 ; L + .BYTE %00000000 .BYTE %01000000 .BYTE %01000000 .BYTE %01000000 @@ -147,21 +144,19 @@ Phrase: .BYTE %01000000 .BYTE %01111110 .BYTE %00000000 - .BYTE %00000000 ; D + .BYTE %00000000 .BYTE %01111000 .BYTE %01000100 .BYTE %01000010 .BYTE %01000010 .BYTE %01000100 .BYTE %01111000 - .BYTE %00000000 ; Last byte written to PF1 (important, ensures lower tip - ; of letter "D" won't "bleeed") + .BYTE %00000000) - ORG $FFFA ; Cart config (so 6502 can start it up) - - .WORD StartFrame ; NMI - .WORD StartFrame ; RESET - .WORD StartFrame ; IRQ + ORG $FFFA + .WORD StartFrame + .WORD StartFrame + .WORD StartFrame END diff --git a/a/Assembler FASM DOS.asm b/a/Assembler FASM DOS.asm index c728c5a..3f20f73 100644 --- a/a/Assembler FASM DOS.asm +++ b/a/Assembler FASM DOS.asm @@ -4,13 +4,13 @@ entry .code: start segment .code start: - mov ax, .data ; put data segment into ax - mov ds, ax ; there, I setup the DS for you - mov dx, msg ; now I give you the offset in DX. DS:DX now completed. + mov ax, .data + mov ds, ax + mov dx, msg mov ah, 9h int 21h mov ah, 4ch int 21h segment .data - msg db 'Hello World', '$' \ No newline at end of file + msg db 'Hello World', '$' diff --git a/a/Assembler HP85.asm b/a/Assembler HP85.asm index 41a6b51..759025c 100644 --- a/a/Assembler HP85.asm +++ b/a/Assembler HP85.asm @@ -1,4 +1,4 @@ -010 ! Hello world in Assembler for the HP-85 +010 020 NAM HELLO 030 DEF RUNTIM 040 DEF TOKENS diff --git a/a/Assembler Intel.asm b/a/Assembler Intel.asm index 099f8f4..864d8cc 100644 --- a/a/Assembler Intel.asm +++ b/a/Assembler Intel.asm @@ -1,4 +1,3 @@ -; hello_world.asm intel .model small @@ -12,7 +11,7 @@ main proc mov ax,@data mov ds, ax -; hello-world is there + mov dx,offset msg mov ah,09 int 21h diff --git a/a/Assembler MASM DOS.asm b/a/Assembler MASM DOS.asm index f030afb..d859068 100644 --- a/a/Assembler MASM DOS.asm +++ b/a/Assembler MASM DOS.asm @@ -1,4 +1,4 @@ -; 16 bit dos assembly + .model small .stack .data diff --git a/a/Assembler MASM Win32.asm b/a/Assembler MASM Win32.asm index 658d323..3b2dc67 100644 --- a/a/Assembler MASM Win32.asm +++ b/a/Assembler MASM Win32.asm @@ -19,17 +19,17 @@ bytesWritten DWORD ? .code main PROC - push -11 ; nStdHandle (STD_OUTPUT_HANDLE) + push -11 call GetStdHandle@4 - push 0 ; lpReserved - push OFFSET bytesWritten ; lpNumberOfCharsWritten - push LENGTHOF msg - 1 ; nNumberOfCharsToWrite - push OFFSET msg ; *lpBuffer - push eax ; hConsoleOutput + push 0 + push OFFSET bytesWritten + push LENGTHOF msg - 1 + push OFFSET msg + push eax call WriteConsoleA@20 - push 0 ; uExitCode + push 0 call ExitProcess@4 main ENDP END main diff --git a/a/Assembler MASM Win64.asm b/a/Assembler MASM Win64.asm index 3b4271a..5f564ad 100644 --- a/a/Assembler MASM Win64.asm +++ b/a/Assembler MASM Win64.asm @@ -15,19 +15,19 @@ bytesWritten DWORD ? .code main PROC - sub rsp, 5 * 8 ; reserve shadow space + sub rsp, 5 * 8 - mov rcx, -11 ; nStdHandle (STD_OUTPUT_HANDLE) + mov rcx, -11 call GetStdHandle - mov rcx, rax ; hConsoleOutput - lea rdx, msg ; *lpBuffer - mov r8, LENGTHOF msg - 1 ; nNumberOfCharsToWrite - lea r9, bytesWritten ; lpNumberOfCharsWritten - mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0 ; lpReserved + mov rcx, rax + lea rdx, msg + mov r8, LENGTHOF msg - 1 + lea r9, bytesWritten + mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0 call WriteConsoleA - mov rcx, 0 ; uExitCode + mov rcx, 0 call ExitProcess main ENDP END diff --git a/a/Assembler MIPS.asm b/a/Assembler MIPS.asm index 7a3c035..b6b73db 100644 --- a/a/Assembler MIPS.asm +++ b/a/Assembler MIPS.asm @@ -2,8 +2,8 @@ hw: .asciiz "Hello World" .text main: - la $a0, hw #load the address of hw into $a0 - li $v0, 4 #load 4 into $v0 - syscall #perform the print_string syscall - li $v0, 10 #load 10 into $v0 - syscall #perform the exit syscall + la $a0, hw + li $v0, 4 + syscall + li $v0, 10 + syscall diff --git a/a/Assembler NASM FreeBSD.asm b/a/Assembler NASM FreeBSD.asm index bc58e81..ccff72e 100644 --- a/a/Assembler NASM FreeBSD.asm +++ b/a/Assembler NASM FreeBSD.asm @@ -1,31 +1,26 @@ section .text - global _start ;must be declared for linker (ld) + global _start _syscall: - int 0x80 ;system call + int 0x80 ret -_start: ;tell linker entry point +_start: - push dword len ;message length - push dword msg ;message to write - push dword 1 ;file descriptor (stdout) - mov eax,0x4 ;system call number (sys_write) - call _syscall ;call kernel + push dword len + push dword msg + push dword 1 + mov eax,0x4 + call _syscall - ;the alternate way to call kernel: - ;push eax - ;call 7:0 - add esp,12 ;clean stack (3 arguments * 4) + add esp,12 - push dword 0 ;exit code - mov eax,0x1 ;system call number (sys_exit) - call _syscall ;call kernel + push dword 0 + mov eax,0x1 + call _syscall - ;we do not return from sys_exit, - ;there's no need to clean stack section .data -msg db "Hello World",0xa ;our string -len equ $ - msg ;length of our string +msg db "Hello World",0xa +len equ $ - msg \ No newline at end of file diff --git a/a/Assembler NASM Linux.asm b/a/Assembler NASM Linux.asm index d740364..201bf97 100644 --- a/a/Assembler NASM Linux.asm +++ b/a/Assembler NASM Linux.asm @@ -1,20 +1,20 @@ section .text - global _start ;must be declared for linker (ld) + global _start -_start: ;tell linker entry point +_start: - xor ebx,ebx ;ebx=0 - mov ecx,msg ;address of message to write - lea edx,[ebx+len] ;message length - lea eax,[ebx+4] ;system call number (sys_write) - inc ebx ;file descriptor (stdout) - int 0x80 ;call kernel + xor ebx,ebx + mov ecx,msg + lea edx,[ebx+len] + lea eax,[ebx+4] + inc ebx + int 0x80 - xor eax, eax ;set eax=0 - inc eax ;system call number (sys_exit) - int 0x80 ;call kernel + xor eax, eax + inc eax + int 0x80 section .rodata -msg db 'Hello World',0xa ;our string -len equ $ - msg ;length of our string +msg db 'Hello World',0xa +len equ $ - msg \ No newline at end of file diff --git a/a/Assembler NASM Linux64.asm b/a/Assembler NASM Linux64.asm index f7d522c..c9c6447 100644 --- a/a/Assembler NASM Linux64.asm +++ b/a/Assembler NASM Linux64.asm @@ -1,17 +1,16 @@ section .rodata - msg db "Hello World", 0xA ; String to print - len equ $- msg ; Length of string - + msg db "Hello World", 0xA + len equ $- msg section .text - global _start ; Specify entry point to linker + global _start _start: - mov eax, 1 ; System call ID (sys_write) - mov edi, eax ; File descriptor (stdout) - mov esi, msg ; Text to print - mov edx, len ; Length of text to print - syscall ; Call kernel + mov eax, 1 + mov edi, eax + mov esi, msg + mov edx, len + syscall - mov eax, 60 ; System call ID (sys_exit) - xor edi, edi ; Error code (EXIT_SUCCESS) - syscall ; Call kernel + mov eax, 60 + xor edi, edi + syscall diff --git a/a/Assembler NASM Macho64.asm b/a/Assembler NASM Macho64.asm index ab570cd..958e159 100644 --- a/a/Assembler NASM Macho64.asm +++ b/a/Assembler NASM Macho64.asm @@ -2,13 +2,13 @@ global start section .text start: - mov rax, 0x2000004 ; write - mov rdi, 1 ; stdout + mov rax, 0x2000004 + mov rdi, 1 mov rsi, msg mov rdx, msg.len syscall - mov rax, 0x2000001 ; exit + mov rax, 0x2000001 mov rdi, 0 syscall diff --git a/a/Assembler m68000 amigaos.asm b/a/Assembler m68000 amigaos.asm index b9b9288..1214fc8 100644 --- a/a/Assembler m68000 amigaos.asm +++ b/a/Assembler m68000 amigaos.asm @@ -1,4 +1,4 @@ -; "Hello World" in Motorola 68000 machine language, for AmigaOS + ExecBase = 4 OpenLibrary = -552 @@ -7,7 +7,6 @@ PutStr = -948 section "main", code - ; open "dos.library" move.l ExecBase, a6 lea lib, a1 @@ -15,12 +14,10 @@ PutStr = -948 jsr (OpenLibrary, a6) move.l d0, a6 - ; print the message move.l #msg, d1 jsr (PutStr, a6) - ; close the library, and exit with code 0 move.l a6, a1 move.l ExecBase, a6 diff --git a/a/Assembler tms9900 ti99 4a.asm b/a/Assembler tms9900 ti99 4a.asm index 3034e3f..f7ff21b 100644 --- a/a/Assembler tms9900 ti99 4a.asm +++ b/a/Assembler tms9900 ti99 4a.asm @@ -9,14 +9,12 @@ WRKSP EQU >8300 -VDPWD EQU >8C00 * VDP RAM write data -VDPWA EQU >8C02 * VDP RAM read/write address +VDPWD EQU >8C00 +VDPWA EQU >8C02 -START LIMI 0 * disable interrupts - LWPI WRKSP * set default workspace - -* set VDP RAM start address (low and high byte) +START LIMI 0 + LWPI WRKSP LI R0,>0000 ORI R0,>4000 @@ -25,20 +23,21 @@ START LIMI 0 * disable interrupts SWPB R0 MOVB R0,@VDPWA - LI R1,HELLOWORLD * ascii string address - LI R2,12 * total chars + LI R1,HELLOWORLD + LI R2,12 NEXTCHAR - MOVB *R1+,@VDPWD * put next char on screen + MOVB *R1+,@VDPWD DEC R2 JNE NEXTCHAR LOOPBACK - JMP LOOPBACK * stop and do nothing + JMP LOOPBACK HELLOWORLD - TEXT 'HELLO WORLD' * string data + TEXT 'HELLO WORLD' + BYTE 0 END diff --git a/readme.md b/readme.md index 321c8a9..5c0d52c 100644 --- a/readme.md +++ b/readme.md @@ -154,9 +154,9 @@ Make sure to see [contributing.md](/contributing.md) for instructions on contrib * [Assembler Z80 zxspectrum](a/Assembler%20Z80%20zxspectrum.asm) * [ATS2](a/ATS2.dats) * [Attache](a/Attache.%40) -* [AutoLISP](a/AutoLISP.lsp) * [AutoHotKey](a/AutoHotKey.ahk) * [AutoIt](a/AutoIt.au3) +* [AutoLISP](a/AutoLISP.lsp) * [Avisynth](a/Avisynth.avs) * [Awful](a/Awful.yuk) * [AWK](a/AWK.awk) @@ -516,6 +516,7 @@ Make sure to see [contributing.md](/contributing.md) for instructions on contrib * [Nu](n/Nu.nu) * [NWScript](n/NWScript.nss) * [NXC](n/NXC.nxc) +* [o:XML](o/o%3AXML) * [Oberon 2](o/Oberon%202.obn) * [Oberon](o/Oberon.o) * [Obix](o/Obix.osc) @@ -534,7 +535,6 @@ Make sure to see [contributing.md](/contributing.md) for instructions on contrib * [Oracle SQL](o/Oracle%20SQL.sql) * [Orc](o/Orc.orc) * [OX](o/OX.oz) -* [o:XML](o/o:XML) * [Parenthetic](p/Parenthetic.p) * [Parser](p/Parser.p) * [Pascal](p/Pascal.p)