+1 678 648 4277 

NOTE-The following Assembly Language Program has been prepared by our Assembly Language Programmers , just for demonstrating you the quality and comprehensiveness of our Assembly Language Homework Solutions and they do not constitute to any of our previous Assembly Language Assignment/Homework solution deliveries.

Sample Assembly Language Assignment

First, we write a set of 80x86 assembly language routines and a main program that can be installed as a TSR (Terminate and Stay Resident) program and that defines an user-defined ISR so it can be called by otherprograms. This user-defined interrupt service should contain the following functions:

1) INT 63H

a) Function 01H ==> clear screen

b) You may add other functions

2) INT 64H

a) Function 03H ==> draw a rectangle

b) Call registers:

i) AH: 03H

ii) AL: color code

iii) CX: X coordinate of the starting point

iv) DX: Y coordinate of the starting point

v) SI: X coordinate of the ending point

vi) DI: Y coordinate of the ending point

3) INT 65H ==> restore the original interrupt vector.

4) The interrupt service routine you write should become part of the Disk Operating

System (DOS). In other words, it has to reside in the memory and become a

Terminate and Stay Resident (TSR) program. INT 27H is recommended for this purpose.

a) Calling registers:

i) DX Offset of last byte plus 1 of the program to remain resident

ii) CS Segment of Program Segment Prefix

b) Search “INT 27” or “Terminate and Stay Resident” on the internet for more info.

When a user-defined interrupt service (or any ISR) is called, the DS (data segment) is

unchanged at the entry point of the ISR. Therefore, it will point to the original data

segment of the calling function. As a result, the DS must be manually initialized before

access to any data inside the ISR can be made. Also, remember that an ISR is supposed to

save (“PUSH”) all registers that it will modify during the course of its execution. These

registers must be restored at exit. For the second part of the lab, extend your original ISR

to perform the following services:

1) Clear screen.

2) Display the game field and the score on the top right corner of the screen.

3) Start the game by shooting multiple projectiles from a random location on the edge of

the screen.

4) The space ship, in the middle of the screen, aims, controlled by mouse location, can

shoot the projectiles to destroy them using a mouse click to fire bullets in that

direction.

5) Each projectile that is destroyed is worth a certain number of points.

6) If the player is hit by a projectile, the space ship loses one of 3 life points.

7) Game would stop when you get hit 3 times.

 

;Bios.Mac - Macros for BIOS functions

GetTime MACRO
mov ah,00H
int 1AH
;i) AL: Midnight flag, 1 if 24 hours passed since reset
;ii) CX: high order word of tick count
;iii) DX: low order word of tick count
ENDM

GetKey MACRO
mov ah,00H
int 16h
;AH = BIOS Scan Code
;AL = Ascii character
ENDM

MoveCursor MACRO row,column
mov dh,row
mov dl,column
mov bh,0 ;page
mov ah,2
int 10h
ENDM

 ;dos.mac - Macros for DOS functions

MovAX MACRO src
ifdif <ax>,<src>
mov ax,src
endif
ENDM

MovBX MACRO src
ifdif <bx>,<src>
mov bx,src
endif
ENDM

MovCX MACRO src
ifdif <cx>,<src>
mov cx,src
endif
ENDM

MovDX MACRO src
ifdif <dx>,<src>
mov dx,src
endif
ENDM

MovDS MACRO src
ifdif <ds>,<src>
push ax
mov ax,src
mov ds,ax
pop ax
endif
ENDM

MovDI MACRO src
ifdif <di>,<src>
mov di,src
endif
ENDM

MovSI MACRO src
ifdif <si>,<src>
mov si,src
endif
ENDM

StringIn MACRO in
mov ah,0AH
mov dx,offset in
int 21H
ENDM

PrintC MACRO char
mov dl,offset char
mov ah,02H
int 21h
ENDM

PrintS MACRO string
mov dx,offset string
mov ah,09h
int 21h
ENDM

PushAll MACRO ;Save all the registers
push ax
push bx
push cx
push dx
push di
push si
push bp
push ds
ENDM

PopAll MACRO ;Restore all the registers
pop ds
pop bp
pop si
pop di
pop dx
pop cx
pop bx
pop ax
ENDM

Return MACRO
mov ah,4CH
int 21H
ENDM

Create MACRO handle,filename
mov cx, 0
mov ah, 3ch
mov dx, offset filename
int 21h
mov handle,ax
call CheckError ;if carry set, there was an error
ENDM

