Misc.inc
[ Return to Browse Source Page ]
dump_sector:
pushad
push es
call clearscreen
mov ax,os_vram
mov dl,16
mov edi,(4*(80*2) + 24*2)
mov esi,offset hd_buffer
mov es,ax
dump_sector_o:
mov cl,32
dump_sector_i:
mov al,[esi]
dec cl
lea esi,[esi+1]
mov es:[edi],al
lea edi,[edi+2]
jnz dump_sector_i
dec dl
lea edi,[edi + (24*2*2)]
jnz dump_sector_o
mov ax,23*256
call set_cursor
call pause
pop es
popad
ret
tolower:
push ecx
push eax
push edi
call strlen_d
test ecx,ecx
jz tolower_end
tolower_loop:
mov al,[edi]
cmp al,041h
jb tolower_loop2
cmp al,05Ah
ja tolower_loop2
add al,020h
tolower_loop2:
mov [edi],al
lea edi,[edi+1]
loop tolower_loop
tolower_end:
pop edi
pop eax
pop ecx
ret
toupper:
push ecx
push eax
push edi
call strlen_d
test ecx,ecx
jz tolower_end
toupper_loop:
mov al,[edi]
cmp al,061h
jb toupper_loop2
cmp al,07Ah
ja toupper_loop2
sub al,020h
toupper_loop2:
mov [edi],al
lea edi,[edi+1]
loop toupper_loop
toupper_end:
pop edi
pop eax
pop ecx
ret
strlen_d:
; in: ds:edi
; out: ecx
push eax
mov ecx,0FFFFFFFFh
strlen_loop:
mov al,[edi + ecx + 1]
test al,al
lea ecx,[ecx + 1]
jnz strlen_loop
pop eax
ret
common_delay_2:
call vret
dec ecx
jnz common_delay_2
ret
Common_delay:
push eax
push edx
mov dx,064h
common_delay1:
in al,dx
dec ecx
jnz common_delay1
pop edx
pop eax
ret
Patch_int: ; Int eax, *ebx()
push ds
push IDT_DSC
pop ds
lea eax,[eax*8]
mov [eax],bx
lea eax,[eax+6]
shr ebx,16
mov [eax],bx
pop ds
ret
Print_Num_c:
jnc Print_num
push eax
mov al,"1"
call print_char
pop eax
Print_Num:
; Prints an unsigned DWORD in EAX.
pusha
push ds
push OS_Data
mov edi,(offset numstring) + 10
pop ds
push 10
xor ecx,ecx
pop ebx
Print_num_loop:
xor edx,edx
div ebx
Print_num_printazero:
add dl,030h
dec edi
mov [edi],dl
xor edx,edx
test eax,eax
jz Print_num_break
jmp Print_num_loop
Print_num_break:
mov esi,edi
call print
pop ds
popa
ret
print_sn:
push esi
mov esi,offset screen_name_color
call print
mov esi,(offset screen_name2);-(offset screen_name_color))
call print
call message_allign
pop esi
ret
domessage:
push esi
push ds
push os_data
pop ds
mov esi,offset os_sn
call print
pop ds
pop esi
call message_allign
call print
call do_crlf
jmp do_crlf ; call do_crlf / ret
message_allign:
push eax
call getcursorpos
mov al,(8+2)
call set_cursor
pop eax
ret
get_flat_addr:
push eax
and eax,0000FFFFh
push Flat_Data
pop ds
and al,011111000b ; assumes GDT
push esi
lea esi,[eax+01002h]
lodsw
shl eax,16
lodsb
mov ah,[esi+2]
rol eax,16
mov esi,eax
pop eax ; old esi
add esi,eax
pop eax
ret
reset:
mov eax,os_data
mov ds,ax
reset1:
in al,060h ; clear keyboard data by reading
in al,64h
test al,3
jnz reset1
mov al,0FEh
out 64h,al
lidt pword ptr ds:[zeros]
db 0Fh,0B9h ; if the shutdown cycle started here doesn't reboot the PC,
; the keyboard reset will get to it probably after it's
; executed the 0Fh,0B9h and stopped dead in its tracks
; because of it's infamous lack of speed. i don't know
; anything about the speed of the ATX shutdown.
; processor freezes here.
pausereset:
pause_reset:
push offset reset
jmp pause ; call pause / jmp reset
pause:
push eax
push ebx
in al,021h
mov bl,al
or al,2
out 021h,al
pause_2:
mov dx,064h
in al,dx
test al,1
jz pause_1
in al,060h
jmp pause_2
pause_1:
call kbd_get_byte
jc pause_1
test al,080h
jnz pause_1
in al,021h
mov al,bl
out 021h,al
pop ebx
pop eax
ret
bold_line:
boldline:
;ah = line to bold. to keep compatibility
; with cursor format that leaves the y part
; in ah.
push eax
push ecx
push edi
push es
push OS_Vram
mov ecx,80
pop es
movzx eax,ah
;edi = eax*80*2
;edi = eax*5*2*2*2*2*2
;edi = 0101b * eax shl 5
shl eax,5
lea edi,[eax+eax*4+1]
bold_loop:
mov al,es:[edi]
or al,0Fh
stosb
inc edi
loop bold_loop
pop es
pop edi
pop ecx
pop eax
ret
redscreen:
red_screen:
push eax
push ds
push PDA
pop ds
mov al,040h;017h
mov ds:[PDA_StdStyle],al
call clearscreen
pop ds
pop eax
ret
clearscreen:
clear_screen:
push es
push eax
push ecx
push edi
push OS_Vram
pop es
push (80*25)
xor edi,edi
pop ecx
push ds
push PDA
pop ds
mov ah,ds:[PDA_StdStyle]
pop ds
mov al,020h
rep stosw
xor ax,ax
call set_cursor
pop edi
pop ecx
pop eax
pop es
ret
print_hex_32:
rol eax,16
call print_hex_16
rol eax,16
jmp print_hex_16 ; call print_hex_16 / ret
print_hex_16:
rol ax,8
call print_hex
rol ax,8
jmp print_hex ; call print_hex / ret
print_hex:
push ds
push OS_Data
pop ds
push eax
push esi
push ebx
push ecx
push offset hex_table
pop ebx
mov ecx,eax
shr al,4
xlat
xchg eax,ecx
and al,0Fh
xlat
mov ch,al
mov eax,ecx
push offset hex_string
pop esi
mov [esi],ax
call print
pop ecx
pop ebx
pop esi
pop eax
pop ds
ret
Download this file.
[ Return to Browse Source Page ]
Copyright 2000, Ed Pizzi