A couple of years ago I develped a few assembler programs.
A screen shot from one of the assembler programsYou can download my asm programs with source here.
Note: The file is compressed with WinRar.
A small assembler program
The following code demonstrates how a to make a small program in assembler.
The program displays some scrolling graphics (palette rotating).
The size of executable file is just 620 bytes!
;---------------------------------------------------------------------
; cw is made by NJLO/The Candidate - 1995
; optimized version
;---------------------------------------------------------------------
TITLE cw
.MODEL TINY
.CODE
JUMPS
ORG 100H
;---------------------------------------------------------------------
BEGYND: JMP INIT
;---------------------------------------------------------------------
; this text is displayed when the program terminates
end_txt db 'Coded by The Candidate',13,10,10
db ' -=BBS CYBERWORLD=-',13,10
db ' SysOp Jimmy',13,10
db ' CoSysOp The Death',13,10
db ' CoSysOp Zealot',13,10
db ' CALL DK-56219202',13,10,10,'$'
; blue color from pallette (15x15=225, notice not all 256 colors)
bluepal db 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
db 16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16
db 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,42,42,16,42,42,
db 16,42,42,42,42,16,16,16,16,16,42,42,42,42,42,16,42,16,16,42,42,16,16
db 16,16,42,16,42,16,42,16,16,16,16,16,42,16,16,16,16,42,16,42,16,42,16
db 16,16,16,16,42,16,16, 16,16,42,16,16,16,42,16,16,16,16,16,42,16,16,16
db 16,42,16,16,16,42,16,42,16,16,42,42,16,16, 16,16,42,16,16,16,42,16,42
db 42,42,42,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16
db 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16
db 16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16
;--------------------------------------------------------------------------
; input: [screenseg:bx] = screen position, ah = start color
is_line macro
mov dh,21
is_l1: dec dh
mov cx,15 ; loop 15 colors out
is_l2: mov [bx],ah
dec ah
inc bx
loop is_l2
add ah,15
cmp dh,0
jne is_l1
mov [bx],ah ; last five pixels of line
inc bx
dec ah
mov [bx],ah
inc bx
dec ah
mov [bx],ah
inc bx
dec ah
mov [bx],ah
inc bx
dec ah
mov [bx],ah
inc bx
sub ah,11
endm
;---------------------------------------------------------------------
move_bckgrnd_pal macro
mov bx,OFFSET bluepal ; bx -> bluepal
xor cl,cl
ms_1: mov al,15
mul cl
add bx,ax
mov dh,[bx+14]
mov ah,[bx+13]
mov [bx+14],ah
mov ah,[bx+12]
mov [bx+13],ah
mov ah,[bx+11]
mov [bx+12],ah
mov ah,[bx+10]
mov [bx+11],ah
mov ah,[bx+9]
mov [bx+10],ah
mov ah,[bx+8]
mov [bx+9],ah
mov ah,[bx+7]
mov [bx+8],ah
mov ah,[bx+6]
mov [bx+7],ah
mov ah,[bx+5]
mov [bx+6],ah
mov ah,[bx+4]
mov [bx+5],ah
mov ah,[bx+3]
mov [bx+4],ah
mov ah,[bx+2]
mov [bx+3],ah
mov ah,[bx+1]
mov [bx+2],ah
mov ah,[bx]
mov [bx+1],ah
mov [bx],dh
inc di
inc cl ; increment counter (i)
xor ah,ah
sub bx,ax
cmp cl,15
jne ms_1
endm
;---------------------------------------------------------------------
;---------------------------------------------------------------------
;---------------------------------------------------------------------
INIT: mov ax,13h ; ah=0 and al=13h = 320x200, 256 colors
INT 10h
;---------------------------------------------------------------------
; Initialize screen (boxes 15x15)
xor bx,bx ; zero position
mov ah,225 ; start color
mov cx,0a000h
push ds
mov ds,cx
mov dl,15
is_1: is_line ; draw one line
dec dl
cmp dl,0
jne is_1
mov cx,29600 ; rest 185 lines
mov bx,4800 ; first 15 lines
xor si,si ; ScrSeg:si -> first screen pixel
is_2: mov ax,[si]
mov [bx],ax
inc si
inc si
inc bx
inc bx
loop is_2
pop ds
;---------------------------------------------------------------------
main1: move_bckgrnd_pal
; set background palette
mov si,OFFSET bluepal ; si -> blue palette (225 colors)
MOV DX,3dah ; WAIT FOR VERTICAL BLANKING
WV_1: IN AL,DX
TEST AL,8
JZ WV_1
mov cx,226
mov dx,03c8h
xor al,al
out dx,al
inc dx
pal1: out dx,al
xor al,al
out dx,al
mov al,28
out dx,al
lodsb
loop pal1
mov ah,1 ; check if key is pressed
int 16h
jz main1 ; if key not pressed jump to main1
;---------------------------------------------------------------------
MOV AH,7h ; remove key
INT 21h
MOV AX,3 ; text mode
INT 10h
MOV DX,OFFSET end_txt
MOV AH,9h ; write string ( dx -> string)
INT 21h
MOV AH,4ch ; exit to dos
INT 21h
END BEGYND
;---------------------------------------------------------------------
Related topics
Opcodes for the 80386The different ASM instructions explained Asm programming at GameDev.netGreat site - make sure to read the Assembly TutorialThe Simtel.Net MS-DOS Collection