Open MACRO handle,filename
mov al, 0
mov ah, 3dh
mov dx, offset filename
int 21h
mov handle,ax
ENDM

Len MACRO buff
mov cx,2 ;take into account header
mov bx, offset buff+2
call calclen
mov bx, offset buff
mov [bx],cl
ENDM

ReadFile MACRO handle,buff,size
mov ah, 3fh
mov bx, handle
mov cx, size
mov dx, offset buff
int 21h
call CheckError ;if carry set, there was an error
ENDM

WriteFile MACRO handle,buff,size
mov ah, 40h
mov bx, handle
mov dx, offset buff
mov cx, size
int 21h
call CheckError ;if carry set, there was an error
ENDM

Close MACRO handle
mov bx, handle
mov ah, 3eh
int 21h
call CheckError ;if carry set, there was an error
ENDM

InChar MACRO
mov ah,1H
int 21H
ENDM

InitMouse MACRO
mov ax,0
int 33h
;AX = FFFFh if successful
;BX = number of buttons
;AX = 0 Unable to init
ENDM

ShowMouse MACRO
mov ax,1
int 33h
ENDM

;GetMouse returns ZF if no mouse button
GetMouse MACRO x,y
mov ax,3
int 33h
;BX = 1 = left, 2 = right, 3 = both
;CX = x
;DX = y
push cx
mov ax, cx
mov cl,3
shr ax,cl
mov x, ax
mov ax, dx
mov cl,3
shr ax,cl
mov y, ax
pop cx
and bx, 1
ENDM

GetIRQ MACRO irq,saveSeg,saveOff
mov ah,35h
mov al,irq
int 21h
mov saveSeg,es
mov saveOff,bx
ENDM

SetIRQ MACRO irqNum,irqAddress
mov ax,cs
mov ds,ax
mov ah,25h
mov al,irqNum
mov dx,offset irqAddress
int 21h
ENDM

PutIRQ MACRO irq,saveSeg,saveOff
mov ah,25h
mov al,irq
mov ds,saveSeg
mov dx,saveOff
int 21h
ENDM

TSR MACRO function
mov ax,cs
mov ds,ax
mov dx,offset function
int 27h
ENDM


MyCls MACRO
mov ah,01h
int 63h
ENDM

MyPlayfield MACRO
mov ah,02h
int 63h
ENDM

MyWait MACRO
mov ah,03h
int 63h
ENDM

MyPlayGame MACRO
mov ah,04h
int 63h
ENDM

MyRect MACRO xStart,yStart,xEnd,yEnd,color
mov ah,03h
mov al,color
mov cx,xStart
mov dx,yStart
mov si,xEnd
mov di,yEnd
int 64h
ENDM

DrawSquare MACRO xStart,yStart,boxSize,color
PushAll
mov ah,03h
mov al,color
MovCx xStart
MovDx yStart
; mov cx,xStart
; mov dx,yStart
mov si,cx
add si,boxSize
mov di,dx
add di,boxSize
int 64h
PopAll
ENDM

MyRestoreIRQ MACRO
int 65h
ENDM

 

;FILENAME: tsr.asm
;FILE FORMAT: EXE
include dos.mac
include bios.mac

code SEGMENT
ASSUME cs:code, ds:code, ss:stack_seg
ORG 100h
begin:
jmp initialize
; needed memory data here
old_int63_seg dw 0
old_int63_off dw 0
old_int64_seg dw 0
old_int64_off dw 0
old_int65_seg dw 0
old_int65_off dw 0

; begin resident program here
; AH = 01H Clear the screen
int63 PROC FAR
cmp ah,01h
je _cls
iret
_cls:
PushAll
mov ax,0b800h
mov ds,ax
mov bx,80*100 ;80 columns 25 rows
_clsLoop:
mov word ptr [bx],720h ;space in gray with black background
sub bx,2
jnc _clsLoop
MoveCursor 0,0
PopAll
iret
int63 ENDP

;Get screen address
;ax = y
;bx = x
;Return
;bx = screen offset
GetAddr PROC
push cx
mov cl,160
mul cl
add bx,bx
add bx,ax
pop cx
ret
ENDP

