[KERNEL] updated local labels in functions and other small changes

git-svn-id: svn://kolibrios.org@9910 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Doczom 2023-04-08 21:24:05 +00:00
parent fbb49920de
commit cf0e9867b0
11 changed files with 289 additions and 298 deletions

View File

@ -57,7 +57,6 @@ endg
align 4 align 4
pci_api: pci_api:
;cross ;cross
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
@ -76,8 +75,8 @@ else
ja pci_service_not_supported ja pci_service_not_supported
end if end if
call dword [f62call+edx*4] call dword [f62call + edx*4]
mov dword [esp+32], eax mov dword [esp + SYSCALL_STACK.eax], eax
ret ret
@ -90,7 +89,7 @@ pci_api_drv:
cmp eax, 2 cmp eax, 2
ja .fail ja .fail
jmp dword [f62call+eax*4] jmp dword [f62call + eax*4]
.fail: .fail:
or eax, -1 or eax, -1
@ -116,7 +115,7 @@ pci_fn_2:
pci_service_not_supported: pci_service_not_supported:
or eax, -1 or eax, -1
mov dword [esp+32], eax mov dword [esp + SYSCALL_STACK.eax], eax
ret ret
;*************************************************************************** ;***************************************************************************
@ -157,7 +156,7 @@ align 4
pci_read_reg: pci_read_reg:
push ebx esi push ebx esi
cmp [BOOT.pci_data.access_mechanism], 2; what mechanism will we use? cmp [BOOT.pci_data.access_mechanism], 2; what mechanism will we use?
je pci_read_reg_2 je .pci_read_reg_2
; mechanism 1 ; mechanism 1
mov esi, eax ; save register size into ESI mov esi, eax ; save register size into ESI
@ -176,28 +175,29 @@ pci_read_reg:
or dl, bl ; add to port address first 2 bits of register address or dl, bl ; add to port address first 2 bits of register address
or esi, esi or esi, esi
jz pci_read_byte1 jz .byte1
cmp esi, 1 cmp esi, 1
jz pci_read_word1 jz .word1
cmp esi, 2 cmp esi, 2
jz pci_read_dword1 jz .dword1
jmp pci_fin_read1 jmp .fin_read1
pci_read_byte1: .byte1:
in al, dx in al, dx
jmp pci_fin_read1 jmp .fin_read1
pci_read_word1: .word1:
in ax, dx in ax, dx
jmp pci_fin_read1 jmp .fin_read1
pci_read_dword1: .dword1:
in eax, dx in eax, dx
pci_fin_read1: .fin_read1:
pop esi ebx pop esi ebx
ret ret
pci_read_reg_2:
.pci_read_reg_2:
test bh, 128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_read_reg_err jnz .pci_read_reg_err
mov esi, eax ; save register size into ESI mov esi, eax ; save register size into ESI
and esi, 3 and esi, 3
@ -217,27 +217,27 @@ pci_read_reg_2:
mov dx, bx mov dx, bx
or esi, esi or esi, esi
jz pci_read_byte2 jz .byte2
cmp esi, 1 cmp esi, 1
jz pci_read_word2 jz .word2
cmp esi, 2 cmp esi, 2
jz pci_read_dword2 jz .dword2
jmp pci_fin_read2 jmp .fin_read2
pci_read_byte2: .byte2:
in al, dx in al, dx
jmp pci_fin_read2 jmp .fin_read2
pci_read_word2: .word2:
in ax, dx in ax, dx
jmp pci_fin_read2 jmp .fin_read2
pci_read_dword2: .dword2:
in eax, dx in eax, dx
pci_fin_read2: .fin_read2:
pop esi ebx pop esi ebx
ret ret
pci_read_reg_err: .pci_read_reg_err:
xor eax, eax xor eax, eax
dec eax dec eax
pop esi ebx pop esi ebx
@ -281,22 +281,22 @@ pci_write_reg:
mov eax, ecx mov eax, ecx
or esi, esi or esi, esi
jz pci_write_byte1 jz .byte1
cmp esi, 1 cmp esi, 1
jz pci_write_word1 jz .word1
cmp esi, 2 cmp esi, 2
jz pci_write_dword1 jz .dword1
jmp pci_fin_write1 jmp .fin_write1
pci_write_byte1: .byte1:
out dx, al out dx, al
jmp pci_fin_write1 jmp .fin_write1
pci_write_word1: .word1:
out dx, ax out dx, ax
jmp pci_fin_write1 jmp .fin_write1
pci_write_dword1: .dword1:
out dx, eax out dx, eax
pci_fin_write1: .fin_write1:
xor eax, eax xor eax, eax
pop ebx esi pop ebx esi
@ -305,7 +305,7 @@ pci_fin_write1:
pci_write_reg_2: pci_write_reg_2:
test bh, 128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_write_reg_err jnz .pci_write_reg_err
mov esi, eax ; save register size into ESI mov esi, eax ; save register size into ESI
@ -327,28 +327,28 @@ pci_write_reg_2:
mov eax, ecx mov eax, ecx
or esi, esi or esi, esi
jz pci_write_byte2 jz .byte2
cmp esi, 1 cmp esi, 1
jz pci_write_word2 jz .word2
cmp esi, 2 cmp esi, 2
jz pci_write_dword2 jz .dword2
jmp pci_fin_write2 jmp .fin_write2
pci_write_byte2: .byte2:
out dx, al out dx, al
jmp pci_fin_write2 jmp .fin_write2
pci_write_word2: .word2:
out dx, ax out dx, ax
jmp pci_fin_write2 jmp .fin_write2
pci_write_dword2: .dword2:
out dx, eax out dx, eax
pci_fin_write2: .fin_write2:
xor eax, eax xor eax, eax
pop ebx esi pop ebx esi
ret ret
pci_write_reg_err: .pci_write_reg_err:
xor eax, eax xor eax, eax
dec eax dec eax
pop ebx esi pop ebx esi
@ -432,12 +432,12 @@ pci_mmio_map:
or eax, eax or eax, eax
jnz @f jnz @f
mov eax, -3 ; empty I/O space mov eax, -3 ; empty I/O space
jmp mmio_ret_fail jmp .mmio_ret_fail
@@: @@:
test eax, 1 test eax, 1
jz @f jz @f
mov eax, -4 ; damned ports (not MMIO space) mov eax, -4 ; damned ports (not MMIO space)
jmp mmio_ret_fail jmp .mmio_ret_fail
@@: @@:
pop ecx ; ecx = block size, bytes (expanded to whole page) pop ecx ; ecx = block size, bytes (expanded to whole page)
mov ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx mov ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx
@ -445,15 +445,15 @@ pci_mmio_map:
push eax ; store MMIO physical address + keep 2DWords in the stack push eax ; store MMIO physical address + keep 2DWords in the stack
stdcall user_alloc, ecx stdcall user_alloc, ecx
or eax, eax or eax, eax
jnz mmio_map_over jnz .mmio_map_over
mov eax, -5 ; problem with page allocation mov eax, -5 ; problem with page allocation
mmio_ret_fail: .mmio_ret_fail:
pop ecx pop ecx
pop edx pop edx
ret ret
mmio_map_over: .mmio_map_over:
mov ecx, ebx; ecx = size (bytes, expanded to whole page) mov ecx, ebx; ecx = size (bytes, expanded to whole page)
shr ecx, 12 ; ecx = number of pages shr ecx, 12 ; ecx = number of pages
mov ebx, eax; ebx = linear address mov ebx, eax; ebx = linear address
@ -596,16 +596,16 @@ sys_pcibios:
.unsupported_func: .unsupported_func:
mov ah, 0x81 ; FUNC_NOT_SUPPORTED mov ah, 0x81 ; FUNC_NOT_SUPPORTED
.return: .return:
mov dword[esp + 4 ], edi mov dword[esp + SYSCALL_STACK.edi], edi
mov dword[esp + 8], esi mov dword[esp + SYSCALL_STACK.esi], esi
.return_abcd: .return_abcd:
mov dword[esp + 24], edx mov dword[esp + SYSCALL_STACK.edx], edx
.return_abc: .return_abc:
mov dword[esp + 28], ecx mov dword[esp + SYSCALL_STACK.ecx], ecx
.return_ab: .return_ab:
mov dword[esp + 20], ebx mov dword[esp + SYSCALL_STACK.ebx], ebx
.return_a: .return_a:
mov dword[esp + 32], eax mov dword[esp + SYSCALL_STACK.eax], eax
ret ret
proc pci_enum proc pci_enum

