.model small
.stack 100h
.data
menu db 0c9h,38 dup(0cdh),0bbh
db 0bah,38 dup(20h),0bah
db 0c8h,38 dup(0cdh),0bch
urname db 0c9h,32 dup(0cdh),0bbh
db 0bah,' Name: ',0bah
db 0bah,' Course/Yr: ',0bah
db 0bah,' Subject: ',0bah
db 0c8h,32 dup(0cdh),0bch
menu1 db 0c9h,28 dup(0cdh),0bbh
db 0bah,' 1 pyramid name ',0bah
db 0bah,' 2 multiply & divide ',0bah
db 0bah,' 3 reverse word ',0bah
db 0bah,' 4 palyndrome ',0bah
db 0bah,' 5 character count ',0bah
db 0bah,' 6 sum of 1-100 ',0bah
db 0bah,' 7 color loops ',0bah
db 0bah,' 8 word display ',0bah
db 0bah,' 9 running word ',0bah
db 0bah,' 10 character attribute ',0bah
db 0bah,'Enter Choice: ',0bah
db 0c8h,28 dup(0cdh),0bch
ok dw ?
msg db 'enter word: ',0
msg0 db 13,10,'Do you want to continue[Y/N]?',0
msg2 db 13,10,'[1]Mul',13,10,'[2]Div',0
msg21 db 13,10,'Enter your choice: ',0
msg22 db 13,10,'Enter first number: ',0
msg23 db 13,10,'Enter the second number: ',0
msg24 db 13,10,'The answer is: ',0
msg25 db 13,10,'Wrong input..Enter choice: ',0
msg26 db 13,10,'Remainder: ',0
msg3 db 13,10,'the reverse is ',0
msg41 db ' is a palindrome!',0
msg42 db ' is not a palindrone!',0
msg51 db 13,10,'total characters entered: ',0
msg6 db 'the sum of 1-100 is: ',0
copy8 db 80 dup (0)
copy db 80 dup (0)
nme db 80 dup (0)
course db 80 dup (0)
sbj db 80 dup (0)
chr_cnt dw ?
one dw ?
two dw ?
three dw ?
myname dw ?
mycourse dw ?
mysbj dw ?
.386
.code
start:
mov ax,@data
mov ds,ax
mov es,ax
mov ok,0
mov myname,0
mov mycourse,0
mov mysbj,0
start1:
mov chr_cnt,0
mov one,0
mov two,0
mov three,0
call clr_scrn
mov ax,0600h ;whole shadow
mov bh,17h
mov cx,0215h
mov dx,183ch
int 10h
mov bl,70h ;menu
mov bp,offset menu
mov cx,40
mov dl,20 ;column
mov dh,01h ;row
call str_atrb
add bp,cx
p01: ;cntnue menu
inc dh
call str_atrb
cmp dh,17h
je p02
jmp p01
p02:
add bp,cx
call str_atrb
mov ax,0600h ;urname shadow
mov bh,17h
mov cx,0418h
mov dx,0839h
int 10h
mov ax,0600h ;menu shadow
mov bh,17h
mov cx,0a1ah
mov dx,1637h
int 10h
mov bl,87h ;urname
mov bp,offset urname
mov cx,34
mov dl,17h ;column
mov dh,03h ;row
p03: ;cntnue urname
cmp dh,08h
je p04
call str_atrb
add bp,cx
inc dh
jmp p03
p04:
mov bl,07h ;menu1
mov bp,offset menu1
mov cx,30
mov dl,19h ;column
mov dh,09h ;row
p05: ;cntnue menu1
cmp dh,16h
je p06
call str_atrb
add bp,cx
inc dh
jmp p05
p06:
cmp ok,123
je p07
call cursorp001
mov ax,0
mov ax,offset nme
call get_str
mov myname,ax
call cursorp002
mov ax,0
mov ax,offset course
call get_str
mov mycourse,ax
call cursorp003
mov ax,0
mov ax,offset sbj
call get_str
mov mysbj,ax
p07:
call cursorp001
mov ax,myname
call put_str
call cursorp002
mov ax,mycourse
call put_str
call cursorp003
mov ax,mysbj
call put_str
mov ok,0
p08:
call cursorp004
call getn
call cmpair
aa1: ;1st menu
call junmar
mov ax, offset msg
call put_str
mov ok,2
mov ax,offset copy
call get_str
mov two,ax
mov ax,chr_cnt
mov three,ax
mov cx,0
rope:
sub chr_cnt,cx
cmp chr_cnt,cx
jle finish
mov bx,two
add chr_cnt,cx
call nextline
call tab
mov one,cx
push cx
mov cx,0
hop:
cmp cx,one
jge then
mov al,''
call putc
inc bx
inc cx
jmp hop
then:
mov ax,bx
call put_str
pop cx
inc cx
dec three
jmp rope
finish: ;reverse
cmp cx,0
jge fnsh1
call end_else
fnsh1:
mov bx,two
mov one,cx
push cx
mov cx,0
hoping:
cmp cx,one
jge thensss
mov al,''
call putc
inc bx
inc cx
jmp hoping
thensss:
mov ax,bx
call put_str
call nextline
call tab
pop cx
dec cx
inc three
jmp finish
bb1:
call junmar
mov ok,0
mov ax,offset msg2
call put_str
mov ax,offset msg21
call put_str
bb12:
call getc
cmp al,'1'
je multing
cmp al,'2'
je diving
mov ax,offset msg25
call put_str
jmp bb12
multing:
mov ax, offset msg22
call put_str
call getn
mov one,ax
mov ax,offset msg23
call put_str
call getn
mov two,ax
mov ax,offset msg24
call put_str
mov cx, two
mov ax, one
mul cx
call putn
call end_else
diving:
mov ax, offset msg22
call put_str
call getn
mov one,ax
mov ax,offset msg23
call put_str
call getn
mov two, ax
mov ax,offset msg24
call put_str
mov ax,one
mov cx,0
call jun
jun:
cmp ax,two
jb mar
sub ax,two
inc cx
jmp jun
mar:
mov bx,ax
mov ax,cx
call putn
cmp bx,0
je finish2
mov ax,offset msg26
call put_str
mov ax,bx
call putn
jmp finish2
finish2:
call end_else
cc1:
call junmar
mov ax,offset msg
call put_str
dec two
mov ax,offset copy
call get_str
mov bx,chr_cnt
add two,bx
add two,ax
mov ax,offset msg3
call put_str
rope3:
mov bx,two
mov al,byte ptr [bx]
cmp al,0
je finish3
call putc
dec two
jmp rope3
finish3:
call end_else
dd1:
call junmar
mov ax,offset msg
call put_str
dec two
mov ax,offset copy
call get_str
mov one,ax
mov bx,chr_cnt
add two,bx
add two,ax
call nextline
mov ax,0
mov ax,offset copy
call put_str
looping:
mov bx,one
mov al,byte ptr [bx]
mov bx,two
mov ah,byte ptr [bx]
cmp al,0
je palin
cmp al,ah
jne not_palin
inc one
dec two
jmp looping
palin:
mov ax,offset msg41
call put_str
call end_else
not_palin:
mov ax,offset msg42
call put_str
call end_else
ee1:
call junmar
mov ax,offset msg
call put_str
mov ax,offset copy
call get_str
mov ax,offset msg51
call put_str
mov ax,chr_cnt
call putn
call end_else
ff1:
call junmar
mov cx,1
mov one,0
looping6:
cmp cx,100
jnle end_disp6
add one,cx
inc cx
jmp looping6
end_disp6:
mov ax,offset msg6
call put_str
mov ax,one
call putn
call end_else
gg1:
mov cx,0000h
mov dx,004fh
loop71:
mov bh,85h
loops7:
mov ax,0600h
int 10h
sub bh,10h
inc dh
inc ch
cmp bh,07h
je loop71
cmp dh,19h
jl loops7
call cursorp0
call end_else
hh1:
call junmar
mov ax,offset msg
call put_str
mov ax,offset copy8
call get_str
mov one,ax
mov two,4fh
mov ax,chr_cnt
sub two,ax
call clr_scrn
call cursorp0
call hh3
mov dh,18h
int 10h
call hh3
add dx,two
int 10h
call hh3
mov dh,00h
int 10h
call hh3
call cursorp2
call hh3
call end_else
ii1:
call junmar
mov ax,offset msg
call put_str
mov ax,offset copy
call get_str
mov one,ax
mov ax,4fh
sub ax,chr_cnt
mov two,ax
mov ah,02h
mov bh,00
mov di,00h
mov dh,12h
int 10h
mov cx,0
jmp ii3
ii2:
inc three
mov cx,two
cmp three,cx
jg end_else
mov al,''
call putc
mov cx,0
ii3:
mov ax,one
call put_str
mov ah,02h
mov bh,00
mov dx,three
mov dh,12h
int 10h
inc cx
cmp cx,08ffh
jl ii3
jmp ii2
jj1:
call junmar
mov ax,offset msg
call put_str
mov ax,offset copy
call get_str
mov one,ax
call clr_scrn
mov cx,0000h
mov dx,004fh
mov bh,01h
loops10:
mov ax,0600h
int 10h
add bh,01h
inc dh
inc ch
cmp bh,10h
je loops101
cmp dh,19h
jl loops10
mov ok,10
call cursorp0
jmp loops102
loops101:
mov bh,01h
jmp loops10
loops102:
mov ax,one
call put_str
cmp two,1932
jl loops102
call cursorp0
end_else: ;end else
call cont
str_atrb:
mov ax,1301h ;urname
mov bh,00
int 10h
ret
cursorp0:
mov ah,02h
mov bh,00
mov dh,00h
mov dl,00h
int 10h
ret
cursorp001:
mov ah,02h
mov bh,00
mov dh,04h
mov dl,1eh
int 10h
ret
cursorp002:
mov ah,02h
mov bh,00
mov dh,05h
mov dl,23h
int 10h
ret
cursorp003:
mov ah,02h
mov bh,00
mov dh,06h
mov dl,21h
int 10h
ret
cursorp004:
mov ah,02h
mov bh,00
mov dh,14h
mov dl,41
int 10h
ret
cmpair:
mov ok,ax
cmp ok,1
je a1
cmp ok,2
je b1
cmp ok,3
je c1
cmp ok,4
je d1
cmp ok,5
je e1
cmp ok,6
je f1
cmp ok,7
je g1
cmp ok,8
je h1
cmp ok,9
je i1
cmp ok,10
je j1
call end_else
a1:
call aa1
b1:
call bb1
c1:
call cc1
d1:
call dd1
e1:
call ee1
f1:
call ff1
g1:
call gg1
h1:
call hh1
i1:
call ii1
j1:
call jj1
clr_scrn:
mov ax,0600h ;whole screen
mov bh,07h
mov cx,0000h
mov dx,184fh
int 10h
ret
cursorp1:
mov ah,02h
mov bh,00
mov dh,05h
mov dl,00h
int 10h
ret
cursor11:
mov ah,02h
mov bh,00
mov dh,01h
mov dl,00h
int 10h
ret
cursorp2:
mov ah,02h
mov bh,00
mov dh,12
mov dl,40
mov cx,chr_cnt
shr cx,01
sub dl,cl
int 10h
ret
puts:
mov dx,ax
mov ah,9h
int 21h
ret
putc:
mov dl,al
mov ah,2h
int 21h
ret
getc:
mov ah,1h
int 21h
ret
getn:
push bx
push cx
push dx
mov dx, 1
mov bx, 0
mov cx, 0
call getc
cmp al, ' '
jne newline
mov dx, -1
call getc
newline:
push dx
cmp al, 13
je fin_read
sub al, '0'
mov bl, al
mov ax, 10
mul cx
mov cx, ax
add cx, bx
call getc
read_loop:
cmp al, 13
je fin_read
sub al, '0'
mov bl, al
mov ax, 10
mul cx
mov cx, ax
add cx, bx
call getc
jmp read_loop
fin_read:
mov ax, cx
pop dx
cmp dx, 1
je fin_getn
neg ax
fin_getn:
pop dx
pop cx
pop bx
ret
putn:
push bx
push cx
push dx
mov dx,0
push dx
mov cx,10
cmp ax,0
jge calc_digits
neg ax
push ax
mov al,'-'
call putc
pop ax
calc_digits:
div cx
add dx,'0'
push dx
mov dx,0
cmp ax,0
jne calc_digits
disp_loop:
pop ax
cmp ax,0
je end_disp_loop
call putc
jmp disp_loop
end_disp_loop:
pop dx
pop cx
pop bx
mov ok,0
ret
get_str:
push ax
push bx
push cx
push dx
mov cx,0
mov bx,ax
call getc
mov byte ptr[bx],al
get_loop:
cmp al,13
je get_fin
inc bx
inc cx
call getc
mov byte ptr[bx],al
jmp get_loop
get_fin:
mov byte ptr[bx],0
pop dx
mov chr_cnt,cx
pop cx
pop bx
pop ax
ret
put_str:
push ax
push bx
push cx
push dx
mov cx,one
mov bx,ax
mov al,byte ptr[bx]
put_loop:
cmp al,0
je put_fin
cmp ok,2
jne put1
cmp cx,three
jge put_fin
put1:
call putc
inc cx
inc bx
cmp ok,10
jne put2
inc two
put2:
mov al,byte ptr[bx]
jmp put_loop
put_fin:
pop dx
pop cx
pop bx
pop ax
ret
nextline:
mov al,13
call putc
mov al,10
call putc
ret
tab:
mov al,09
call putc
ret
hh3:
push ax
mov ax,one
call put_str
pop ax
ret
junmar:
call clr_scrn
call cursorp1
ret
cont:
mov ok,99
mov ax,offset msg0
call put_str
call getc
cmp al,'Y'
je cont2
cmp al,'y'
je cont2
cmp al,'N'
je cont3
cmp al,'n'
je cont3
cont3:
mov ax,4c00h
int 21h
cont2:
mov ok,123
call start1
end start
No comments:
Post a Comment