; AH = 03H Draw a rectangle
; AL = Color Code
; CX = X start
; DX = Y start
; SI = X end
; DI = Y end
int64 PROC FAR
cmp ah,03h
je _rect
iret
_rect:
PushAll
push ax
mov ax,0b800h ;set ds to the screen
mov ds,ax
mov ax,dx
cmp ax,0
jge _rectY
mov ax,0
mov dx,0
_rectY:
mov bx,cx
cmp bx,0
jge _rectX
mov bx,0
mov cx,0
_rectX:
cmp si,80
jl _rectX2
mov si,79
_rectX2:
cmp di,50
jl _rectY2
mov di,49
_rectY2:
call GetAddr
pop ax ;so we can get the color back
mov ah,al
push cx ;save initial left x
mov al,0cdh ;the horizontal character
_topLine:
cmp cx,si
je _topLine2
add bx,2
mov [bx],ax
inc cx
jmp _topLine
_topLine2:
mov al,0bbh ;Top right character
mov [bx],ax
mov cx,dx
mov al,0bah ;the vertical character
_rightLine:
cmp cx,di
je _rightLine2
add bx,160
mov [bx],ax
inc cx
jmp _rightLine
_rightLine2:
mov al,0bch ;Bottom right left character
mov [bx],ax
pop cx
mov al,0cdh ;the horizontal character
_bottomLine:
cmp cx,si
je _bottomLine2
sub bx,2
mov [bx],ax
inc cx
jmp _bottomLine
_bottomLine2:
mov al,0c8h ;Bottom left character
mov [bx],ax
mov cx,dx
mov al,0bah ;the vertical character
_leftLine:
cmp cx,di
je _leftLine2
sub bx,160
mov [bx],ax
inc cx
jmp _leftLine
_leftLine2:
mov al,0c9h ;Top left character
mov [bx],ax
; pop cx
; mov al,0cdh ;the horizontal character

; pop bx
PopAll
iret
int64 ENDP

;Restore original IRQ
int65 PROC FAR
PushAll
PutIrq 63h,old_int63_seg,old_int63_off
PutIrq 64h,old_int64_seg,old_int64_off
PutIrq 65h,old_int65_seg,old_int65_off
PopAll
iret
int65 ENDP
; end resident program here
code ENDS

stack_seg SEGMENT stack
db 100 dup(?)
stack_seg ENDS

code SEGMENT

initialize:
ASSUME cs:code, ds:code, ss:stack_seg
mov ax,cs
mov ds,ax
GetIrq 63h,old_int63_seg,old_int63_off
GetIrq 64h,old_int64_seg,old_int64_off
GetIrq 65h,old_int65_seg,old_int65_off
SetIrq 63h,int63
SetIrq 64h,int64
SetIrq 65h,int65
; MyCls
; MyRect 10,10,20,20,0fh ;draw rectangle from (10,10)-(20,20)
; MyRestoreIRQ
TSR initialize
return
code ENDS

END begin

;FILENAME: tsr.asm
;FILE FORMAT: EXE
include dos.mac
include bios.mac

code SEGMENT
ASSUME cs:code, ds:code, ss:stack_seg
ORG 100h
BLACK = 0
BLUE = 1
GREEN = 2
CYAN = 3
RED = 4
PURPLE = 5
BROWN = 6
WHITE = 7
BRIGHT = 8
YELLOW = BRIGHT + BROWN

begin:
jmp initialize
; needed memory data here
old_int63_seg dw 0
old_int63_off dw 0
old_int64_seg dw 0
old_int64_off dw 0
old_int65_seg dw 0
old_int65_off dw 0
score dw 0f053h,0f063h,0f06fh,0f072h,0f065h,0f03ah,20h ;Score:<Space> in reverse
points dw 0f030h,0f030h,0f030h,0f030h,0f030h,0f030h,20h ;000000 in reverse
dw 0f04ch,0f069h,0f076h,0f065h,0f073h,0f03ah,20h ;Lives:<Space>
lives dw 0f033h
seed dw 0ABBAh
bulletsXY:
dw 32 dup (0)
; dw 15000,4000,-5,-5
; dw 17000,3000,-5,-5
; dw 2000,500,5,5
; dw 5000,300,5,5
; dw 9000,590,-5,5
; dw 6000,2300,5,-5
; dw 10000,3000,-5,0
; dw 2000,4500,0,-30
projectilesBigXY:
dw 32 dup (0)
; dw 19000,3500,-5,0
; dw 8000,300,0,5
; dw 16000,3500,-5,-5
; dw 9000,300,-5,5
; dw 3500,1200,-5,0
; dw 9000,2000,-5,0
; dw 1000,4000,0,-5
; dw 400,400,30,15
projectilesSmallXY:
dw 32 dup (0)
; dw 500,4000,0,-5
; dw 2000,1000,5,5
; dw 3500,300,-5,5
; dw 3500,300,-5,0
; dw 1200,2000,0,5
; dw 2000,3000,0,-5
; dw 900,900,5,0
; dw 10000,2500,-30,0
starsXY db 128 dup (?) ;64 * x,y
playerX dw 38
playerY dw 11
bulletXStart dw 41*256
bulletYStart dw 13*256
time dw 500
fireX dw 0
fireY dw 0
bulletMouseX dw 41*8
bulletMouseY dw 13*8
bulletHit db 0