View File

@ -936,7 +936,7 @@ sys_IPC:
jb .touch jb .touch
popf popf
mov [esp+32], ebx ;ebx=0 mov [esp + SYSCALL_STACK.eax], ebx ;ebx=0
ret ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -946,11 +946,11 @@ sys_IPC:
jnz @f jnz @f
stdcall sys_ipc_send, ecx, edx, esi stdcall sys_ipc_send, ecx, edx, esi
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
@@: @@:
or eax, -1 or eax, -1
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
@ -1079,22 +1079,22 @@ sysfn_meminfo:
mov eax, [pg_data.pages_count] mov eax, [pg_data.pages_count]
mov [ecx], eax mov [ecx], eax
shl eax, 12 shl eax, 12
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
mov eax, [pg_data.pages_free] mov eax, [pg_data.pages_free]
mov [ecx+4], eax mov [ecx + 4], eax
mov eax, [pg_data.pages_faults] mov eax, [pg_data.pages_faults]
mov [ecx+8], eax mov [ecx + 8], eax
mov eax, [heap_size] mov eax, [heap_size]
mov [ecx+12], eax mov [ecx + 12], eax
mov eax, [heap_free] mov eax, [heap_free]
mov [ecx+16], eax mov [ecx + 16], eax
mov eax, [heap_blocks] mov eax, [heap_blocks]
mov [ecx+20], eax mov [ecx + 20], eax
mov eax, [free_blocks] mov eax, [free_blocks]
mov [ecx+24], eax mov [ecx + 24], eax
ret ret
.fail: .fail:
or dword [esp+32], -1 or dword [esp + SYSCALL_STACK.eax], -1
ret ret
align 4 align 4

View File

@ -76,6 +76,7 @@ update_counters:
sub eax, [esi - sizeof.APPDATA + APPDATA.counter_add] ; time stamp counter add sub eax, [esi - sizeof.APPDATA + APPDATA.counter_add] ; time stamp counter add
add [esi - sizeof.APPDATA + APPDATA.counter_sum], eax ; counter sum add [esi - sizeof.APPDATA + APPDATA.counter_sum], eax ; counter sum
ret ret
align 4 align 4
updatecputimes: updatecputimes:
mov ecx, [thread_count] mov ecx, [thread_count]

View File

@ -525,18 +525,18 @@ destroy_thread:
jb .loop2 jb .loop2
mov ecx, esi ; remove buttons mov ecx, esi ; remove buttons
bnewba2: .bnewba2:
mov edi, [BTN_ADDR] mov edi, [BTN_ADDR]
mov eax, edi mov eax, edi
cld cld
movzx ebx, word [edi] movzx ebx, word [edi]
inc bx inc bx
bnewba: .bnewba:
dec bx dec bx
jz bnmba jz .bnmba
add eax, 0x10 add eax, 0x10
cmp cx, [eax] cmp cx, [eax]
jnz bnewba jnz .bnewba
pusha pusha
mov ecx, ebx mov ecx, ebx
inc ecx inc ecx
@ -546,8 +546,8 @@ destroy_thread:
call memmove call memmove
dec dword [edi] dec dword [edi]
popa popa
jmp bnewba2 jmp .bnewba2
bnmba: .bnmba:
pusha ; save window coordinates for window restoring pusha ; save window coordinates for window restoring
cld cld
@ -662,27 +662,27 @@ destroy_thread:
shl edx, BSF sizeof.APPDATA shl edx, BSF sizeof.APPDATA
mov edx, [SLOT_BASE + edx + APPDATA.tid] mov edx, [SLOT_BASE + edx + APPDATA.tid]
rmpr0: .rmpr0:
mov esi, [RESERVED_PORTS] mov esi, [RESERVED_PORTS]
test esi, esi test esi, esi
jz rmpr9 jz .rmpr9
rmpr3: .rmpr3:
mov edi, esi mov edi, esi
shl edi, 4 shl edi, 4
add edi, RESERVED_PORTS add edi, RESERVED_PORTS
cmp edx, [edi] cmp edx, [edi]
je rmpr4 je .rmpr4
dec esi dec esi
jnz rmpr3 jnz .rmpr3
jmp rmpr9 jmp .rmpr9
rmpr4: .rmpr4:
mov ecx, 256 mov ecx, 256
sub ecx, esi sub ecx, esi
@ -695,9 +695,9 @@ destroy_thread:
dec dword [RESERVED_PORTS] dec dword [RESERVED_PORTS]
jmp rmpr0 jmp .rmpr0
rmpr9: .rmpr9:
popa popa
; clearing APPDATA structure this thread ; clearing APPDATA structure this thread

