Clean up Assembly files (#1003)

This commit is contained in:
MrBrain295
2021-05-08 09:57:36 -05:00
committed by GitHub
parent 45856bf57b
commit 7f7369291b
20 changed files with 174 additions and 196 deletions

View File

@@ -1,21 +1,17 @@
; goodbyeworld.s for C= 8-bit machines, ca65 assembler format. a_cr = $0d
; String printing limited to strings of 256 characters or less. bsout = $ffd2
a_cr = $0d ; Carriage return.
bsout = $ffd2 ; KERNAL ROM, output a character to current device.
.code .code
ldx #0 ; Starting index 0 in X register. ldx #0
printnext: printnext:
lda text,x ; Get character from string. lda text,x
beq done ; If we read a 0 we're done. beq done
jsr bsout ; Output character. jsr bsout
inx ; Increment index to next character. inx
bne printnext ; Repeat if index doesn't overflow to 0. bne printnext
done: done:
rts ; Return from subroutine. rts
.rodata .rodata
text: text:

View File

@@ -1,4 +1,4 @@
STROUT EQU $DB3A ;OUTPUTS AY-POINTED NULL TERMINATED STRING STROUT EQU $DB3A
LDY #>HELLO LDY #>HELLO
LDA #<HELLO LDA #<HELLO
JMP STROUT JMP STROUT

View File

@@ -6,28 +6,27 @@
;*************************************************************************** ;***************************************************************************
org 0 org 0
; this header required to identify ROM by Vectrex hardware (only year allowed to change)
db "g GCE 2016", $80 ; 'g' is copyright sign
dw $F600 ; music from the rom (no music)
db $FC, $30, 33, -$2a ; height, width, rel y, rel x for app title
db "HELLO WORLD", $80 ; app title, ending with $80
db 0 ; end of header
; main loop (required to redraw vectors on CRT screen) db "g GCE 2016", $80
dw $F600
db $FC, $30, 33, -$2a
db "HELLO WORLD", $80
db 0
loop: loop:
; recalibrate CRT, reset beam to 0,0 (center of the screen) jsr $f192
jsr $f192 ; Wait_Recal subroutine in ROM
ldu #helloworld ; string address ldu #helloworld
lda #10 ; Y lda #10
ldb #-45 ; X ldb #-45
jsr $f37a ; Print_Str_d subroutine in ROM jsr $f37a
bra loop bra loop
; Text data ($80 - end of line)
helloworld: db 'Hello World',$80 helloworld: db 'Hello World',$80

View File

@@ -6,45 +6,44 @@
cpu 8048 cpu 8048
org 400h org 400h
; interrupt vectors
jmp 02C3h ; selectgame (RESET)
jmp 0009h ; irq
jmp timer ; timer
jmp 001Ah ; vsyncirq
jmp start ; after selectgame
jmp 0044h ; soundirq
jmp 02C3h
jmp 0009h
jmp timer
jmp 001Ah
jmp start
jmp 0044h
timer: timer:
ret ; no timer needed ret
start: start:
call 011Ch ; gfxoff call 011Ch
mov r0,#010h ; pointer in VDC - which char to display (one of 12) mov r0,#010h
mov r3,#40 ; x mov r3,#40
mov r4,#100 ; y mov r4,#100
mov r1,#hellostr & 0ffh ; string to print (should be on same 255 bytes page) mov r1,#hellostr & 0ffh
mov r2,#11 ; string length mov r2,#11
nextchar: nextchar:
mov a,r1 mov a,r1
movp a,@a ; get char located at @r1 movp a,@a
mov r5,a mov r5,a
inc r1 ; inc addr of char inc r1
mov r6,#0eh ; white color mov r6,#0eh
call 03EAh ; printchar bios subroutine (increases r0, r3) call 03EAh
djnz r2,nextchar djnz r2,nextchar
call 0127h ; gfxon (show what is written to VDC) call 0127h
loop: loop:
jmp loop ; just wait and do nothing jmp loop
; 'HELLO WORLD' (ascii not supported by assembler)
hellostr: hellostr:
db 01dh, 012h, 00eh, 00eh, 017h, 00ch, 011h, 017h, 013h, 00eh, 01ah db 01dh, 012h, 00eh, 00eh, 017h, 00ch, 011h, 017h, 013h, 00eh, 01ah

View File

@@ -4,10 +4,10 @@ message: .asciz "Hello World\n"
.text .text
.global main .global main
main: main:
mov r0, #1 @ file descriptor 1 mov r0, #1
ldr r1, =message @ load address of message ldr r1, =message
mov r7, #4 @ system call write mov r7, #4
swi #0 @ display message swi #0
mov r0, #0 mov r0, #0
bx lr bx lr

View File

@@ -1,6 +1,4 @@
;
; hello.asm
;
; A "Hello, World!" which illustrates an Atari 2600 programming ; A "Hello, World!" which illustrates an Atari 2600 programming
; introduction talk (slides at http://slideshare.net/chesterbr). ; introduction talk (slides at http://slideshare.net/chesterbr).
; ;
@@ -13,69 +11,68 @@
PROCESSOR 6502 PROCESSOR 6502
INCLUDE "vcs.h" INCLUDE "vcs.h"
ORG $F000 ; Start of "cart area" (see Atari memory map) ORG $F000
StartFrame: StartFrame:
lda #%00000010 ; Vertical sync is signaled by VSYNC's bit 1... lda #%00000010
sta VSYNC sta VSYNC
REPEAT 3 ; ...and lasts 3 scanlines REPEAT 3
sta WSYNC ; (WSYNC write => wait for end of scanline) sta WSYNC
REPEND REPEND
lda #0 lda #0
sta VSYNC ; Signal vertical sync by clearing the bit sta VSYNC
PreparePlayfield: ; We'll use the first VBLANK scanline for setup PreparePlayfield:
lda #$00 ; (could have done it before, just once) lda #$00
sta ENABL ; Turn off ball, missiles and players sta ENABL
sta ENAM0 sta ENAM0
sta ENAM1 sta ENAM1
sta GRP0 sta GRP0
sta GRP1 sta GRP1
sta COLUBK ; Background color (black) sta COLUBK
sta PF0 ; PF0 and PF2 will be "off" (we'll focus on PF1)... sta PF0
sta PF2 sta PF2
lda #$FF ; Playfield collor (yellow-ish) lda #$FF
sta COLUPF sta COLUPF
lda #$00 ; Ensure we will duplicate (and not reflect) PF lda #$00
sta CTRLPF sta CTRLPF
ldx #0 ; X will count visible scanlines, let's reset it ldx #0
REPEAT 37 ; Wait until this (and the other 36) vertical blank REPEAT 37
sta WSYNC ; scanlines are finished sta WSYNC
REPEND REPEND
lda #0 ; Vertical blank is done, we can "turn on" the beam lda #0
sta VBLANK sta VBLANK
Scanline: Scanline:
cpx #174 ; "HELLO WORLD" = (11 chars x 8 lines - 1) x 2 scanlines = cpx #174
bcs ScanlineEnd ; 174 (0 to 173). After that, skip drawing code bcs ScanlineEnd
txa ; We want each byte of the hello world phrase on 2 scanlines, txa
lsr ; which means Y (bitmap counter) = X (scanline counter) / 2. lsr
tay ; For division by two we use (A-only) right-shift tay
lda Phrase,y ; "Phrase,Y" = mem(Phrase+Y) (Y-th address after Phrase) lda Phrase,y
sta PF1 ; Put the value on PF bits 4-11 (0-3 is PF0, 12-15 is PF2) sta PF1
ScanlineEnd: ScanlineEnd:
sta WSYNC ; Wait for scanline end sta WSYNC
inx ; Increase counter; repeat untill we got all kernel scanlines inx
cpx #191 cpx #191
bne Scanline bne Scanline
Overscan: Overscan:
lda #%01000010 ; "turn off" the beam again... lda #%01000010
sta VBLANK ; sta VBLANK
REPEAT 30 ; ...for 30 overscan scanlines... REPEAT 30
sta WSYNC sta WSYNC
REPEND REPEND
jmp StartFrame ; ...and start it over! jmp StartFrame
Phrase: Phrase:
.BYTE %00000000 ; H .BYTE %00000000
.BYTE %01000010 .BYTE %01000010
.BYTE %01111110 .BYTE %01111110
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; E .BYTE %00000000
.BYTE %01111110 .BYTE %01111110
.BYTE %01000000 .BYTE %01000000
.BYTE %01111100 .BYTE %01111100
@@ -83,7 +80,7 @@ Phrase:
.BYTE %01000000 .BYTE %01000000
.BYTE %01111110 .BYTE %01111110
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; L .BYTE %00000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
@@ -91,14 +88,14 @@ Phrase:
.BYTE %01000000 .BYTE %01000000
.BYTE %01111110 .BYTE %01111110
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; L .BYTE %00000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01111110 .BYTE %01111110
.BYTE %00000000 ; O .BYTE %00000000
.BYTE %00000000 .BYTE %00000000
.BYTE %00111100 .BYTE %00111100
.BYTE %01000010 .BYTE %01000010
@@ -107,7 +104,6 @@ Phrase:
.BYTE %01000010 .BYTE %01000010
.BYTE %00111100 .BYTE %00111100
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; white space
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 .BYTE %00000000
@@ -115,7 +111,8 @@ Phrase:
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; W .BYTE %00000000
.BYTE %00000000
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
@@ -123,7 +120,7 @@ Phrase:
.BYTE %01011010 .BYTE %01011010
.BYTE %00100100 .BYTE %00100100
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; O .BYTE %00000000
.BYTE %00111100 .BYTE %00111100
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
@@ -131,7 +128,7 @@ Phrase:
.BYTE %01000010 .BYTE %01000010
.BYTE %00111100 .BYTE %00111100
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; R .BYTE %00000000
.BYTE %01111100 .BYTE %01111100
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
@@ -139,7 +136,7 @@ Phrase:
.BYTE %01000100 .BYTE %01000100
.BYTE %01000010 .BYTE %01000010
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; L .BYTE %00000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
.BYTE %01000000 .BYTE %01000000
@@ -147,21 +144,19 @@ Phrase:
.BYTE %01000000 .BYTE %01000000
.BYTE %01111110 .BYTE %01111110
.BYTE %00000000 .BYTE %00000000
.BYTE %00000000 ; D .BYTE %00000000
.BYTE %01111000 .BYTE %01111000
.BYTE %01000100 .BYTE %01000100
.BYTE %01000010 .BYTE %01000010
.BYTE %01000010 .BYTE %01000010
.BYTE %01000100 .BYTE %01000100
.BYTE %01111000 .BYTE %01111000
.BYTE %00000000 ; Last byte written to PF1 (important, ensures lower tip .BYTE %00000000)
; of letter "D" won't "bleeed")
ORG $FFFA ; Cart config (so 6502 can start it up) ORG $FFFA
.WORD StartFrame
.WORD StartFrame ; NMI .WORD StartFrame
.WORD StartFrame ; RESET .WORD StartFrame
.WORD StartFrame ; IRQ
END END

View File

@@ -4,13 +4,13 @@ entry .code: start
segment .code segment .code
start: start:
mov ax, .data ; put data segment into ax mov ax, .data
mov ds, ax ; there, I setup the DS for you mov ds, ax
mov dx, msg ; now I give you the offset in DX. DS:DX now completed. mov dx, msg
mov ah, 9h mov ah, 9h
int 21h int 21h
mov ah, 4ch mov ah, 4ch
int 21h int 21h
segment .data segment .data
msg db 'Hello World', '$' msg db 'Hello World', '$'

View File

@@ -1,4 +1,4 @@
010 ! Hello world in Assembler for the HP-85 010
020 NAM HELLO 020 NAM HELLO
030 DEF RUNTIM 030 DEF RUNTIM
040 DEF TOKENS 040 DEF TOKENS

View File

@@ -1,4 +1,3 @@
; hello_world.asm intel
.model small .model small
@@ -12,7 +11,7 @@ main proc
mov ax,@data mov ax,@data
mov ds, ax mov ds, ax
; hello-world is there
mov dx,offset msg mov dx,offset msg
mov ah,09 mov ah,09
int 21h int 21h

View File

@@ -1,4 +1,4 @@
; 16 bit dos assembly
.model small .model small
.stack .stack
.data .data

View File

@@ -19,17 +19,17 @@ bytesWritten DWORD ?
.code .code
main PROC main PROC
push -11 ; nStdHandle (STD_OUTPUT_HANDLE) push -11
call GetStdHandle@4 call GetStdHandle@4
push 0 ; lpReserved push 0
push OFFSET bytesWritten ; lpNumberOfCharsWritten push OFFSET bytesWritten
push LENGTHOF msg - 1 ; nNumberOfCharsToWrite push LENGTHOF msg - 1
push OFFSET msg ; *lpBuffer push OFFSET msg
push eax ; hConsoleOutput push eax
call WriteConsoleA@20 call WriteConsoleA@20
push 0 ; uExitCode push 0
call ExitProcess@4 call ExitProcess@4
main ENDP main ENDP
END main END main

View File

@@ -15,19 +15,19 @@ bytesWritten DWORD ?
.code .code
main PROC 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 call GetStdHandle
mov rcx, rax ; hConsoleOutput mov rcx, rax
lea rdx, msg ; *lpBuffer lea rdx, msg
mov r8, LENGTHOF msg - 1 ; nNumberOfCharsToWrite mov r8, LENGTHOF msg - 1
lea r9, bytesWritten ; lpNumberOfCharsWritten lea r9, bytesWritten
mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0 ; lpReserved mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0
call WriteConsoleA call WriteConsoleA
mov rcx, 0 ; uExitCode mov rcx, 0
call ExitProcess call ExitProcess
main ENDP main ENDP
END END

View File

@@ -2,8 +2,8 @@
hw: .asciiz "Hello World" hw: .asciiz "Hello World"
.text .text
main: main:
la $a0, hw #load the address of hw into $a0 la $a0, hw
li $v0, 4 #load 4 into $v0 li $v0, 4
syscall #perform the print_string syscall syscall
li $v0, 10 #load 10 into $v0 li $v0, 10
syscall #perform the exit syscall syscall

View File

@@ -1,31 +1,26 @@
section .text section .text
global _start ;must be declared for linker (ld) global _start
_syscall: _syscall:
int 0x80 ;system call int 0x80
ret ret
_start: ;tell linker entry point _start:
push dword len ;message length push dword len
push dword msg ;message to write push dword msg
push dword 1 ;file descriptor (stdout) push dword 1
mov eax,0x4 ;system call number (sys_write) mov eax,0x4
call _syscall ;call kernel 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 push dword 0
mov eax,0x1 ;system call number (sys_exit) mov eax,0x1
call _syscall ;call kernel call _syscall
;we do not return from sys_exit,
;there's no need to clean stack
section .data section .data
msg db "Hello World",0xa ;our string msg db "Hello World",0xa
len equ $ - msg ;length of our string len equ $ - msg

View File

@@ -1,20 +1,20 @@
section .text section .text
global _start ;must be declared for linker (ld) global _start
_start: ;tell linker entry point _start:
xor ebx,ebx ;ebx=0 xor ebx,ebx
mov ecx,msg ;address of message to write mov ecx,msg
lea edx,[ebx+len] ;message length lea edx,[ebx+len]
lea eax,[ebx+4] ;system call number (sys_write) lea eax,[ebx+4]
inc ebx ;file descriptor (stdout) inc ebx
int 0x80 ;call kernel int 0x80
xor eax, eax ;set eax=0 xor eax, eax
inc eax ;system call number (sys_exit) inc eax
int 0x80 ;call kernel int 0x80
section .rodata section .rodata
msg db 'Hello World',0xa ;our string msg db 'Hello World',0xa
len equ $ - msg ;length of our string len equ $ - msg

View File

@@ -1,17 +1,16 @@
section .rodata section .rodata
msg db "Hello World", 0xA ; String to print msg db "Hello World", 0xA
len equ $- msg ; Length of string len equ $- msg
section .text section .text
global _start ; Specify entry point to linker global _start
_start: _start:
mov eax, 1 ; System call ID (sys_write) mov eax, 1
mov edi, eax ; File descriptor (stdout) mov edi, eax
mov esi, msg ; Text to print mov esi, msg
mov edx, len ; Length of text to print mov edx, len
syscall ; Call kernel syscall
mov eax, 60 ; System call ID (sys_exit) mov eax, 60
xor edi, edi ; Error code (EXIT_SUCCESS) xor edi, edi
syscall ; Call kernel syscall

View File

@@ -2,13 +2,13 @@ global start
section .text section .text
start: start:
mov rax, 0x2000004 ; write mov rax, 0x2000004
mov rdi, 1 ; stdout mov rdi, 1
mov rsi, msg mov rsi, msg
mov rdx, msg.len mov rdx, msg.len
syscall syscall
mov rax, 0x2000001 ; exit mov rax, 0x2000001
mov rdi, 0 mov rdi, 0
syscall syscall

View File

@@ -1,4 +1,4 @@
; "Hello World" in Motorola 68000 machine language, for AmigaOS
ExecBase = 4 ExecBase = 4
OpenLibrary = -552 OpenLibrary = -552
@@ -7,7 +7,6 @@ PutStr = -948
section "main", code section "main", code
; open "dos.library"
move.l ExecBase, a6 move.l ExecBase, a6
lea lib, a1 lea lib, a1
@@ -15,12 +14,10 @@ PutStr = -948
jsr (OpenLibrary, a6) jsr (OpenLibrary, a6)
move.l d0, a6 move.l d0, a6
; print the message
move.l #msg, d1 move.l #msg, d1
jsr (PutStr, a6) jsr (PutStr, a6)
; close the library, and exit with code 0
move.l a6, a1 move.l a6, a1
move.l ExecBase, a6 move.l ExecBase, a6

View File

@@ -9,14 +9,12 @@
WRKSP EQU >8300 WRKSP EQU >8300
VDPWD EQU >8C00 * VDP RAM write data VDPWD EQU >8C00
VDPWA EQU >8C02 * VDP RAM read/write address VDPWA EQU >8C02
START LIMI 0 * disable interrupts START LIMI 0
LWPI WRKSP * set default workspace LWPI WRKSP
* set VDP RAM start address (low and high byte)
LI R0,>0000 LI R0,>0000
ORI R0,>4000 ORI R0,>4000
@@ -25,20 +23,21 @@ START LIMI 0 * disable interrupts
SWPB R0 SWPB R0
MOVB R0,@VDPWA MOVB R0,@VDPWA
LI R1,HELLOWORLD * ascii string address LI R1,HELLOWORLD
LI R2,12 * total chars LI R2,12
NEXTCHAR NEXTCHAR
MOVB *R1+,@VDPWD * put next char on screen MOVB *R1+,@VDPWD
DEC R2 DEC R2
JNE NEXTCHAR JNE NEXTCHAR
LOOPBACK LOOPBACK
JMP LOOPBACK * stop and do nothing JMP LOOPBACK
HELLOWORLD HELLOWORLD
TEXT 'HELLO WORLD' * string data TEXT 'HELLO WORLD'
BYTE 0 BYTE 0
END END

View File

@@ -154,9 +154,9 @@ Make sure to see [contributing.md](/contributing.md) for instructions on contrib
* [Assembler Z80 zxspectrum](a/Assembler%20Z80%20zxspectrum.asm) * [Assembler Z80 zxspectrum](a/Assembler%20Z80%20zxspectrum.asm)
* [ATS2](a/ATS2.dats) * [ATS2](a/ATS2.dats)
* [Attache](a/Attache.%40) * [Attache](a/Attache.%40)
* [AutoLISP](a/AutoLISP.lsp)
* [AutoHotKey](a/AutoHotKey.ahk) * [AutoHotKey](a/AutoHotKey.ahk)
* [AutoIt](a/AutoIt.au3) * [AutoIt](a/AutoIt.au3)
* [AutoLISP](a/AutoLISP.lsp)
* [Avisynth](a/Avisynth.avs) * [Avisynth](a/Avisynth.avs)
* [Awful](a/Awful.yuk) * [Awful](a/Awful.yuk)
* [AWK](a/AWK.awk) * [AWK](a/AWK.awk)
@@ -516,6 +516,7 @@ Make sure to see [contributing.md](/contributing.md) for instructions on contrib
* [Nu](n/Nu.nu) * [Nu](n/Nu.nu)
* [NWScript](n/NWScript.nss) * [NWScript](n/NWScript.nss)
* [NXC](n/NXC.nxc) * [NXC](n/NXC.nxc)
* [o:XML](o/o%3AXML)
* [Oberon 2](o/Oberon%202.obn) * [Oberon 2](o/Oberon%202.obn)
* [Oberon](o/Oberon.o) * [Oberon](o/Oberon.o)
* [Obix](o/Obix.osc) * [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) * [Oracle SQL](o/Oracle%20SQL.sql)
* [Orc](o/Orc.orc) * [Orc](o/Orc.orc)
* [OX](o/OX.oz) * [OX](o/OX.oz)
* [o:XML](o/o:XML)
* [Parenthetic](p/Parenthetic.p) * [Parenthetic](p/Parenthetic.p)
* [Parser](p/Parser.p) * [Parser](p/Parser.p)
* [Pascal](p/Pascal.p) * [Pascal](p/Pascal.p)