resetLevel PROC
mov bx,offset bulletsXY
mov cx,64
mov ax,0
.resetLoop:
mov [bx],ax
add bx,2
loop .resetLoop
ret
ENDP

;Random number from http://www.daniweb.com/software-development/assembly/threads/292225/random-number-generating-in-assembly
;returns random number in dx
random PROC
; Lehmer linear congruential random number generator
; z= (a*z+b) mod m = (31*z+13)%19683
; Rules for a, b, m by D. Knuth:
; 1. b and m must be relatively prime
; 2. a-1 must be divisible without remainder by all prime factors of m (19683 = 3^9), (31-1)%3=0
; 3. if m is divisible by 4, a-1 must also be divisible by 4, 19683%4 != 0, ok
; 4. if conditions 1 to 3 met, period of {z1, z2, z3,...} is m-1 = 19682 (Donald says)
push ax ; save used registers
push bx
mov dx, seed ; 43962D is initial Value z for random sequence
mov ax, dx ; set new initial value z
mov bx, 001Fh ; 31D
mul bx ; 31 * z
; result dx:ax, higher value in dx, lower value in ax
add ax, 000Dh ; +13
mov bx, 04CE3h ; 19683D
div bx ; div by 19683D
; result ax:dx, quotient in ax, remainder in dx (this is the rnz)
mov seed,dx ; processing random numbers here, first 10 RNZ (appearing in dx) are:
; 4708 8180 17397 7879 8066 13863 16423 17051 16836 10171
pop bx
pop ax
ret
ENDP

;Add AX points to the score (1-9)
addScore PROC
mov bx,offset points+10
mov cx,6
_scoreLoop:
mov dx,[bx]
add dx,ax
mov ax,0
cmp dl,':' ;: is '9'+1
jc _noInc
sub dl,10
mov al,1 ;so it will increment next digit
_noInc:
mov [bx],dx
sub bx,2
loop _scoreLoop
ret
ENDP

drawStars PROC
mov cx,64
mov si,offset starsXY
drawStarsLoop:
mov ax,0
mov al,cs:[si]
inc si
mov bx,0
mov bl,cs:[si]
inc si
call GetAddr
mov ax,0f2ah ;bright white *
mov [bx],ax
loop drawStarsLoop
mov si,offset score
mov ax,0
mov bx,58
call GetAddr
mov cx,22
scoreLoop:
mov ax,cs:[si]
mov [bx],ax
add bx,2
add si,2
loop scoreLoop
;Now draw bullets, Bullets are BRIGHT RED .
mov cx,8
mov si,offset bulletsXY+1 ;we only want the high parts
bulletsLoop:
mov ax,0
mov bx,0
mov bl,cs:[si]
add si,2
mov al,cs:[si]
add si,6
call GetAddr
and bx,bx
je noBullet
mov ax,0c2eh ;bright red .
mov [bx],ax
noBullet:
loop bulletsLoop
;Now draw Big projectiles 4x4 square in brown
mov cx,8
mov si,offset projectilesBigXY+1 ;we only want the high parts
projectilesBigLoop:
mov bx,0
mov dx,0
mov bl,cs:[si]
add si,2
mov dl,cs:[si]
add si,6
mov ax,bx
or ax,dx
je noBig
DrawSquare bx,dx,4,BROWN
noBig:
loop projectilesBigLoop
;Now draw Small projectiles 2x2 square in brown
mov cx,8
mov si,offset projectilesSmallXY+1 ;we only want the high parts
projectilesSmallLoop:
mov bx,0
mov dx,0
mov bl,cs:[si]
add si,2
mov dl,cs:[si]
add si,6
mov ax,bx
or ax,dx
je noSmall
DrawSquare bx,dx,2,BROWN
noSmall:
loop projectilesSmallLoop
MovDS cs
mov cx,24
mov bx,offset bulletsXY
moveAll:
mov ax,[bx]
mov dx,[bx+4]
add ax,dx
jl offScreen
cmp ax,05000h ;80
jge offScreen
mov [bx],ax
mov ax,[bx+2]
mov dx,[bx+6]
add ax,dx
jl offScreen
cmp ax,03200h ;50
jge offScreen
mov [bx+2],ax
jmp onScreen
offScreen:
mov word ptr [bx],0
mov word ptr [bx+2],0
mov word ptr [bx+4],0
mov word ptr [bx+6],0
onScreen:
add bx,8
loop moveAll
mov cx,8
mov bx,offset bulletsXY
bulletHitLoop:
mov ax,[bx]
mov dx,[bx+2]
call checkProjectiles
and al,al
je bulletNoHit
mov ax,0
mov [bx],ax
mov [bx+2],ax
mov [bx+4],ax
mov [bx+6],ax
bulletNoHit:
add bx,8
loop bulletHitLoop
mov cx,8
;bx already set to offset projectilesBigXY
projectileHitLoop:
mov ax,[bx]
cmp ax,37*256
jle .notHit
cmp ax,43*256
jge .notHit
mov dx,[bx+2]
cmp dx,10*256
jle .notHit
cmp dx,16*256
jge .notHit
call resetLevel
dec lives
ret
.notHit:
add bx,8
loop projectileHitLoop
ret
ENDP

