0% found this document useful (0 votes)
13 views6 pages

Computer Organization and Assembly Language (COAL) Lab 10: Ali Naqi (23F-3052)

The document contains assembly language code for three different lab questions related to computer organization. Each question includes a program that clears the screen and prints the message 'hello world' using various subroutines. The code demonstrates the use of stack operations, string manipulation, and screen memory addressing in assembly language.

Uploaded by

alinaqi1129
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Computer Organization and Assembly Language (COAL) Lab 10: Ali Naqi (23F-3052)

The document contains assembly language code for three different lab questions related to computer organization. Each question includes a program that clears the screen and prints the message 'hello world' using various subroutines. The code demonstrates the use of stack operations, string manipulation, and screen memory addressing in assembly language.

Uploaded by

alinaqi1129
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer Organization and Assembly Language (COAL)

Lab 10
Ali Naqi (23F-3052)
Question 1:
Code:
[org 0x0100]
jmp start
message : db 'hello world', 0
clrscr :
push ax
push di
push es
mov di, 0
mov ax, 0xb800
mov es, ax
mov ax, 0x720
mov cx, 2000
cld
rep stosw

pop es
pop di
pop ax
ret
strlen : push bp
mov bp, sp
push es
push ax
push cx
push si
push di
push ds
pop es
les di, [bp + 4]
mov cx, 0xffff
xor al, al
repne scasb
mov ax, 0xffff
sub ax, cx
dec ax
pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
start:
; call clrscr
mov ax, message
push ax
call strlen
mov ax, 0x4c00
int 0x21
Output:

Question 2:
Code:
[org 0x0100]
jmp start
message : db 'hello world', 0
clrscr :
push ax
push di
push es
mov di, 0
mov ax, 0xb800
mov es, ax
mov ax, 0x720
mov cx, 2000
cld
rep stosw

pop es
pop di
pop ax
ret
printstr : push bp
mov bp, sp
push es
push ax
push cx
push si
push di
push ds
pop es
mov di, [bp + 4]
mov cx, 0xffff
xor al, al
repne scasb
mov ax, 0xffff
sub ax, cx
dec ax
jz exit
mov cx, ax
mov ax, 0xb800
mov es, ax
mov al, 80
mul byte[bp + 8]
add ax, [bp + 10]
shl ax, 1
mov di, ax
mov si, [bp + 4]
mov ah, [bp + 6]
cld
nextchar : lodsb
stosw
loop nextchar
exit : pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
start:
call clrscr
mov ax, 20
push ax
mov ax, 10
push ax
mov ax, 0x07
push ax
mov ax, message
push ax
call printstr
mov ax, 0x4c00
int 0x21
Output:

Question 3:
Code:
[org 0x0100]
jmp start
message : db 'hello world', 0
clrscr :
push ax
push di
push es
mov di, 0
mov ax, 0xb800
mov es, ax
mov ax, 0x720
mov cx, 2000
cld
rep stosw

pop es
pop di
pop ax
ret
printstr : push bp
mov bp, sp
push es
push ax
push cx
push si
push di
push ds
pop es
mov di, [bp + 4]
mov cx, 0xffff
xor al, al
repne scasb
mov ax, 0xffff
sub ax, cx
dec ax
jz exit
mov cx, ax
mov ax, 0xb800
mov es, ax
mov al, 80
mul byte[bp + 8]
add ax, [bp + 10]
shl ax, 1
mov di, ax
mov si, [bp + 4]
mov ah, [bp + 6]
cld
nextchar : lodsb
stosw
loop nextchar
exit : pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
start:
call clrscr
mov ax, 20
push ax
mov ax, 10
push ax
mov ax, 0x07
push ax
mov ax, message
push ax
call printstr
mov ax, 0x4c00
int 0x21
Output:

You might also like