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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
; 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:

View File

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

View File

@ -6,28 +6,27 @@
;***************************************************************************
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:
; recalibrate CRT, reset beam to 0,0 (center of the screen)
jsr $f192 ; Wait_Recal subroutine in ROM
jsr $f192
ldu #helloworld ; string address
lda #10 ; Y
ldb #-45 ; X
ldu #helloworld
lda #10
ldb #-45
jsr $f37a ; Print_Str_d subroutine in ROM
jsr $f37a
bra loop
; Text data ($80 - end of line)
helloworld: db 'Hello World',$80

View File

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

View File

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

View File

@ -1,6 +1,4 @@
;
; hello.asm
;
; A "Hello, World!" which illustrates an Atari 2600 programming
; introduction talk (slides at http://slideshare.net/chesterbr).
;
@ -13,69 +11,68 @@
PROCESSOR 6502
INCLUDE "vcs.h"
ORG $F000 ; Start of "cart area" (see Atari memory map)
ORG $F000
StartFrame:
lda #%00000010 ; Vertical sync is signaled by VSYNC's bit 1...
lda #%00000010
sta VSYNC
REPEAT 3 ; ...and lasts 3 scanlines
sta WSYNC ; (WSYNC write => 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

View File

@ -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', '$'
msg db 'Hello World', '$'

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

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)
* [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)