;Enter with ax,dx with x/y of bullet
;Return al = collision
checkProjectiles PROC
PushAll
mov bulletHit,0
mov si,offset projectilesBigXY
mov cx,8
.projectilesLoop:
mov bx,[si]
cmp ax,bx
jle .bulletNoHit
sub ax,1024
cmp ax,bx
jge .bulletNoHit
mov bx,[si+2]
cmp dx,bx
jle .bulletNoHit
sub dx,1024
cmp dx,bx
jge .bulletNoHit
mov ax,5
call addScore
mov ax,0
mov [si],ax
mov [si+2],ax
mov [si+4],ax
mov [si+6],ax
PopAll
mov al,1
ret
.bulletNoHit:
add si,8
loop .projectilesLoop
PopAll
mov al,0
ret
ENDP

; begin resident program here
; AH = 01H Clear the screen
; AH = 02H Draw playfield (Stars and Score), Player, Bullets, Projectiles
; AH = 03H Wait 1 tick
int63 PROC FAR
cmp ah,01h
je _cls
cmp ah,02h
je _stars
cmp ah,03h
je _wait
cmp ah,04h
je _playGame
iret
_wait:
PushAll
GetTime
mov bx,dx
_wait2:
GetTime
cmp bx,dx
je _wait2
PopAll
iret
_stars:
PushAll
mov ax,cs
mov ds,ax
call drawStars
PopAll
iret
_cls:
PushAll
mov ax,0b800h
mov ds,ax
mov bx,80*50*2 ;80 columns 50 rows (2 characters each)
_clsLoop:
mov word ptr [bx],720h ;space in gray with black background
sub bx,2
jnc _clsLoop
MoveCursor 0,0
PopAll
iret
_playGame:
PushAll
call playGame
PopAll
iret
int63 ENDP

playGame:
InitMouse
gameLoop:
MyCls
MyPlayfield
DrawSquare playerX,playerY,5,CYAN
;add Projectiles
mov bx,offset projectilesBigXY
mov cx,8
.findProjectile:
mov ax,[bx+2]
or ax,[bx]
je .foundProjectile
add bx,8
loop .findProjectile
jmp .noProjectile
.foundProjectile:
call random
and dx,3
je .top
cmp dx,1
je .left
cmp dx,2
je .right
.bottom:
mov ah,25
mov cx,-40
jmp .yline
.top:
mov ah,0
mov cx,40
.yline:
mov [bx+6],cx
mov [bx+2],ax
call random
and dx,63
add dx,7
mov dh,dl
mov [bx],dx
call random
mov ax,dx
and dx,15
add dx,32
and ax,32
je .notneg
neg dx
.notneg:
mov [bx+4],dx
jmp .noProjectile
.left: mov ah,0
mov cx,40
jmp .xline
.right: mov ah,79
mov cx,-40
.xline: mov [bx+4],cx
mov [bx],ax
call random
and dx,31
mov dh,dl
mov [bx+2],dx
call random
mov ax,dx
and dx,15
add dx,32
and ax,32
je .notneg2
neg dx
.notneg2:
mov [bx+6],dx
.noProjectile:
GetMouse fireX,fireY
je noFire
cmp cx,37*8
jle .shotOk
cmp cx,44*8
jge .shotOk
cmp dx,10*8
jle .shotOk
cmp dx,16*8
jle noFire
.shotOk:
mov bx,offset bulletsXY
push cx
mov cx,8
.findBullet:
mov ax,[bx+2]
or ax,[bx]
je .foundFreeBullet
add bx,8
loop .findBullet
pop cx
jmp noFire ;no free bullets, no shots
.foundFreeBullet:
pop cx
mov ax,bulletXStart
mov [bx],ax
mov ax,bulletYStart
mov [bx+2],ax
mov ax,cx
sub ax,bulletMouseX
mov [bx+4],ax
mov ax,dx
sub ax,bulletMouseY
mov [bx+6],ax
noFire:
mov ax,fireY
mov bx,fireX
call GetAddr
mov [bx],0302bh ;text mouse cursor (inverted blue +)
MovDS cs
; mov ax,3
; call addScore
; DrawSquare 75,45,10,BLUE
MyWait
mov ax,lives
cmp al,'0'
je exit
jmp gameLoop
exit:
MyRestoreIRQ
ret

