;THANKS TO MY PROFESSOR FOR THE PROBLEM
.model tiny
.code
org 100h
begin: jmp start
msg1 db "REVERSE",0ah,"$"
msg2 db 8 dup(20h),"$";8 is the number of characters including the space
start proc
lea si,msg1[7];7 is the number of characters
lea di,msg2[0]
mov cx,8;8 is the number of characters including the space
prog: mov al,[si]
mov [di],al
dec si
inc di
dec cx
jnz prog
mov ah,09h
lea dx,msg1
int 21h
mov ah,09h
lea dx,msg2
int 21h
mov ah,07h
int 21h
mov ax,4c00h
int 21h
start endp
end begin
Assembly Language
Editor: Programmer's File Editor
Assembler: Turbo Assembler (TASM)
Linker: Turbo Link (TLINK)
Saturday, September 18, 2010
Wednesday, August 25, 2010
ASCII characters
;This program displays all ascii characters
;from IBM PC by Peter Abel (5th edition)
.model small
.stack 64
.data
char_ctr db 00
col db 24
row db 04
mode db ?
.286
.code
a10main proc near
mov ax,@data
mov ds,ax
mov es,ax
call b10mode
call c10clear
a20:
call d10cursor
call e10disply
cmp char_ctr,0ffh
je a30
inc char_ctr
add col,02
cmp col,56
jne a20
inc row
mov col,24
jmp a20
a30:
mov ah,10h
int 16h
mov ah,00h
mov al,mode
int 10h
mov ax,4c00h
int 21h
a10main endp
b10mode proc near
mov ah,0fh
int 10h
mov mode,al
mov ah,00h
mov al,03
int 10h
ret
b10mode endp
c10clear proc near
pusha
mov ah,08h
int 10h
mov bh,ah
mov ax,0600h
mov cx,0000
mov dx,184fh
int 10h
mov ax,0610h
mov bh,5Dh
mov cx,0418h
mov dx,1336h
int 10h
popa
ret
c10clear endp
d10cursor proc near
pusha
mov ah,02h
mov bh,00
mov dh,row
mov dl,col
int 10h
popa
ret
d10cursor endp
e10disply proc near
pusha
mov ah,0ah
mov al,char_ctr
mov bh,00
mov cx,01
int 10h
popa
ret
e10disply endp
end a10main
;from IBM PC by Peter Abel (5th edition)
.model small
.stack 64
.data
char_ctr db 00
col db 24
row db 04
mode db ?
.286
.code
a10main proc near
mov ax,@data
mov ds,ax
mov es,ax
call b10mode
call c10clear
a20:
call d10cursor
call e10disply
cmp char_ctr,0ffh
je a30
inc char_ctr
add col,02
cmp col,56
jne a20
inc row
mov col,24
jmp a20
a30:
mov ah,10h
int 16h
mov ah,00h
mov al,mode
int 10h
mov ax,4c00h
int 21h
a10main endp
b10mode proc near
mov ah,0fh
int 10h
mov mode,al
mov ah,00h
mov al,03
int 10h
ret
b10mode endp
c10clear proc near
pusha
mov ah,08h
int 10h
mov bh,ah
mov ax,0600h
mov cx,0000
mov dx,184fh
int 10h
mov ax,0610h
mov bh,5Dh
mov cx,0418h
mov dx,1336h
int 10h
popa
ret
c10clear endp
d10cursor proc near
pusha
mov ah,02h
mov bh,00
mov dh,row
mov dl,col
int 10h
popa
ret
d10cursor endp
e10disply proc near
pusha
mov ah,0ah
mov al,char_ctr
mov bh,00
mov cx,01
int 10h
popa
ret
e10disply endp
end a10main
Thursday, August 19, 2010
Reverse Keyboard
Example if capslock is on, A will be a.. and if off a will be A
.model small
.stack 50
.data
msg db "Enter a character: $"
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09
mov dx,offset msg
int 21h
start: mov ah,07
int 21h
cmp al,0dh
je exit
cmp al,41h
je smol
cmp al,41h
ja sa
cmp al,41h
jb start
cmp al,5ah
je smol
cmp al,5ah
jb smol
cmp al,61h
je cap
cmp al,61h
ja cap
cmp al,7ah
je cap
cmp al,7ah
ja start
cmp al,7ah
jb ca
sa: cmp al,5ah
je smol
cmp al,5ah
jb smol
ca: cmp al,61h
je cap
cmp al,61h
ja cap
cmp al,61h
jb start
cap: sub al,20h
jmp disp
smol: add al,20h
jmp disp
disp: mov ah,02
mov dl,al
int 21h
jmp start
exit: mov ax,4c00h
int 21h
main endp
end main
.model small
.stack 50
.data
msg db "Enter a character: $"
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09
mov dx,offset msg
int 21h
start: mov ah,07
int 21h
cmp al,0dh
je exit
cmp al,41h
je smol
cmp al,41h
ja sa
cmp al,41h
jb start
cmp al,5ah
je smol
cmp al,5ah
jb smol
cmp al,61h
je cap
cmp al,61h
ja cap
cmp al,7ah
je cap
cmp al,7ah
ja start
cmp al,7ah
jb ca
sa: cmp al,5ah
je smol
cmp al,5ah
jb smol
ca: cmp al,61h
je cap
cmp al,61h
ja cap
cmp al,61h
jb start
cap: sub al,20h
jmp disp
smol: add al,20h
jmp disp
disp: mov ah,02
mov dl,al
int 21h
jmp start
exit: mov ax,4c00h
int 21h
main endp
end main
Tuesday, August 17, 2010
Numbers only
;This program accepts only numbers. Press enter to quit.
stak segment para stack 'stack'
db 100 dup (0)
stak ends
dta segment
msg1 db "Enter a number: $"
dta ends
kod segment
main proc
assume ss:stak, ds:dta, cs:kod
mov ax,dta
mov ds,ax
mov ah,09
mov dx,offset msg1
int 21h
start: mov ah,07
int 21h
cmp al,0dh
je exit
cmp al,30h
jb start
cmp al,39h
ja start
disp: mov ah,02
mov dl,al
int 21h
jmp start
exit: mov ax,4c00h
int 21h
main endp
kod ends
end main
stak segment para stack 'stack'
db 100 dup (0)
stak ends
dta segment
msg1 db "Enter a number: $"
dta ends
kod segment
main proc
assume ss:stak, ds:dta, cs:kod
mov ax,dta
mov ds,ax
mov ah,09
mov dx,offset msg1
int 21h
start: mov ah,07
int 21h
cmp al,0dh
je exit
cmp al,30h
jb start
cmp al,39h
ja start
disp: mov ah,02
mov dl,al
int 21h
jmp start
exit: mov ax,4c00h
int 21h
main endp
kod ends
end main
Hello World! (Prints a string)
;prints a string
stak segment para stack 'stack'
db 50 dup(0)
stak ends
dta segment
msg db"Hello World!$"
dta ends
kod segment
prok proc
assume ss:stak, ds:dta, cs:kod
mov ax,dta
mov ds,ax
mov ah,09
mov dx, offset msg
int 21h
mov ah,07
int 21h
mov ax,4c00h
int 21h
prok endp
kod ends
end prok
stak segment para stack 'stack'
db 50 dup(0)
stak ends
dta segment
msg db"Hello World!$"
dta ends
kod segment
prok proc
assume ss:stak, ds:dta, cs:kod
mov ax,dta
mov ds,ax
mov ah,09
mov dx, offset msg
int 21h
mov ah,07
int 21h
mov ax,4c00h
int 21h
prok endp
kod ends
end prok
Subscribe to:
Posts (Atom)