View File

@ -20,12 +20,12 @@ endg
align 4 align 4
sys_background: sys_background:
cmp ebx, 1 ; BACKGROUND SIZE cmp ebx, 1 ; BACKGROUND SIZE
jnz nosb1 jnz .nosb1
test ecx, ecx test ecx, ecx
jz sbgrr jz .sbgrr
test edx, edx test edx, edx
jz sbgrr jz .sbgrr
;-------------------------------------- ;--------------------------------------
align 4 align 4
@@: @@:
@ -98,13 +98,13 @@ align 4
mov [bgrlock], 0 mov [bgrlock], 0
;-------------------------------------- ;--------------------------------------
align 4 align 4
sbgrr: .sbgrr:
ret ret
;-------------------------------------- ;--------------------------------------
align 4 align 4
nosb1: .nosb1:
cmp ebx, 2 ; SET PIXEL cmp ebx, 2 ; SET PIXEL
jnz nosb2 jnz .nosb2
mov eax, [img_background] mov eax, [img_background]
test ecx, ecx test ecx, ecx
@ -115,8 +115,8 @@ nosb1:
align 4 align 4
@@: @@:
mov ebx, [mem_BACKGROUND] mov ebx, [mem_BACKGROUND]
add ebx, 4095 add ebx, PAGE_SIZE-1
and ebx, -4096 and ebx, -PAGE_SIZE
sub ebx, 4 sub ebx, 4
cmp ecx, ebx cmp ecx, ebx
ja .ret ja .ret
@ -132,7 +132,7 @@ align 4
ret ret
;-------------------------------------- ;--------------------------------------
align 4 align 4
nosb2: .nosb2:
cmp ebx, 3 ; DRAW BACKGROUND cmp ebx, 3 ; DRAW BACKGROUND
jnz nosb3 jnz nosb3
;-------------------------------------- ;--------------------------------------
@ -206,7 +206,7 @@ align 4
cmp [img_background], static_background_data cmp [img_background], static_background_data
jz .nomem jz .nomem
stdcall user_alloc, [mem_BACKGROUND] stdcall user_alloc, [mem_BACKGROUND]
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
test eax, eax test eax, eax
jz .nomem jz .nomem
mov ebx, eax mov ebx, eax
@ -276,14 +276,14 @@ align 4
pop eax pop eax
and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE
stdcall user_free, ebx stdcall user_free, ebx
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
and [bgrlockpid], 0 and [bgrlockpid], 0
mov [bgrlock], 0 mov [bgrlock], 0
ret ret
;-------------------------------------- ;--------------------------------------
align 4 align 4
.err: .err:
and dword [esp+32], 0 and dword [esp + SYSCALL_STACK.eax], 0
ret ret
;------------------------------------- ;-------------------------------------
align 4 align 4
@ -293,17 +293,17 @@ nosb7:
mov ecx, [current_slot] mov ecx, [current_slot]
xor eax, eax xor eax, eax
xchg eax, [ecx+APPDATA.draw_bgr_x] xchg eax, [ecx + APPDATA.draw_bgr_x]
mov [esp + 32], eax ; eax = [left]*65536 + [right] mov [esp + SYSCALL_STACK.eax], eax ; eax = [left]*65536 + [right]
xor eax, eax xor eax, eax
xchg eax, [ecx+APPDATA.draw_bgr_y] xchg eax, [ecx + APPDATA.draw_bgr_y]
mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] mov [esp + SYSCALL_STACK.ebx], eax ; ebx = [top]*65536 + [bottom]
ret ret
;--------------------------------------- ;---------------------------------------
align 4 align 4
nosb8: nosb8:
cmp ebx, 9 cmp ebx, 9
jnz nosb9 jnz .exit
; ecx = [left]*65536 + [right] ; ecx = [left]*65536 + [right]
; edx = [top]*65536 + [bottom] ; edx = [top]*65536 + [bottom]
mov eax, [_display.width] mov eax, [_display.width]
@ -343,10 +343,6 @@ nosb8:
align 4 align 4
.exit: .exit:
ret ret
;--------------------------------------
align 4
nosb9:
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -384,7 +380,7 @@ sys_getbackground: ; sysfn 39
mov eax, [BgrDataWidth] mov eax, [BgrDataWidth]
shl eax, 16 shl eax, 16
mov ax, word [BgrDataHeight] mov ax, word [BgrDataHeight]
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
;--------------------------------------- ;---------------------------------------
align 4 align 4
@ -400,8 +396,8 @@ align 4
align 4 align 4
@@: @@:
mov ebx, [mem_BACKGROUND] mov ebx, [mem_BACKGROUND]
add ebx, 4095 add ebx, PAGE_SIZE-1
and ebx, -4096 and ebx, -PAGE_SIZE
sub ebx, 4 sub ebx, 4
cmp ecx, ebx cmp ecx, ebx
ja .ret ja .ret
@ -409,7 +405,7 @@ align 4
mov eax, [ecx+eax] mov eax, [ecx+eax]
and eax, 0xFFFFFF and eax, 0xFFFFFF
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
align 4 align 4
.ret: .ret:
ret ret
@ -456,8 +452,8 @@ align 4
; check bounds ; check bounds
mov ebx, [mem_BACKGROUND] mov ebx, [mem_BACKGROUND]
add ebx, 4095 add ebx, PAGE_SIZE-1
and ebx, -4096 and ebx, -PAGE_SIZE
sub ebx, 4 sub ebx, 4
add eax, [.subrect_startptr] add eax, [.subrect_startptr]
cmp eax, ebx cmp eax, ebx
@ -495,7 +491,7 @@ align 4
jmp .copy_rect jmp .copy_rect
.end_copy_rect: .end_copy_rect:
xor eax, eax xor eax, eax
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
;-------------------------------------- ;--------------------------------------
align 4 align 4
.fail_39_3: .fail_39_3:
@ -513,7 +509,7 @@ align 4
;-------------------------------------- ;--------------------------------------
align 4 align 4
.nogb4: .nogb4:
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------

View File

@ -480,7 +480,7 @@ sys_getevent: ;; f11
cli ; the right to hope to disable interrupts, as when called from shed cli ; the right to hope to disable interrupts, as when called from shed
call get_event_for_app call get_event_for_app
popfd popfd
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
@ -492,7 +492,7 @@ sys_wait_event_timeout: ;; f23
call unprotect_from_terminate call unprotect_from_terminate
mov edx, get_event_for_app; wait_test mov edx, get_event_for_app; wait_test
call Wait_events_ex ; ebx - timeout call Wait_events_ex ; ebx - timeout
mov [esp+32], eax mov [esp + SYSCALL_STACK.eax], eax
call protect_from_terminate call protect_from_terminate
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------

