Skip to content

Instantly share code, notes, and snippets.

View djg's full-sized avatar
💭
I may be slow to respond.

Dan Glastonbury djg

💭
I may be slow to respond.
View GitHub Profile
@ECHO OFF
rem Recompile PS3 shaders from ps3.cg into shader.ps3 for all techniques.
SET CGC=c:\dev\cyclone\Main\Target\win32\runtime\sce-cgc.exe
SET CGNVTOCGB=c:\dev\cyclone\Main\Target\win32\runtime\cgnv2cgbLevelC.exe
SET CONCAT=c:\dev\cyclone\Main\Target\win32\runtime\CompilePS3Shaders_release
attrib -r shader.ps3
DEL /Q *.fp *.fpo *.vp *.vpo shader.ps3
IF EXIST ps3.techniques (
procedure putpixel(x,y:word;color:byte); assembler;
asm
mov es,sega000
db 66h; xor ax,ax
db 66h; xor bx,bx
mov ax,x
mov bx,y
mov cl,color
db 67h,66h,8dh,1ch,9bh ;{lea ebx,[ebx+ebx*4]}
db 66h; shl bx,6
@djg
djg / getchar.asm
Last active December 28, 2015 19:59
I was going for less bytes, hence the push/pop/push shenanigans. There must be an easier way to do this. Why does BSD require the syscall on the top of the stack *and* in EAX?
getchar: ; read a byte from stdin
push 0
mov eax, esp
push 1
push eax
push STDIN_FILENO
push SYS_READ
pop eax
push eax
int 80h
@djg
djg / gist:7556865
Created November 20, 2013 02:51
Current byte count == 24
# getchar: # read a byte from stdin
6a 00 # push 0
89 e0 # mov eax, esp
6a 01 # push 1
50 # push eax
6a 00 # push STDIN_FILENO
6a 03 # push SYS_READ
58 # pop eax
50 # push eax
cd 80 # int 80h
; ryg's version
getchar: ;read a byte from stdin
xor eax, eax
push eax
mov ecx, esp
push eax
push ecx
push eax
push eax
mov al, SYS_READ
@djg
djg / gist:7556935
Created November 20, 2013 02:58
ryg's version: byte count == 22
# ryg's version
# getchar:
31 C0 # xor eax, eax
50 # push eax
89 E1 # mov ecx, esp
50 # push eax
51 # push ecx
50 # push eax
50 # push eax
B0 03 # mov al, 3
@djg
djg / gist:7611808
Created November 23, 2013 07:13
Forthy stack operations.
drop:
pop %ebx
pop %eax
jmp *%ebx
swap:
pop %ebx
pop %eax
pop %ecx
push %eax
@djg
djg / crap1.crap
Created November 24, 2013 23:31
crap1.crap - crap0.asm written in crap
#
# CRAP1 for Darwin-i386-MachO
# Copyright (C) 2013, Dan Glastonbury <dan.glastonbury@gmail.com>
#
# Based on:
# HEX1 for Linux-i386-ELF
# Copyright (C) 2001, Edmund GRIMLEY EVANS <edmundo@rano.org>
#
# _mach_header: # struct mach_header
@djg
djg / crap2b.crap
Created November 24, 2013 23:34
crap2b.crap - crap2a.crap utilizing labels
#
# CRAP2b for Darwin-i386-MachO
# Copyright (C) 2013, Dan Glastonbury <dan.glastonbury@gmail.com>
#
# Uses BSS section for data storage and labels for call & jmp targets
#
# Based on:
# HEX2b and HEX2c for Linux-i386-ELF
# Copyright (C) 2001, Edmund GRIMLEY EVANS <edmundo@rano.org>
#
@djg
djg / crap3b.crap
Created November 24, 2013 23:37
crap3b.crap - Supports 4 character labels! (crap3 dialect)
#
# CRAP3b for Darwin-i386-MachO
# Copyright (C) 2013, Dan Glastonbury <dan.glastonbury@gmail.com>
#
# Labels are 4 chars. Labels are stores in a symbol table stored in
# BSS section. The labels form a list of 32-bit label name and address
# pairs.
#
# Errors are signaled by return code:
# 1: Syntax Error