cs401 Assignment No 2

You might also like

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

Student ID: BC220415039

Assembly Code:
[org 0x0100]

jmp start

message: db 'BC220415039'

length: dw 11

clrscr:

push es

push ax

push di

mov ax, 0xb800

mov es, ax

mov di, 0

nextloc:

mov word[es:di], 0x2020

add di, 2

cmp di, 4000

jne nextloc

mov si, message

mov cx, [length]

mov di, 79

sub di, cx

shl di, 1

mov ax, 3

mov bx, ax

shl bx, 60

shl ax, 2

add bx, ax
add di, bx

shl di, 1

print_vuid:

mov al, [si]

mov ah, 0x05

mov [es:di], ax

add si, 1

add di, 2

loop print_vuid

pop di

pop ax

pop es

ret

printstr:

push bp

mov bp, sp

push es

push ax

push cx

push si

push di

mov ax, 0xb800

mov es, ax

mov si, [bp+8]

mov cx, [bp+10]

mov di, [bp+4]

mov ax, [bp+6]

mov bx, ax
shl bx, 6

shl ax, 2

add bx, ax

add di, bx

shl di, 1

print_loop:

mov al, [si]

mov ah, [bp+12]

mov [es:di], ax

add si, 1

add di, 2

loop print_loop

pop di

pop si

pop cx

pop ax

pop es

pop bp

ret 10

start:

call clrscr

mov ax, 7

push ax

mov ax, 4

push ax

mov ax, 5

push ax

mov ax, message


push ax

push word (length)

call printstr

mov ax, 0x4c00

int 0x21

Output Screenshot:

You might also like