View File

@ -284,10 +284,10 @@ dd .setSkinUnicode
; out: eax = pack[left, right], ebx = pack[top, bottom] ; out: eax = pack[left, right], ebx = pack[top, bottom]
mov eax, [screen_workarea.left - 2] mov eax, [screen_workarea.left - 2]
mov ax, word[screen_workarea.right] mov ax, word[screen_workarea.right]
mov [esp + 32], eax mov [esp + SYSCALL_STACK.eax], eax
mov eax, [screen_workarea.top - 2] mov eax, [screen_workarea.top - 2]
mov ax, word[screen_workarea.bottom] mov ax, word[screen_workarea.bottom]
mov [esp + 20], eax mov [esp + SYSCALL_STACK.ebx], eax
ret ret
.setScreenWorkingArea: .setScreenWorkingArea:
@ -346,16 +346,16 @@ dd .setSkinUnicode
.getSkinMargins: .getSkinMargins:
; out: eax = pack[left, right], ebx = pack[top, bottom] ; out: eax = pack[left, right], ebx = pack[top, bottom]
mov eax, [_skinmargins + 0] mov eax, [_skinmargins + 0]
mov [esp + 32], eax mov [esp + SYSCALL_STACK.eax], eax
mov eax, [_skinmargins + 4] mov eax, [_skinmargins + 4]
mov [esp + 20], eax mov [esp + SYSCALL_STACK.ebx], eax
ret ret
.setSkin: .setSkin:
; in: ecx -> file path string ; in: ecx -> file path string
mov ebx, ecx mov ebx, ecx
call read_skin_file call read_skin_file
mov [esp + 32], eax mov [esp + SYSCALL_STACK.eax], eax
test eax, eax test eax, eax
jnz .ret jnz .ret
call .calculateScreen call .calculateScreen
@ -364,7 +364,7 @@ dd .setSkinUnicode
.getFontSmoothing: .getFontSmoothing:
xor eax, eax xor eax, eax
mov al, [fontSmoothing] mov al, [fontSmoothing]
mov [esp + 32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
.setFontSmoothing: .setFontSmoothing:
@ -374,7 +374,7 @@ dd .setSkinUnicode
.getFontSize: .getFontSize:
xor eax, eax xor eax, eax
mov al, [fontSize] mov al, [fontSize]
mov [esp + 32], eax mov [esp + SYSCALL_STACK.eax], eax
ret ret
.setFontSize: .setFontSize:
@ -393,7 +393,7 @@ dd .setSkinUnicode
jz @f jz @f
mov ebx, [esp] mov ebx, [esp]
call read_skin_file call read_skin_file
mov [esp + 32 + 4], eax mov [esp + SYSCALL_STACK.eax + 4], eax
@@: @@:
call kernel_free call kernel_free
call .calculateScreen call .calculateScreen
@ -505,7 +505,7 @@ syscall_window_settings:
align 4 align 4
set_window_defaults: set_window_defaults:
mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable mov byte [window_data + sizeof.WDATA + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
push eax ecx push eax ecx
xor eax, eax xor eax, eax
mov ecx, WIN_STACK mov ecx, WIN_STACK
@ -1090,10 +1090,10 @@ align 4
movzx edi, word[WIN_POS + eax * 2] movzx edi, word[WIN_POS + eax * 2]
shl edi, BSF sizeof.WDATA shl edi, BSF sizeof.WDATA
; it is a unused slot? ; it is a unused slot?
cmp byte [edi*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE cmp byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
je @f je @f
; it is a hidden thread? ; it is a hidden thread?
lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] lea esi, [SLOT_BASE + edi*8 + APPDATA.app_name]
cmp [esi], byte '@' cmp [esi], byte '@'
je @f je @f
; is it already minimized? ; is it already minimized?
@ -2548,6 +2548,3 @@ align 4
add esp, 4 ;dword for 0/1 - set_screen/fl_redraw add esp, 4 ;dword for 0/1 - set_screen/fl_redraw
ret ret

View File

@ -61,7 +61,7 @@ draw_mouse_under:
xor ecx, ecx xor ecx, ecx
xor edx, edx xor edx, edx
mres: .mres:
movzx eax, word [X_UNDER] movzx eax, word [X_UNDER]
movzx ebx, word [Y_UNDER] movzx ebx, word [Y_UNDER]
add eax, ecx add eax, ecx
@ -86,11 +86,13 @@ draw_mouse_under:
pop ecx pop ecx
inc ecx inc ecx
cmp ecx, 16 cmp ecx, 16
jnz mres jnz .mres
xor ecx, ecx xor ecx, ecx
inc edx inc edx
cmp edx, 24 cmp edx, 24
jnz mres jnz .mres
popad popad
ret ret
@ -186,7 +188,7 @@ align 4
mov edx, 0 mov edx, 0
;-------------------------------------- ;--------------------------------------
align 4 align 4
drm: .drm:
push eax push eax
push ebx push ebx
push ecx push ecx
@ -243,11 +245,13 @@ drm:
mov eax, [esp+4] ; and x mov eax, [esp+4] ; and x
inc ecx ; +1 cycle inc ecx ; +1 cycle
cmp ecx, 16 ; if more than 16 cmp ecx, 16 ; if more than 16
jnz drm jnz .drm
xor ecx, ecx xor ecx, ecx
inc edx inc edx
cmp edx, 24 cmp edx, 24
jnz drm jnz .drm
add esp, 8 add esp, 8
popad popad
ret ret

View File

@ -17,19 +17,18 @@ $Revision$
; ebx =3 - set alarm-clock ecx - 00SSMMHH ; ebx =3 - set alarm-clock ecx - 00SSMMHH
; out: 0 -Ok 1 -wrong format 2 -battery low ; out: 0 -Ok 1 -wrong format 2 -battery low
sys_settime: sys_settime:
cli cli
mov al, 0x0d mov al, 0x0d
out 0x70, al out 0x70, al
in al, 0x71 in al, 0x71
bt ax, 7 bt ax, 7
jnc bat_low jnc .bat_low
cmp ebx, 2;day of week cmp ebx, 2 ;day of week
jne nosetweek jne .nosetweek
test ecx, ecx ;test day of week test ecx, ecx ;test day of week
je wrongtime je .wrongtime
cmp ecx, 7 cmp ecx, 7
ja wrongtime ja .wrongtime
mov edx, 0x70 mov edx, 0x70
call startstopclk call startstopclk
dec edx dec edx
@ -38,52 +37,52 @@ sys_settime:
inc edx inc edx
mov al, cl mov al, cl
out dx, al out dx, al
jmp endsettime jmp .endsettime
nosetweek: ;set date .nosetweek: ;set date
cmp ebx, 1 cmp ebx, 1
jne nosetdate jne .nosetdate
cmp cl, 0x99;test year cmp cl, 0x99;test year
ja wrongtime ja .wrongtime
shl ecx, 4 shl ecx, 4
cmp cl, 0x90 cmp cl, 0x90
ja wrongtime ja .wrongtime
cmp ch, 0x99;test month cmp ch, 0x99;test month
ja wrongtime ja .wrongtime
shr ecx, 4 shr ecx, 4
test ch, ch test ch, ch
je wrongtime je .wrongtime
cmp ch, 0x12 cmp ch, 0x12
ja wrongtime ja .wrongtime
shl ecx, 8 shl ecx, 8
bswap ecx ;ebx=00YYMMDD bswap ecx ;ebx=00YYMMDD
test cl, cl ;test day test cl, cl ;test day
je wrongtime je .wrongtime
shl ecx, 4 shl ecx, 4
cmp cl, 0x90 cmp cl, 0x90
ja wrongtime ja .wrongtime
shr ecx, 4 shr ecx, 4
cmp ch, 2 ;February cmp ch, 2 ;February
jne testday jne .testday
cmp cl, 0x29 cmp cl, 0x29
ja wrongtime ja .wrongtime
jmp setdate jmp .setdate
testday: .testday:
cmp ch, 8 cmp ch, 8
jb testday1;Aug-Dec jb .testday1 ;Aug-Dec
bt cx, 8 bt cx, 8
jnc days31 jnc .days31
jmp days30 jmp .days30
testday1: .testday1:
bt cx, 8 ;Jan-Jul ex.Feb bt cx, 8 ;Jan-Jul ex.Feb
jnc days30 jnc .days30
days31: .days31:
cmp cl, 0x31 cmp cl, 0x31
ja wrongtime ja .wrongtime
jmp setdate jmp .setdate
days30: .days30:
cmp cl, 0x30 cmp cl, 0x30
ja wrongtime ja .wrongtime
setdate: .setdate:
mov edx, 0x70 mov edx, 0x70
call startstopclk call startstopclk
dec edx dec edx
@ -105,26 +104,26 @@ sys_settime:
shr ecx, 8 shr ecx, 8
mov al, ch mov al, ch
out dx, al out dx, al
jmp endsettime jmp .endsettime
nosetdate: ;set time or alarm-clock .nosetdate: ;set time or alarm-clock
cmp ebx, 3 cmp ebx, 3
ja wrongtime ja .wrongtime
cmp cl, 0x23 cmp cl, 0x23
ja wrongtime ja .wrongtime
cmp ch, 0x59 cmp ch, 0x59
ja wrongtime ja .wrongtime
shl ecx, 4 shl ecx, 4
cmp cl, 0x90 cmp cl, 0x90
ja wrongtime ja .wrongtime
cmp ch, 0x92 cmp ch, 0x92
ja wrongtime ja .wrongtime
shl ecx, 4 shl ecx, 4
bswap ecx ;00HHMMSS bswap ecx ;00HHMMSS
cmp cl, 0x59 cmp cl, 0x59
ja wrongtime ja .wrongtime
shl ecx, 4 shl ecx, 4
cmp cl, 0x90 cmp cl, 0x90
ja wrongtime ja .wrongtime
shr ecx, 4 shr ecx, 4
mov edx, 0x70 mov edx, 0x70
@ -132,7 +131,7 @@ sys_settime:
dec edx dec edx
cmp ebx, 3 cmp ebx, 3
je setalarm je .setalarm
xor eax, eax;al=0-set seconds xor eax, eax;al=0-set seconds
out dx, al out dx, al
inc edx inc edx
@ -151,8 +150,8 @@ sys_settime:
shr ecx, 8 shr ecx, 8
mov al, ch mov al, ch
out dx, al out dx, al
jmp endsettime jmp .endsettime
setalarm: .setalarm:
mov al, 1;set seconds for al. mov al, 1;set seconds for al.
out dx, al out dx, al
inc edx inc edx
@ -178,19 +177,19 @@ sys_settime:
in al, dx in al, dx
bts ax, 5;set bit 5 bts ax, 5;set bit 5
out dx, al out dx, al
endsettime: .endsettime:
dec edx dec edx
call startstopclk call startstopclk
sti sti
and [esp+36-4], dword 0 and [esp + SYSCALL_STACK.eax], dword 0
ret ret
bat_low: .bat_low:
sti sti
mov [esp+36-4], dword 2 mov [esp + SYSCALL_STACK.eax], dword 2
ret ret
wrongtime: .wrongtime:
sti sti
mov [esp+36-4], dword 1 mov [esp + SYSCALL_STACK.eax], dword 1
ret ret
startstopclk: startstopclk:
@ -235,14 +234,11 @@ sys_clock:
movzx edx, al movzx edx, al
add ecx, edx add ecx, edx
sti sti
mov [esp + 32], ecx mov [esp + SYSCALL_STACK.eax], ecx
ret ret
align 4 align 4
sys_date: sys_date:
cli cli
@@: @@:
mov al, 10 mov al, 10
@ -254,7 +250,6 @@ sys_date:
call delay_ms call delay_ms
jmp @b jmp @b
@@: @@:
mov ch, 0 mov ch, 0
mov al, 7 ; date mov al, 7 ; date
out 0x70, al out 0x70, al
@ -270,5 +265,5 @@ sys_date:
in al, 0x71 in al, 0x71
mov cl, al mov cl, al
sti sti
mov [esp+32], ecx mov [esp + SYSCALL_STACK.eax], ecx
ret ret

View File

@ -1363,7 +1363,14 @@ display_number:
; add check pointers ; add check pointers
test bl, bl test bl, bl
jz @f jz @f
stdcall is_region_userspace, ecx, 1 bt ebx, 30 ; check 30 bit
jb @f
stdcall is_region_userspace, ecx, 4
jz @f
ret
@@:
jz @f
stdcall is_region_userspace, ecx, 8
jz @f jz @f
ret ret
@@: @@:
@ -1882,16 +1889,6 @@ sm10:
smn2: smn2:
ret ret
detect_devices:
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;include 'detect/commouse.inc'
;include 'detect/ps2mouse.inc'
;include 'detect/dev_fd.inc'
;include 'detect/dev_hdcd.inc'
;include 'detect/sear_par.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ret
sys_end: sys_end:
;-------------------------------------- ;--------------------------------------
cmp [_display.select_cursor], 0 cmp [_display.select_cursor], 0
@ -2024,27 +2021,27 @@ is_kernel_thread:
sysfn_terminate: ; 18.2 = TERMINATE sysfn_terminate: ; 18.2 = TERMINATE
push ecx push ecx
cmp ecx, 2 cmp ecx, 2
jb noprocessterminate jb .noprocessterminate
mov edx, [thread_count] mov edx, [thread_count]
cmp ecx, edx cmp ecx, edx
ja noprocessterminate ja .noprocessterminate
mov eax, [thread_count] mov eax, [thread_count]
shl ecx, BSF sizeof.APPDATA shl ecx, BSF sizeof.APPDATA
add ecx, SLOT_BASE add ecx, SLOT_BASE
mov edx, [ecx + APPDATA.tid] mov edx, [ecx + APPDATA.tid]
cmp byte [ecx + APPDATA.state], TSTATE_FREE cmp byte [ecx + APPDATA.state], TSTATE_FREE
jz noprocessterminate jz .noprocessterminate
push eax push eax
mov eax, ecx mov eax, ecx
call is_kernel_thread call is_kernel_thread
pop eax pop eax
jz noprocessterminate jz .noprocessterminate
push ecx edx push ecx edx
mov edx, ecx mov edx, ecx
call request_terminate call request_terminate
pop edx ecx pop edx ecx
test eax, eax test eax, eax
jz noprocessterminate jz .noprocessterminate
;-------------------------------------- ;--------------------------------------
; terminate all network sockets it used ; terminate all network sockets it used
pusha pusha
@ -2073,10 +2070,10 @@ sysfn_terminate: ; 18.2 = TERMINATE
;call MEM_Heap_UnLock ;call MEM_Heap_UnLock
cmp edx, [application_table_owner]; clear app table stat cmp edx, [application_table_owner]; clear app table stat
jne noatsc jne .noatsc
call unlock_application_table call unlock_application_table
noatsc: .noatsc:
noprocessterminate: .noprocessterminate:
add esp, 4 add esp, 4
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -2496,7 +2493,7 @@ sys_cachetodiskette:
align 4 align 4
sys_getkey: sys_getkey:
mov [esp + 32], dword 1 mov [esp + SYSCALL_STACK.eax], dword 1
; test main buffer ; test main buffer
mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK
movzx ecx, word [WIN_STACK + ebx * 2] movzx ecx, word [WIN_STACK + ebx * 2]
@ -2688,23 +2685,23 @@ sys_cpuusage:
align 4 align 4
sys_redrawstat: sys_redrawstat:
cmp ebx, 1 cmp ebx, 1
jne no_widgets_away jne .no_widgets_away
; buttons away ; buttons away
mov ecx, [current_slot_idx] mov ecx, [current_slot_idx]
sys_newba2: .sys_newba2:
mov edi, [BTN_ADDR] mov edi, [BTN_ADDR]
cmp [edi], dword 0 ; empty button list ? cmp [edi], dword 0 ; empty button list ?
je end_of_buttons_away je .end_of_buttons_away
movzx ebx, word [edi] movzx ebx, word [edi]
inc ebx inc ebx
mov eax, edi mov eax, edi
sys_newba: .sys_newba:
dec ebx dec ebx
jz end_of_buttons_away jz .end_of_buttons_away
add eax, 0x10 add eax, 0x10
cmp cx, [eax] cmp cx, [eax]
jnz sys_newba jnz .sys_newba
push eax ebx ecx push eax ebx ecx
mov ecx, ebx mov ecx, ebx
@ -2716,16 +2713,15 @@ sys_redrawstat:
dec dword [edi] dec dword [edi]
pop ecx ebx eax pop ecx ebx eax
jmp sys_newba2 jmp .sys_newba2
end_of_buttons_away:
.end_of_buttons_away:
ret ret
no_widgets_away: .no_widgets_away:
cmp ebx, 2 cmp ebx, 2
jnz srl1 jnz .srl1
mov edx, [current_slot_idx] ; return whole screen draw area for this app mov edx, [current_slot_idx] ; return whole screen draw area for this app
shl edx, 5 ;? shl edx, 5 ;?
@ -2739,7 +2735,7 @@ sys_redrawstat:
dec eax dec eax
mov [edx + RECT.bottom], eax mov [edx + RECT.bottom], eax
srl1: .srl1:
ret ret
;ok - 100% work ;ok - 100% work
@ -2878,7 +2874,7 @@ endg
align 4 align 4
checkmisc: checkmisc:
cmp [ctrl_alt_del], 1 cmp [ctrl_alt_del], 1
jne nocpustart jne .nocpustart
mov ebp, cpustring mov ebp, cpustring
call fs_execute_from_sysdir call fs_execute_from_sysdir
@ -2886,9 +2882,9 @@ checkmisc:
mov [ctrl_alt_del], 0 mov [ctrl_alt_del], 0
;-------------------------------------- ;--------------------------------------
align 4 align 4
nocpustart: .nocpustart:
cmp [mouse_active], 1 cmp [mouse_active], 1
jne mouse_not_active jne .mouse_not_active
mov [mouse_active], 0 mov [mouse_active], 0
xor edi, edi xor edi, edi
@ -2942,7 +2938,7 @@ align 4
pop eax pop eax
;-------------------------------------- ;--------------------------------------
align 4 align 4
mouse_not_active: .mouse_not_active:
cmp [REDRAW_BACKGROUND], 0 ; background update ? cmp [REDRAW_BACKGROUND], 0 ; background update ?
jz nobackgr jz nobackgr
@ -3425,18 +3421,18 @@ delay_hs: ; delay in 1/100 secs
mov edx, [timer_ticks] mov edx, [timer_ticks]
;-------------------------------------- ;--------------------------------------
align 4 align 4
newtic: .newtic:
mov ecx, [timer_ticks] mov ecx, [timer_ticks]
sub ecx, edx sub ecx, edx
cmp ecx, ebx cmp ecx, ebx
jae zerodelay jae .zerodelay
call change_task call change_task
jmp newtic jmp .newtic
;-------------------------------------- ;--------------------------------------
align 4 align 4
zerodelay: .zerodelay:
pop edx pop edx
pop ecx pop ecx
ret ret
@ -3527,46 +3523,46 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea
r_f_port_area: r_f_port_area:
test ebx, ebx test ebx, ebx
jnz free_port_area jnz .free_port_area
cmp ecx, edx ; beginning > end ? cmp ecx, edx ; beginning > end ?
ja rpal1 ja .rpal1
cmp edx, 65536 ;test ebx, not 0xffff cmp edx, 65536 ;test ebx, not 0xffff
jae rpal1 jae .rpal1
mov eax, [RESERVED_PORTS] mov eax, [RESERVED_PORTS]
test eax, eax ; no reserved areas ? test eax, eax ; no reserved areas ?
je rpal2 je .rpal2
cmp eax, 255 ; max reserved cmp eax, 255 ; max reserved
jae rpal1 jae .rpal1
rpal3: .rpal3:
mov ebx, eax mov ebx, eax
shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table
add ebx, RESERVED_PORTS add ebx, RESERVED_PORTS
cmp ecx, [ebx+8] cmp ecx, [ebx+8]
ja rpal4 ja .rpal4
cmp edx, [ebx+4] cmp edx, [ebx+4]
jae rpal1 jae .rpal1
rpal4: .rpal4:
dec eax dec eax
jnz rpal3 jnz .rpal3
jmp rpal2 jmp .rpal2
rpal1: .rpal1:
xor eax, eax xor eax, eax
inc eax inc eax
ret ret
rpal2: .rpal2:
; enable port access at port IO map ; enable port access at port IO map
pushad ; start enable io map pushad ; start enable io map
mov eax, ecx mov eax, ecx
xor ebp, ebp ; enable - eax = port xor ebp, ebp ; enable - eax = port
cli cli
new_port_access: .new_port_access:
call set_io_access_rights call set_io_access_rights
inc eax inc eax
cmp eax, edx cmp eax, edx
jbe new_port_access jbe .new_port_access
no_unmask_io: ;no_unmask_io:
sti sti
popad ; end enable io map popad ; end enable io map
@ -3584,31 +3580,31 @@ no_unmask_io:
xor eax, eax xor eax, eax
ret ret
free_port_area: .free_port_area:
mov eax, [RESERVED_PORTS]; no reserved areas ? mov eax, [RESERVED_PORTS]; no reserved areas ?
test eax, eax test eax, eax
jz frpal2 jz .frpal2
mov ebx, [current_slot] mov ebx, [current_slot]
mov ebx, [ebx + APPDATA.tid] mov ebx, [ebx + APPDATA.tid]
frpal3: .frpal3:
mov edi, eax mov edi, eax
shl edi, 4 shl edi, 4
add edi, RESERVED_PORTS add edi, RESERVED_PORTS
cmp ebx, [edi] cmp ebx, [edi]
jne frpal4 jne .frpal4
cmp ecx, [edi+4] cmp ecx, [edi+4]
jne frpal4 jne .frpal4
cmp edx, [edi+8] cmp edx, [edi+8]
jne frpal4 jne .frpal4
jmp frpal1 jmp .frpal1
frpal4: .frpal4:
dec eax dec eax
jnz frpal3 jnz .frpal3
frpal2: .frpal2:
inc eax inc eax
ret ret
frpal1: .frpal1:
push ecx push ecx
mov ecx, 256 mov ecx, 256
sub ecx, eax sub ecx, eax
@ -3627,28 +3623,27 @@ free_port_area:
xor ebp, ebp xor ebp, ebp
inc ebp inc ebp
new_port_access_disable: ; disable - eax = port .new_port_access_disable: ; disable - eax = port
call set_io_access_rights call set_io_access_rights
inc eax inc eax
cmp eax, edx cmp eax, edx
jbe new_port_access_disable jbe .new_port_access_disable
no_mask_io: ; end disable io map ;no_mask_io: ; end disable io map
xor eax, eax xor eax, eax
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
drawbackground: drawbackground:
dbrv20:
cmp [BgrDrawMode], dword 1 cmp [BgrDrawMode], dword 1
jne bgrstr jne .bgrstr
call vesa20_drawbackground_tiled call vesa20_drawbackground_tiled
; call [draw_pointer] ; call [draw_pointer]
call __sys_draw_pointer call __sys_draw_pointer
ret ret
;-------------------------------------- ;--------------------------------------
align 4 align 4
bgrstr: .bgrstr:
call vesa20_drawbackground_stretch call vesa20_drawbackground_stretch
; call [draw_pointer] ; call [draw_pointer]
call __sys_draw_pointer call __sys_draw_pointer
@ -3708,12 +3703,14 @@ sys_putimage_palette:
; edi = pointer to palette ; edi = pointer to palette
; ebp = row delta ; ebp = row delta
; check pointer ; check pointer
push ecx push ecx esi
mov ax, cx mov ax, cx
shr ecx, 16 shr ecx, 16
imul eax, ecx imul eax, ecx
; imul eax, esi ; eax*count bit in 1 pixel
; shr eax, 3
stdcall is_region_userspace, ebx, eax stdcall is_region_userspace, ebx, eax
pop ecx pop esi ecx
jnz sys_putimage.exit jnz sys_putimage.exit
mov eax, [current_slot] mov eax, [current_slot]
@ -4078,10 +4075,10 @@ kb_write_wait_ack:
if used _rdtsc if used _rdtsc
_rdtsc: _rdtsc:
bt [cpu_caps], CAPS_TSC bt [cpu_caps], CAPS_TSC
jnc ret_rdtsc jnc .ret_rdtsc
rdtsc rdtsc
ret ret
ret_rdtsc: .ret_rdtsc:
mov edx, 0xffffffff mov edx, 0xffffffff
mov eax, 0xffffffff mov eax, 0xffffffff
ret ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; PLAYNOTE.INC version 1.1 22 November 2003 ;; ;; PLAYNOTE.INC version 1.1 22 November 2003 ;;
@ -22,21 +22,21 @@ align 4
sound_interface: sound_interface:
cmp eax, ebx ; this is subfunction #55 ? cmp eax, ebx ; this is subfunction #55 ?
jne retFunc55 ; if no then return. jne .ret ; if no then return.
cmp byte [sound_flag], 0 cmp byte [sound_flag], 0
jne retFunc55 jne .ret
movzx eax, byte [countDelayNote] movzx eax, byte [countDelayNote]
or al, al ; player is busy ? or al, al ; player is busy ?
jnz retFunc55 ; return counter delay Note jnz .ret ; return counter delay Note
mov [memAdrNote], esi;edx mov [memAdrNote], esi;edx
call get_pid call get_pid
mov [pidProcessNote], eax mov [pidProcessNote], eax
xor eax, eax ; Ok! EAX = 0 xor eax, eax ; Ok! EAX = 0
retFunc55: .ret:
mov [esp+32], eax ; return value EAX for application mov [esp + SYSCALL_STACK.eax], eax ; return value EAX for application
ret ret
iglobal iglobal
@ -55,41 +55,41 @@ playNote:
; jmp NotPlayNotes ; jmp NotPlayNotes
mov esi, [memAdrNote] mov esi, [memAdrNote]
or esi, esi ; ESI = 0 ? - OFF Notes Play ? or esi, esi ; ESI = 0 ? - OFF Notes Play ?
jz NotPlayNotes ; if ESI = 0 -> ignore play pocedure jz .NotPlayNotes ; if ESI = 0 -> ignore play pocedure
cmp eax, [count_timer_Note] cmp eax, [count_timer_Note]
jb NotPlayNotes jb .NotPlayNotes
push eax push eax
inc eax inc eax
mov [count_timer_Note], eax mov [count_timer_Note], eax
mov al, [countDelayNote] mov al, [countDelayNote]
dec al ; decrement counter Delay for Playing Note dec al ; decrement counter Delay for Playing Note
jz NewLoadNote@Delay jz .NewLoadNote@Delay
cmp al, 0xFF ; this is first Note Play ? cmp al, 0xFF ; this is first Note Play ?
jne NextDelayNote jne .NextDelayNote
;This is FIRST Note, save counter channel 2 chip 8253 ;This is FIRST Note, save counter channel 2 chip 8253
mov al, 0xB6 ; control byte to timer chip 8253 mov al, 0xB6 ; control byte to timer chip 8253
out 0x43, al ; Send it to the control port chip 8253 out 0x43, al ; Send it to the control port chip 8253
in al, 0x42 ; Read Lower byte counter channel 2 chip 8253 in al, 0x42 ; Read Lower byte counter channel 2 chip 8253
mov ah, al ; AH = Lower byte counter channel 2 mov ah, al ; AH = Lower byte counter channel 2
in al, 0x42 ; Read Upper byte counter channel 2 chip 8253 in al, 0x42 ; Read Upper byte counter channel 2 chip 8253
mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253 mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253
NewLoadNote@Delay: .NewLoadNote@Delay:
cld cld
; lodsb ; load AL - counter Delay ; lodsb ; load AL - counter Delay
call ReadNoteByte call ReadNoteByte
or al, al ; THE END ? or al, al ; THE END ?
jz EndPlayNote jz .EndPlayNote
cmp al, 0x81 cmp al, 0x81
jnc NoteforOctave jnc .NoteforOctave
mov [countDelayNote], al mov [countDelayNote], al
; lodsw ; load AX - counter for Note! ; lodsw ; load AX - counter for Note!
call ReadNoteByte call ReadNoteByte
mov ah, al mov ah, al
call ReadNoteByte call ReadNoteByte
xchg al, ah xchg al, ah
jmp pokeNote jmp .pokeNote
EndPlayNote: ; THE END Play Notes! .EndPlayNote: ; THE END Play Notes!
in al, 0x61 ; Get contents of system port B chip 8255 in al, 0x61 ; Get contents of system port B chip 8255
and al, 0xFC ; Turn OFF timer and speaker and al, 0xFC ; Turn OFF timer and speaker
out 0x61, al ; Send out new values to port B chip 8255 out 0x61, al ; Send out new values to port B chip 8255
@ -100,25 +100,25 @@ playNote:
out 0x42, al ; restore Upper byte channel 2 out 0x42, al ; restore Upper byte channel 2
xor eax, eax ; EAX = 0 xor eax, eax ; EAX = 0
mov [memAdrNote], eax; clear header control Delay-Note string mov [memAdrNote], eax; clear header control Delay-Note string
NextDelayNote: .NextDelayNote:
mov [countDelayNote], al; save new counter delay Note mov [countDelayNote], al; save new counter delay Note
pop eax pop eax
NotPlayNotes: .NotPlayNotes:
RET ret
NoteforOctave: .NoteforOctave:
sub al, 0x81 ; correction value for delay Note sub al, 0x81 ; correction value for delay Note
mov [countDelayNote], al; save counter delay this new Note mov [countDelayNote], al; save counter delay this new Note
; lodsb ; load pack control code ; lodsb ; load pack control code
call ReadNoteByte call ReadNoteByte
cmp al, 0xFF ; this is PAUSE ? cmp al, 0xFF ; this is PAUSE ?
jne packCode ; no, this is PACK CODE jne .packCode ; no, this is PACK CODE
in al, 0x61 ; Get contents of system port B chip 8255 in al, 0x61 ; Get contents of system port B chip 8255
and al, 0xFC ; Turn OFF timer and speaker and al, 0xFC ; Turn OFF timer and speaker
out 0x61, al ; Send out new values to port B chip 8255 out 0x61, al ; Send out new values to port B chip 8255
jmp saveESI jmp .saveESI
packCode: .packCode:
mov cl, al ; save code mov cl, al ; save code
and al, 0xF ; clear upper bits and al, 0xF ; clear upper bits
dec al ; correction dec al ; correction
@ -128,17 +128,18 @@ playNote:
mov ax, [eax] ; read constant mov ax, [eax] ; read constant
shr cl, 4 ; transform for number Octave shr cl, 4 ; transform for number Octave
shr ax, cl ; calculate from Note this Octave! shr ax, cl ; calculate from Note this Octave!
pokeNote: .pokeNote:
out 0x42, al ; Lower byte Out to channel 2 timer chip 8253 out 0x42, al ; Lower byte Out to channel 2 timer chip 8253
mov al, ah mov al, ah
out 0x42, al ; Upper byte Out to channel 2 timer chip 8253 out 0x42, al ; Upper byte Out to channel 2 timer chip 8253
in al, 0x61 ; Get contents of system port B chip 8255 in al, 0x61 ; Get contents of system port B chip 8255
or al, 3 ; Turn ON timer and speaker or al, 3 ; Turn ON timer and speaker
out 0x61, al ; Send out new values to port B chip 8255 out 0x61, al ; Send out new values to port B chip 8255
saveESI: .saveESI:
; mov [memAdrNote], esi ; save new header control Delay-Note string ; mov [memAdrNote], esi ; save new header control Delay-Note string
pop eax pop eax
RET ret
ReadNoteByte: ReadNoteByte:
;result: ;result:
; al - note ; al - note