MikeFoster
April 1, 2001, 01:51 am
Here's something you can really crash your machine with. Does anyone remember A86/D86? Man, I loved that! Here's a little diddy I wrote with A86. Can you tell me what it does?
; get_vid_ptr
; pre: dx is coord
; post: es is vid_seg and bx is offset into page 0
;
get_vid_ptr:
push ax,dx
mov al,80
mul dh
xor dh,dh
add ax,dx
shl ax,1
mov bx,ax
mov es,ax,vid_seg
pop dx,ax
ret
; get_cell
; pre: dx is coord
; post: ax is cell from page 0
;
get_cell:
push bx,es
call get_vid_ptr
es mov ax,w
pop es,bx
ret
; get_char_1
; pre: dx is coord
; post: al is char from page 1
;
get_char_1:
push bx,es
call get_vid_ptr
add bx,4000
es mov al,b[bx]
pop es,bx
ret
; put_cell
; pre: dx is coord, ax is cell
; post: cell is put to page 1
;
put_cell:
call put_char
call put_attr
ret
; put_char
; pre: dx is coord, al is char
; post: char is put to page 1
;
put_char:
push bx,es
call get_vid_ptr
add bx,4000
es mov b[bx],al
pop es,bx
ret
; put_attr
; pre: dx is coord, ah is attr
; post: attr is put to page 1
;
put_attr:
push bx,es
call get_vid_ptr
add bx,4001
es mov b[bx],ah
pop es,bx
ret
; move_page
; pre: ch is destination page, cl is source page
; post: 4000 bytes are copied from page cl to page ch
;
move_page:
push ax,cx,dx,si,di
push cx
mov ax,4000
xor ch,ch
mul cx
mov si,ax
mov ax,4000
pop cx
mov cl,ch
xor ch,ch
mul cx
mov di,ax
mov es,ax,vid_seg
push ds,ax
pop ds
mov cx,2000
cld
rep movsw
pop ds,di,si,dx,cx,ax
ret
------------------
Try these HelpFromTechs.com [b]Web Development Resources:
Reference Links (http://www.helpfromtechs.com/ubb/Forum8/HTML/000054.html)*|*User Authentication (http://www.helpfromtechs.com/ubb/Forum8/HTML/000071.html)*|*HTML Editors (http://www.helpfromtechs.com/ubb/Forum8/HTML/000030.html)*|*Perl/CGI (http://www.helpfromtechs.com/ubb/Forum8/HTML/000016.html)*|*Embedding Music (http://www.helpfromtechs.com/ubb/Forum8/HTML/000067.html)
; get_vid_ptr
; pre: dx is coord
; post: es is vid_seg and bx is offset into page 0
;
get_vid_ptr:
push ax,dx
mov al,80
mul dh
xor dh,dh
add ax,dx
shl ax,1
mov bx,ax
mov es,ax,vid_seg
pop dx,ax
ret
; get_cell
; pre: dx is coord
; post: ax is cell from page 0
;
get_cell:
push bx,es
call get_vid_ptr
es mov ax,w
pop es,bx
ret
; get_char_1
; pre: dx is coord
; post: al is char from page 1
;
get_char_1:
push bx,es
call get_vid_ptr
add bx,4000
es mov al,b[bx]
pop es,bx
ret
; put_cell
; pre: dx is coord, ax is cell
; post: cell is put to page 1
;
put_cell:
call put_char
call put_attr
ret
; put_char
; pre: dx is coord, al is char
; post: char is put to page 1
;
put_char:
push bx,es
call get_vid_ptr
add bx,4000
es mov b[bx],al
pop es,bx
ret
; put_attr
; pre: dx is coord, ah is attr
; post: attr is put to page 1
;
put_attr:
push bx,es
call get_vid_ptr
add bx,4001
es mov b[bx],ah
pop es,bx
ret
; move_page
; pre: ch is destination page, cl is source page
; post: 4000 bytes are copied from page cl to page ch
;
move_page:
push ax,cx,dx,si,di
push cx
mov ax,4000
xor ch,ch
mul cx
mov si,ax
mov ax,4000
pop cx
mov cl,ch
xor ch,ch
mul cx
mov di,ax
mov es,ax,vid_seg
push ds,ax
pop ds
mov cx,2000
cld
rep movsw
pop ds,di,si,dx,cx,ax
ret
------------------
Try these HelpFromTechs.com [b]Web Development Resources:
Reference Links (http://www.helpfromtechs.com/ubb/Forum8/HTML/000054.html)*|*User Authentication (http://www.helpfromtechs.com/ubb/Forum8/HTML/000071.html)*|*HTML Editors (http://www.helpfromtechs.com/ubb/Forum8/HTML/000030.html)*|*Perl/CGI (http://www.helpfromtechs.com/ubb/Forum8/HTML/000016.html)*|*Embedding Music (http://www.helpfromtechs.com/ubb/Forum8/HTML/000067.html)