cs401p assignment 2 2023
[org 0x0100]
jmp main_funtion
ID: db 10, 13,'$'
Length_of_buffer: db 80 ; length of buffer
db 0 ; number of characters on return
times 80 db 0 ; actual buffer space
string_length: dw 11 ; length of the string
; subroutine to clear the screen
clearscreen:
push es
push ax
push di
mov ax, 0xb800
mov es, ax
xor di, di
mov cx, 80*20
clr_loop:
mov word [es:di], 0x0700
add di, 2
loop clr_loop
pop di
pop ax
pop es
ret
output_string:
push bp
mov bp, sp
push es
push ax
push cx
push si
push di
mov ax, 0xb800
mov es, ax
xor di, di
mov si, [bp+6]
mov cx, [bp+4]
mov ah, 0xFF
print_loop:
mov al, [si]
mov ah, [si+1]
mov [es:di], ax
add di, 2
add si, 1
loop print_loop
pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 4
main_funtion:
mov dx, Length_of_buffer
mov ah, 0x0A
int 0x21
mov bh, 0
mov bl, [Length_of_buffer+1]
mov byte [Length_of_buffer+2+bx], '$'
mov ax, Length_of_buffer+2
push ax
push word [string_length]
call clearscreen
call output_string
mov ax, 0x4c00
int 0x21
