TASM (Assignment) 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Submitted by: Almar D. Elipana BSIT-2B ; prob. no. 1 ; print numbers: 1 2 3 4 5 6 7 mov dx, bx int 21h .

model small .stack 100h .data num1 dw 1 num2 dw 8 .code main proc mov ax, @data mov ds, ax cmp bx, cx jb display1 check: mov dx, 1 add bx, dx sub bx, 30h jmp check

mov bx, num1 ; bx=1 mov cx, num2 ; cx=8 bye: cmp bx, cx jb display1

cmp bx, cx je bye

mov ax, 4c00h int 21h

cmp bx, cx je bye

main endp end main

display1: add bx, 30h mov ah, 02h

Submitted by: Almar D. Elipana BSIT-2B

;prob. no. 2 ;output: ;2 ;5

Submitted by: Almar D. Elipana BSIT-2B ;8 mov dx, bx int 21h .model small .stack 100h .data num1 dw 2 num2 dw 11 .code main proc mov ax, @data mov ds, ax cmp bx, cx jb display1 mov bx, num1 ; bx=2 mov cx, num2 ; cx=11 cmp bx, cx je bye cmp bx, cx jb display1 bye: mov ax, 4c00h int 21h cmp bx, cx je bye line proc mov ah, 02h display1: add bx, 30h mov ah, 02h mov dl, 0ah mov dl, 0dh int 21h check: call line mov dx, 3 add bx, dx sub bx, 30h jmp check

Submitted by: Almar D. Elipana BSIT-2B int 21h ret line endp

main endp end main

;prob. no. 3 ;output ;1 ;1 2 2

Submitted by: Almar D. Elipana BSIT-2B ;1 ;1 ;1 ;1 2 2 2 2 cmp bx,'2' je nl .model small .stack 100h .data space db " ","$" a dw 0 b dw 0 inc bx mov ah,02h mov dx,bx int 21h addnum: cmp bx,'2' jb addnum

.code main proc

mov ah,09h lea dx,space int 21h mov ax,@data mov ds,ax jmp check

mov bx,a add bl,30h

nl: call line

mov cx,b add cl,30h check:

inc cx pop bx mov bx,a add bl,30h

Submitted by: Almar D. Elipana BSIT-2B

check1:

main endp end main

cmp cx,'6' jb check

cmp cx,'6' je endd

endd:

mov ah,4ch int 21h

line proc mov ah, 02h

mov dl, 0dh int 21h

mov dl, 0ah int 21h ret ;prob. no. 4 ;output: ;* line endp ;* * * * *

Submitted by: Almar D. Elipana BSIT-2B ;* * * * * * go: inc bx mov ah, 09h .model small .stack 100h .data strt dw 0 endd dw 2 spce db " ","$" star db " * ","$" jmp chicks .code main proc mov ax, @data mov ds, ax chicks: cmp bx, cx jne go mov ah, 09h lea dx, spce int 21h lea dx, star int 21h

mov bx, strt ;bx=0 add bl, 30h

cmp bx, cx je den

mov cx, endd ;cx=3 add cl, 30h

den: call line add cx, 2

cmp bx, cx ja go

sub cl, 30h

pop bx

Submitted by: Almar D. Elipana BSIT-2B cmp bx, cx jne go

cmp bx, cx je denied

denied: mov ah, 4ch int 21h

line proc mov ah, 02h

mov dl, 0dh int 21h

mov dl, 0ah int 21h ret

line endp ;prob. no. 5 main endp end main ;output ;* ;* * * * * * * * * * * * *

Submitted by: Almar D. Elipana BSIT-2B ;* ;* * * * * disp: inc bx mov ah, 09h .model small .stack 100h .data bgin dw 0 next dw endd dw 8 point db "* ","$" 2 chek: cmp bx, cx jb disp .code main proc mov ax, @data mov ds, ax look: mov bx, bgin add bl, 30h mov dx, 2 add cx, dx call line mov cx, next add cl, 30h pop bx mov bx, bgin cmp bx, cx jb disp mov dx, endd add bx, 30h cmp bx, cx je look jmp chek lea dx, point int 21h

