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

2 comments:

  1. This example lacks of comments. It's quite hard to tell what happens in this code if you are a mere beginner in ASM looking for some examples or tips.

    ReplyDelete
    Replies
    1. Hi Aleksander! I apologize that this blog is no longer updated since I changed career. Thanks!

      Delete