- jcodeeInactive forumer
- Posts : 3
Join date : 2009-11-06
Age : 46
Home Address : AUH, United Arab Emirates
OS LOADER - Sorry wala section for assemblers kaya dito na lang
Tue Dec 08, 2009 4:56 pm
#make_bin#
#load_segment=0800#
#load_offset=0000#
#al=0b#
#ah=00#
#bh=00#
#bl=00#
#ch=00#
#cl=02#
#dh=00#
#dl=00#
#ds=0800#
#es=0800#
#si=7c02#
#di=0000#
#bp=0000#
#cs=0800#
#ip=0000#
#ss=07c0#
#sp=03fe#
putc macro char
push ax
mov al, char
mov ah, 0eh
int 10h
pop ax
endm
gotoxy macro col, row
push ax
push bx
push dx
mov ah, 02h
mov dh, row
mov dl, col
mov bh, 0
int 10h
pop dx
pop bx
pop ax
endm
print macro x, y, attrib, sdat
LOCAL s_dcl, skip_dcl, s_dcl_end
pusha
mov dx, cs
mov es, dx
mov ah, 13h
mov al, 1
mov bh, 0
mov bl, attrib
mov cx, offset s_dcl_end - offset s_dcl
mov dl, x
mov dh, y
mov bp, offset s_dcl
int 10h
popa
jmp skip_dcl
s_dcl DB sdat
s_dcl_end DB 0
skip_dcl:
endm
org 0000h
jmp start
;==== data section =====================
msg db 'os loader open!', 0
cmd_size equ 10
command_buffer db cmd_size dup('b')
clean_str db cmd_size dup(' '), 0
prompt db '>', 0
chelp db 'help', 0
chelp_tail:
ccls db 'cls', 0
ccls_tail:
cquit db 'quit', 0
cquit_tail:
cexit db 'exit', 0
cexit_tail:
creboot db 'reboot', 0
creboot_tail:
help_msg db 'OS Loader!', 0Dh,0Ah
db 'console commands:', 0Dh,0Ah
db 'help - print list.', 0Dh,0Ah
db 'cls - clear scr', 0Dh,0Ah
db 'reboot - reboot the machine.', 0Dh,0Ah
db 'quit - reboot.', 0Dh,0Ah
db 'exit - quit.', 0Dh,0Ah
db 'mods', 0Dh,0Ah, 0
unknown db 'unknown command: ' , 0
;======================================
start:
; data segment:
push cs
pop ds
; video mode
mov ah, 00h
mov al, 03h
int 10h
; prompt emulators
mov ax, 1003h
mov bx, 0
int 10h
call clear_screen
lea si, msg
call print_string
eternal_loop:
call get_command
call process_cmd
jmp eternal_loop
;===========================================
get_command proc near
mov ax, 40h
mov es, ax
mov al, es:[84h]
gotoxy 0, al
lea si, clean_str
call print_string
gotoxy 0, al
lea si, prompt
call print_string
mov dx, cmd_size ; buffer size.
lea di, command_buffer
call get_string
ret
get_command endp
;===========================================
process_cmd proc near
push ds
pop es
cld ; forward compare.
lea si, command_buffer
mov cx, chelp_tail - offset chelp ; size of ['help',0] string.
lea di, chelp
repe cmpsb
je help_command
lea si, command_buffer
mov cx, ccls_tail - offset ccls ; size of ['cls',0] string.
lea di, ccls
repe cmpsb
jne not_cls
jmp cls_command
not_cls:
lea si, command_buffer
mov cx, cquit_tail - offset cquit ; size of ['quit',0] string.
lea di, cquit
repe cmpsb
je reboot_command
lea si, command_buffer
mov cx, cexit_tail - offset cexit ; size of ['exit',0] string.
lea di, cexit
repe cmpsb
je reboot_command
lea si, command_buffer
mov cx, creboot_tail - offset creboot ; size of ['reboot',0] string.
lea di, creboot
repe cmpsb
je reboot_command
mov al, 1
call scroll_t_area
mov ax, 40h
mov es, ax
mov al, es:[84h]
dec al
gotoxy 0, al
lea si, unknown
call print_string
lea si, command_buffer
call print_string
mov al, 1
call scroll_t_area
jmp processed
mov al, 9
call scroll_t_area
mov ax, 40h
mov es, ax
mov al, es:[84h]
sub al, 9
gotoxy 0, al
lea si, help_msg
call print_string
mov al, 1
call scroll_t_area
jmp processed
cls_command:
call clear_screen
jmp processed
reboot_command:
call clear_screen
print 5,2,0011_1111b," eject floppy disks "
print 5,3,0011_1111b," press any key to reboot... "
mov ax, 0 ; wait for any key....
int 16h
;boot values
mov ax, 0040h
mov ds, ax
mov w.[0072h], 0000h
jmp 0ffffh:0000h
processed:
ret
process_cmd endp
scroll_t_area proc near
mov dx, 40h
mov es, dx
mov ah, 06h
mov bh, 07
mov ch, 0
mov cl, 0
mov di, 84h
mov dh, es:[di]
dec dh
mov di, 4ah
mov dl, es:[di]
dec dl
int 10h
ret
scroll_t_area endp
get_string proc near
push ax
push cx
push di
push dx
mov cx, 0
cmp dx, 1
jbe empty_buffer
dec dx
wait_for_key:
mov ah, 0
int 16h
cmp al, 0Dh
jz exit
cmp al, 8
jne add_to_buffer
jcxz wait_for_key
dec cx
dec di
putc 8
putc ' '
putc 8
jmp wait_for_key
add_to_buffer:
cmp cx, dx
jae wait_for_key
mov [di], al
inc di
inc cx
mov ah, 0eh
int 10h
jmp wait_for_key
exit:
; null term
mov [di], 0
empty_buffer:
pop dx
pop di
pop cx
pop ax
ret
get_string endp
print_string proc near
push ax
push si
next_char:
mov al, [si]
cmp al, 0
jz printed
inc si
mov ah, 0eh
int 10h
jmp next_char
printed:
pop si
pop ax
ret
print_string endp
clear_screen proc near
push ax
push ds
push bx
push cx
push di
mov ax, 40h
mov ds, ax
mov ah, 06h
mov al, 0
mov bh, 1001_1111b
mov ch, 0
mov cl, 0
mov di, 84h
mov dh, [di]
mov di, 4ah
mov dl, [di]
dec dl
int 10h
mov bh, 0
mov dl, 0
mov dh, 0
mov ah, 02
int 10h
pop di
pop cx
pop bx
pop ds
pop ax
ret
clear_screen endp
#load_segment=0800#
#load_offset=0000#
#al=0b#
#ah=00#
#bh=00#
#bl=00#
#ch=00#
#cl=02#
#dh=00#
#dl=00#
#ds=0800#
#es=0800#
#si=7c02#
#di=0000#
#bp=0000#
#cs=0800#
#ip=0000#
#ss=07c0#
#sp=03fe#
putc macro char
push ax
mov al, char
mov ah, 0eh
int 10h
pop ax
endm
gotoxy macro col, row
push ax
push bx
push dx
mov ah, 02h
mov dh, row
mov dl, col
mov bh, 0
int 10h
pop dx
pop bx
pop ax
endm
print macro x, y, attrib, sdat
LOCAL s_dcl, skip_dcl, s_dcl_end
pusha
mov dx, cs
mov es, dx
mov ah, 13h
mov al, 1
mov bh, 0
mov bl, attrib
mov cx, offset s_dcl_end - offset s_dcl
mov dl, x
mov dh, y
mov bp, offset s_dcl
int 10h
popa
jmp skip_dcl
s_dcl DB sdat
s_dcl_end DB 0
skip_dcl:
endm
org 0000h
jmp start
;==== data section =====================
msg db 'os loader open!', 0
cmd_size equ 10
command_buffer db cmd_size dup('b')
clean_str db cmd_size dup(' '), 0
prompt db '>', 0
chelp db 'help', 0
chelp_tail:
ccls db 'cls', 0
ccls_tail:
cquit db 'quit', 0
cquit_tail:
cexit db 'exit', 0
cexit_tail:
creboot db 'reboot', 0
creboot_tail:
help_msg db 'OS Loader!', 0Dh,0Ah
db 'console commands:', 0Dh,0Ah
db 'help - print list.', 0Dh,0Ah
db 'cls - clear scr', 0Dh,0Ah
db 'reboot - reboot the machine.', 0Dh,0Ah
db 'quit - reboot.', 0Dh,0Ah
db 'exit - quit.', 0Dh,0Ah
db 'mods', 0Dh,0Ah, 0
unknown db 'unknown command: ' , 0
;======================================
start:
; data segment:
push cs
pop ds
; video mode
mov ah, 00h
mov al, 03h
int 10h
; prompt emulators
mov ax, 1003h
mov bx, 0
int 10h
call clear_screen
lea si, msg
call print_string
eternal_loop:
call get_command
call process_cmd
jmp eternal_loop
;===========================================
get_command proc near
mov ax, 40h
mov es, ax
mov al, es:[84h]
gotoxy 0, al
lea si, clean_str
call print_string
gotoxy 0, al
lea si, prompt
call print_string
mov dx, cmd_size ; buffer size.
lea di, command_buffer
call get_string
ret
get_command endp
;===========================================
process_cmd proc near
push ds
pop es
cld ; forward compare.
lea si, command_buffer
mov cx, chelp_tail - offset chelp ; size of ['help',0] string.
lea di, chelp
repe cmpsb
je help_command
lea si, command_buffer
mov cx, ccls_tail - offset ccls ; size of ['cls',0] string.
lea di, ccls
repe cmpsb
jne not_cls
jmp cls_command
not_cls:
lea si, command_buffer
mov cx, cquit_tail - offset cquit ; size of ['quit',0] string.
lea di, cquit
repe cmpsb
je reboot_command
lea si, command_buffer
mov cx, cexit_tail - offset cexit ; size of ['exit',0] string.
lea di, cexit
repe cmpsb
je reboot_command
lea si, command_buffer
mov cx, creboot_tail - offset creboot ; size of ['reboot',0] string.
lea di, creboot
repe cmpsb
je reboot_command
mov al, 1
call scroll_t_area
mov ax, 40h
mov es, ax
mov al, es:[84h]
dec al
gotoxy 0, al
lea si, unknown
call print_string
lea si, command_buffer
call print_string
mov al, 1
call scroll_t_area
jmp processed
mov al, 9
call scroll_t_area
mov ax, 40h
mov es, ax
mov al, es:[84h]
sub al, 9
gotoxy 0, al
lea si, help_msg
call print_string
mov al, 1
call scroll_t_area
jmp processed
cls_command:
call clear_screen
jmp processed
reboot_command:
call clear_screen
print 5,2,0011_1111b," eject floppy disks "
print 5,3,0011_1111b," press any key to reboot... "
mov ax, 0 ; wait for any key....
int 16h
;boot values
mov ax, 0040h
mov ds, ax
mov w.[0072h], 0000h
jmp 0ffffh:0000h
processed:
ret
process_cmd endp
scroll_t_area proc near
mov dx, 40h
mov es, dx
mov ah, 06h
mov bh, 07
mov ch, 0
mov cl, 0
mov di, 84h
mov dh, es:[di]
dec dh
mov di, 4ah
mov dl, es:[di]
dec dl
int 10h
ret
scroll_t_area endp
get_string proc near
push ax
push cx
push di
push dx
mov cx, 0
cmp dx, 1
jbe empty_buffer
dec dx
wait_for_key:
mov ah, 0
int 16h
cmp al, 0Dh
jz exit
cmp al, 8
jne add_to_buffer
jcxz wait_for_key
dec cx
dec di
putc 8
putc ' '
putc 8
jmp wait_for_key
add_to_buffer:
cmp cx, dx
jae wait_for_key
mov [di], al
inc di
inc cx
mov ah, 0eh
int 10h
jmp wait_for_key
exit:
; null term
mov [di], 0
empty_buffer:
pop dx
pop di
pop cx
pop ax
ret
get_string endp
print_string proc near
push ax
push si
next_char:
mov al, [si]
cmp al, 0
jz printed
inc si
mov ah, 0eh
int 10h
jmp next_char
printed:
pop si
pop ax
ret
print_string endp
clear_screen proc near
push ax
push ds
push bx
push cx
push di
mov ax, 40h
mov ds, ax
mov ah, 06h
mov al, 0
mov bh, 1001_1111b
mov ch, 0
mov cl, 0
mov di, 84h
mov dh, [di]
mov di, 4ah
mov dl, [di]
dec dl
int 10h
mov bh, 0
mov dl, 0
mov dh, 0
mov ah, 02
int 10h
pop di
pop cx
pop bx
pop ds
pop ax
ret
clear_screen endp
- GuestGuest
Re: OS LOADER - Sorry wala section for assemblers kaya dito na lang
Wed Dec 09, 2009 5:52 am
hmmm.,, di ko alam to ah... hek..
Permissions in this forum:
You cannot reply to topics in this forum