Submitted by: Almar D. Elipana BSIT-2B add dl, 30h

cmp dx, cx

ja disp cmp dx, cx

je end1

end1: mov ah, 4ch int 21h line proc mov ah, 02h mov dl,0dh int 21h mov dl, 0ah int 21h ret

line endp ;prob. no. 6 main endp end main ;output: ;& & ;& &

Submitted by: Almar D. Elipana BSIT-2B ;& & ;& & ;& & add1: inc bx mov ah, 09h lea dx, amper .model small .stack 100h .data strtnum ednnum amper space dw 0 dw 5 db " & ","$" db "","$" cmp bx, 2 jne check .code main proc mov ax, @data mov ds, ax check: mov bx, strtnum ;bx=0 add bl, 30h cmp bx, 2 jne add1 cmp bx, 2 je next mov ah, 09h lea dx, space int 21h int 21h

mov cx, endnum ;cx=5 add cl, 30h

new: call line

cmp bx, cx jb add1

pop bx mov bx, strtnum

Submitted by: Almar D. Elipana BSIT-2B add bl, 30h end main

dec cx cmp cx, 0 jne add1

cmp cx, 0 je endd

endd: mov ah, 4ch int 21h

line proc mov ah, 02h

mov dl, 0ah int 21h

mov dl, 0ah int 21h ret line endp ;prob. no. 8 ;output: ;& main endp ;& & & & & &

Submitted by: Almar D. Elipana BSIT-2B ;& & & & & here: inc bx mov ah, 09h .model small .stack 100h .data zro tre dw 0 dw 3 mov ah, 09h lea dx, aprt int 21h lea dx, strs int 21h

aprt db " ","$" strs db " & ","$"

jmp look .code main proc mov ax, @data mov ds, ax look: cmp bx, cx jne here

mov bx, zro ;bx=0 add bl, 30h

cmp bx, cx je find

mov cx, tre ;cx=1 add cl, 30h

find: call line

cmp bx, cx je here

inc cx sub cl, 30h

Submitted by: Almar D. Elipana BSIT-2B pop bx cmp bx, cx jne here

cmp bx, cx je suspend

suspend: mov ah, 4ch int 21h

line proc mov ah, 02h

mov dl, 0dh int 21h

mov dl, 0ah int 21h ret

line endp

;prob. no. 9 ;output:

main endp end main

;1 2 2 3 3 4 4

Submitted by: Almar D. Elipana BSIT-2B .model small .stack 100h .data num1 num2 x dw 1 dw 2 db "4","$" cmp bx, 4 .code main proc mov ax, @data mov ds, ax den: mov dx, 1 add bx, dx mov bx, num1 ;bx=1 mov cx, num2 ;cx=2 pop dx cmp bx, cx jne nxt mov dx, 1 add cx, dx sub cl, 30h nxt: add bl, 30h mov ah, 02h cmp cx, 5 jb nxt sub bl, 30h jne den mov dx, cx int 21h add cl, 30h mov ah, 02h

mov dx, bx int 21h

cmp cx, 5 je bye1

Submitted by: Almar D. Elipana BSIT-2B bye: mov ax, 4c00h int 21h

bye1: mov ah, 09h lea dx, x int 21h

jmp bye

main endp end main

;prob. no. 10 ;output: ;3 2 6 4 9 6 12

Submitted by: Almar D. Elipana BSIT-2B .model small .stack 100h .data num1 dw 3 num2 dw 2 x db "12","$" cmp bx, 12 .code main proc mov ax, @data mov ds, ax den: mov dx, 3 add bx, dx mov bx, num1 ;bx=3 mov cx, num2 ;cx=2 pop dx cmp bx, cx jne nxt mov dx, 2 add cx, dx sub cl, 30h nxt: add bx, 30h mov ah, 02h cmp cx, 8 jb nxt sub bl, 30h jne den mov dx, cx int 21h add cx, 30h mov ah, 02h

mov dx, bx int 21h

cmp cx, 8 je bye1

Submitted by: Almar D. Elipana BSIT-2B bye: mov ax, 4c00h int 21h

bye1: mov ah, 09h lea dx, x int 21h

jmp bye

main endp end main

You might also like