;Get screen address
;ax = y
;bx = x
;Return
;ds = points to screen
;bx = screen offset
GetAddr PROC
push cx
mov cl,160
mul cl
add bx,bx
add bx,ax
mov ax,0b800h
mov ds,ax
pop cx
ret
ENDP

WaitTick PROC
GetTime
mov bx,dx
WaitTick2:
GetTime
cmp bx,dx
je WaitTick2
ret
ENDP

; AH = 03H Draw a rectangle
; AL = Color Code
; CX = X start
; DX = Y start
; SI = X end
; DI = Y end
int64 PROC FAR
cmp ah,03h
je _rect
iret
_rect:
PushAll
push ax
mov ax,0b800h ;set ds to the screen
mov ds,ax
mov ax,dx
cmp ax,0
jge _rectY
mov ax,0
mov dx,0
_rectY:
mov bx,cx
cmp bx,0
jge _rectX
mov bx,0
mov cx,0
_rectX:
cmp si,80
jl _rectX2
mov si,79
_rectX2:
cmp di,50
jl _rectY2
mov di,49
_rectY2:
call GetAddr
pop ax ;so we can get the color back
mov ah,al
push cx ;save initial left x
mov al,0cdh ;the horizontal character
_topLine:
cmp cx,si
je _topLine2
add bx,2
mov [bx],ax
inc cx
jmp _topLine
_topLine2:
mov al,0bbh ;Top right character
mov [bx],ax
mov cx,dx
mov al,0bah ;the vertical character
_rightLine:
cmp cx,di
je _rightLine2
add bx,160
mov [bx],ax
inc cx
jmp _rightLine
_rightLine2:
mov al,0bch ;Bottom right left character
mov [bx],ax
pop cx
mov al,0cdh ;the horizontal character
_bottomLine:
cmp cx,si
je _bottomLine2
sub bx,2
mov [bx],ax
inc cx
jmp _bottomLine
_bottomLine2:
mov al,0c8h ;Bottom left character
mov [bx],ax
mov cx,dx
mov al,0bah ;the vertical character
_leftLine:
cmp cx,di
je _leftLine2
sub bx,160
mov [bx],ax
inc cx
jmp _leftLine
_leftLine2:
mov al,0c9h ;Top left character
mov [bx],ax
; pop cx
; mov al,0cdh ;the horizontal character

; pop bx
PopAll
iret
int64 ENDP

;Restore original IRQ
int65 PROC FAR
PushAll
PutIrq 63h,old_int63_seg,old_int63_off
PutIrq 64h,old_int64_seg,old_int64_off
PutIrq 65h,old_int65_seg,old_int65_off
PopAll
iret
int65 ENDP
; end resident program here
code ENDS

stack_seg SEGMENT stack
db 100 dup(?)
stack_seg ENDS

code SEGMENT

initialize:
ASSUME cs:code, ds:code, ss:stack_seg
mov ax,cs
mov ds,ax
mov cx,64
mov bx,offset starsXY
initStars:
call random
and dx,63
mov [bx],dl
add bx,1
call random
and dx,63
add dx,8
mov [bx],dl
add bx,1
loop initStars

GetIrq 63h,old_int63_seg,old_int63_off
GetIrq 64h,old_int64_seg,old_int64_off
GetIrq 65h,old_int65_seg,old_int65_off
SetIrq 63h,int63
SetIrq 64h,int64
SetIrq 65h,int65
myPlayGame
TSR initialize
return
code ENDS

END begin