PDA

You are currently viewing a search engine-friendly (archive) version of this page.

View Full Version : A86 Assembly Language


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)

MikeFoster
April 1, 2001, 03:01 am
This is from a program I wrote that was an illustration of cellular automata. Here's the description from the source file:

; ca.8
; cellular automata

; This program causes each character on the screen to move in a certain
; direction with its forecolor changing to reflect its direction but the
; backcolor never changing. If a cell (also called a CA) is blocked from
; moving forward, it just changes its direction.
; The low nibble of the attribute is used to indicate a cell's direction.
; This low nibble controls the foreground color, so the background is never
; changed. The direction is random, in the range 0 - 0F, and corresponds
; as follows, with respect to the cell's position X. For example, the
; colors 6 and 0E both indicate movement directly down.

Later, I went back and added a really neat feature. On the program's command line you could specify which characters it was to animate. When the program runs, any on-screen characters you specified suddenly take on a life of their own, bouncing off other characters and moving around as if they were single celled creatures living on your screen - thus, cellular automata.

You can download the source (http://lineoflight.com/links/programming.html) - I just realized that I don't have the executable there so if you want it just let me know.

tschus!

------------------
Try these HelpFromTechs.com 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)