From a77e7ee15d81090cd8bf0d017aa4b0ad6678278d Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Tue, 4 Jun 2013 11:14:37 +0000 Subject: [PATCH] make macro for push imm/pop dst git-svn-id: svn://kolibrios.org@3598 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/disk.inc | 12 +++---- kernel/trunk/blkdev/rd.inc | 15 +++------ .../extended_primary_loader/cdfs/bootsect.asm | 3 +- kernel/trunk/bus/pci/pci32.inc | 3 +- kernel/trunk/bus/usb/ehci.inc | 33 +++++++------------ kernel/trunk/bus/usb/hccommon.inc | 3 +- kernel/trunk/bus/usb/hub.inc | 3 +- kernel/trunk/bus/usb/init.inc | 3 +- kernel/trunk/bus/usb/ohci.inc | 18 ++++------ kernel/trunk/bus/usb/scheduler.inc | 18 ++++------ kernel/trunk/bus/usb/uhci.inc | 21 ++++-------- kernel/trunk/core/sys32.inc | 3 +- kernel/trunk/core/timers.inc | 3 +- kernel/trunk/drivers/fdo.inc | 17 ++++++++-- kernel/trunk/drivers/usbhid.asm | 9 ++--- kernel/trunk/drivers/usbstor.asm | 15 +++------ kernel/trunk/fdo.inc | 3 +- kernel/trunk/fs/fat12.inc | 9 ++--- kernel/trunk/fs/fat32.inc | 33 +++++++------------ kernel/trunk/fs/ntfs.inc | 21 ++++-------- kernel/trunk/hid/keyboard.inc | 3 +- kernel/trunk/kernel.asm | 6 ++-- kernel/trunk/macros.inc | 13 ++++++++ kernel/trunk/network/tcp.inc | 3 +- .../sec_loader/trunk/boot/cdfs/bootsect.asm | 3 +- 25 files changed, 109 insertions(+), 164 deletions(-) diff --git a/kernel/trunk/blkdev/disk.inc b/kernel/trunk/blkdev/disk.inc index 094ecc790f..356f3d8226 100644 --- a/kernel/trunk/blkdev/disk.inc +++ b/kernel/trunk/blkdev/disk.inc @@ -335,8 +335,7 @@ disk_add: push ebx esi ; save used registers to be stdcall ; 1. Allocate the DISK structure. ; 1a. Call the heap manager. - push sizeof.DISK - pop eax + movi eax, sizeof.DISK call malloc ; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0. test eax, eax @@ -608,15 +607,13 @@ disk_call_driver: ; The default implementation of DISKFUNC.querymedia. disk_default_querymedia: - push DISK_STATUS_INVALID_CALL - pop eax + movi eax, DISK_STATUS_INVALID_CALL ret 8 ; The default implementation of DISKFUNC.read and DISKFUNC.write. disk_default_read: disk_default_write: - push DISK_STATUS_INVALID_CALL - pop eax + movi eax, DISK_STATUS_INVALID_CALL ret 20 ; The default implementation of DISKFUNC.close, DISKFUNC.closemedia and @@ -1002,8 +999,7 @@ end virtual jnz .success ; 3. No file system has recognized the volume, so just allocate the PARTITION ; structure without extra fields. - push sizeof.PARTITION - pop eax + movi eax, sizeof.PARTITION call malloc test eax, eax jz .nothing diff --git a/kernel/trunk/blkdev/rd.inc b/kernel/trunk/blkdev/rd.inc index e67f65757e..b4ca7a296c 100644 --- a/kernel/trunk/blkdev/rd.inc +++ b/kernel/trunk/blkdev/rd.inc @@ -1252,8 +1252,7 @@ fat_gen_short_name: stosd pop edi xor eax, eax - push 8 - pop ebx + movi ebx, 8 lea ecx, [edi+8] .loop: lodsb @@ -1538,8 +1537,7 @@ fs_RamdiskRewrite: push ecx edi mov ecx, 8 repnz scasb - push 1 - pop eax ; 1 entry + movi eax, 1 ; 1 entry jnz .notilde ; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total xor eax, eax @@ -1764,8 +1762,7 @@ fs_RamdiskRewrite: add esp, 20 mov [esp+16], ebx popad - push ERROR_DISK_FULL - pop eax + movi eax, ERROR_DISK_FULL ret .writedir: mov edi, eax @@ -1957,8 +1954,7 @@ ramdisk_extend_file: jb @b .fat_err: pop ecx - push ERROR_FAT_TABLE - pop eax + movi eax, ERROR_FAT_TABLE stc ret @@: @@ -2033,8 +2029,7 @@ ramdisk_extend_file: pop edi ecx pop esi edx stc - push ERROR_DISK_FULL - pop eax + movi eax, ERROR_DISK_FULL ret fat_update_datetime: diff --git a/kernel/trunk/bootloader/extended_primary_loader/cdfs/bootsect.asm b/kernel/trunk/bootloader/extended_primary_loader/cdfs/bootsect.asm index 4694e005e8..64c9f01a58 100644 --- a/kernel/trunk/bootloader/extended_primary_loader/cdfs/bootsect.asm +++ b/kernel/trunk/bootloader/extended_primary_loader/cdfs/bootsect.asm @@ -50,8 +50,7 @@ real_start: ; get file system information ; scan for Primary Volume Descriptor db 66h - push 10h-1 - pop eax + movi eax, 10h-1 pvd_scan_loop: mov cx, 1 inc eax diff --git a/kernel/trunk/bus/pci/pci32.inc b/kernel/trunk/bus/pci/pci32.inc index 3604c54c08..599525b241 100644 --- a/kernel/trunk/bus/pci/pci32.inc +++ b/kernel/trunk/bus/pci/pci32.inc @@ -680,8 +680,7 @@ end virtual jmp .no_device .has_device: push eax - push sizeof.PCIDEV - pop eax + movi eax, sizeof.PCIDEV call malloc pop ecx test eax, eax diff --git a/kernel/trunk/bus/usb/ehci.inc b/kernel/trunk/bus/usb/ehci.inc index b39f3504b1..15dd3f1e1d 100644 --- a/kernel/trunk/bus/usb/ehci.inc +++ b/kernel/trunk/bus/usb/ehci.inc @@ -330,8 +330,7 @@ end if ; 2b. Fill first 32 entries. inc eax inc eax ; set Type to EHCI_TYPE_QH - push 32 - pop ecx + movi ecx, 32 mov edx, ecx @@: stosd @@ -434,14 +433,12 @@ end if ; now edi = MMIOBase2 ; 6. Transfer the controller to a known state. ; 6b. Stop the controller if it is running. - push 10 - pop ecx + movi ecx, 10 test dword [edi+EhciStatusReg], 1 shl 12 jnz .stopped and dword [edi+EhciCommandReg], not 1 @@: - push 1 - pop esi + movi esi, 1 call delay_ms test dword [edi+EhciStatusReg], 1 shl 12 jnz .stopped @@ -451,11 +448,9 @@ end if .stopped: ; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms. or dword [edi+EhciCommandReg], 2 - push 50 - pop ecx + movi ecx, 50 @@: - push 1 - pop esi + movi esi, 1 call delay_ms test dword [edi+EhciCommandReg], 2 jz .reset_ok @@ -515,8 +510,7 @@ end if test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h jz @f push esi - push 20 - pop esi + movi esi, 20 call delay_ms pop esi @@: @@ -676,8 +670,7 @@ proc ehci_kickoff_bios test al, 1 jz .has_ownership push esi - push 1 - pop esi + movi esi, 1 call delay_ms pop esi dec dword [esp] @@ -862,8 +855,7 @@ end virtual push eax ecx sub edi, ehci_pipe.SoftwarePart xor eax, eax - push ehci_pipe.SoftwarePart/4 - pop ecx + movi ecx, ehci_pipe.SoftwarePart/4 rep stosd pop ecx eax ; 2. Setup PID in the first TD and make sure that the it is not active. @@ -883,8 +875,7 @@ end virtual and eax, 3FFF0000h ; Use 1 requests per microframe for control/bulk endpoints, ; use value from the endpoint descriptor for periodic endpoints - push 1 - pop edx + movi edx, 1 test [.type], 1 jz @f mov edx, [.maxpacket] @@ -1292,8 +1283,7 @@ proc ehci_port_init @@: ; 3. Call the worker procedure to notify the protocol layer ; about new EHCI device. It is high-speed. - push USB_SPEED_HS - pop eax + movi eax, USB_SPEED_HS call ehci_new_device test eax, eax jnz .nothing @@ -1794,8 +1784,7 @@ proc ehci_process_updated_td ; all corresponding bits are set. In this case, return some error code, ; the order is quite arbitrary. pop eax ; status - push USB_STATUS_UNDERRUN - pop ecx + movi ecx, USB_STATUS_UNDERRUN test al, 40h ; not Halted? jz .know_error mov cl, USB_STATUS_OVERRUN diff --git a/kernel/trunk/bus/usb/hccommon.inc b/kernel/trunk/bus/usb/hccommon.inc index 05dc309770..9735aa9eec 100644 --- a/kernel/trunk/bus/usb/hccommon.inc +++ b/kernel/trunk/bus/usb/hccommon.inc @@ -398,8 +398,7 @@ proc usb_process_wait_lists jnc @f or byte [esp], 1 shl CONTROL_PIPE @@: - push 4 - pop edx + movi edx, 4 call usb_process_one_wait_list jnc @f or byte [esp], 1 shl INTERRUPT_PIPE diff --git a/kernel/trunk/bus/usb/hub.inc b/kernel/trunk/bus/usb/hub.inc index 403d59a4e6..25ffe1d510 100644 --- a/kernel/trunk/bus/usb/hub.inc +++ b/kernel/trunk/bus/usb/hub.inc @@ -253,8 +253,7 @@ end virtual ; 2a. Save registers. push edx ; 2b. Call the allocator. - push 40 - pop eax + movi eax, 40 call malloc ; 2c. Restore registers. pop ecx diff --git a/kernel/trunk/bus/usb/init.inc b/kernel/trunk/bus/usb/init.inc index d18d936be4..d43f94910e 100644 --- a/kernel/trunk/bus/usb/init.inc +++ b/kernel/trunk/bus/usb/init.inc @@ -131,8 +131,7 @@ endg proc create_usb_thread ; 1. Create the thread. push edi - push 1 - pop ebx + movi ebx, 1 mov ecx, usb_thread_proc xor edx, edx call new_sys_threads diff --git a/kernel/trunk/bus/usb/ohci.inc b/kernel/trunk/bus/usb/ohci.inc index f08ba4124a..8f3bb3c0c6 100644 --- a/kernel/trunk/bus/usb/ohci.inc +++ b/kernel/trunk/bus/usb/ohci.inc @@ -351,8 +351,7 @@ end if lea esi, [eax+ohci_controller.IntEDs+32*sizeof.ohci_static_ep] call get_pg_addr add eax, ohci_controller.IntEDs - push 32 - pop ecx + movi ecx, 32 mov edx, ecx @@: stosd @@ -429,10 +428,8 @@ end if ; 5c. Save FmInterval register. pushd [edi+OhciFmIntervalReg] ; 5d. Issue software reset and wait up to 10ms, checking status every 1 ms. - push 1 - pop ecx - push 10 - pop edx + movi ecx, 1 + movi edx, 10 mov [edi+OhciCommandStatusReg], ecx @@: mov esi, ecx @@ -633,14 +630,12 @@ proc ohci_kickoff_bios ; (This should generate SMI, BIOS should release its ownership in SMI handler.) mov dword [eax+OhciCommandStatusReg], 8 ; 4c. Wait for result no more than 50 ms, checking for status every 1 ms. - push 50 - pop ecx + movi ecx, 50 @@: test dword [eax+OhciControlReg], edx jz .has_ownership push esi - push 1 - pop esi + movi esi, 1 call delay_ms pop esi loop @b @@ -984,8 +979,7 @@ end virtual ; if so, return an error. lea edx, [esi + ohci_controller.IntEDs - sizeof.ohci_controller] lea eax, [esi + ohci_controller.IntEDs + 32*sizeof.ohci_static_ep - sizeof.ohci_controller] - push 64 - pop ecx + movi ecx, 64 call usb1_select_interrupt_list test edx, edx jz .return0 diff --git a/kernel/trunk/bus/usb/scheduler.inc b/kernel/trunk/bus/usb/scheduler.inc index 933eb9cbee..b09a9aa810 100644 --- a/kernel/trunk/bus/usb/scheduler.inc +++ b/kernel/trunk/bus/usb/scheduler.inc @@ -206,8 +206,7 @@ end virtual sub ecx, 3 cmp ecx, 5 ; maximum 32ms jbe @f - push 5 - pop ecx + movi ecx, 5 @@: ; There are four nested loops, ; * Loop #4 (the innermost one) calculates the total periodic bandwidth @@ -221,10 +220,8 @@ end virtual ; ebx = number of iterations of loop #1 ; [esp] = delta of counter for loop #3, in bytes ; [esp+4] = delta between the first group and the target group, in bytes - push 1 - pop ebx - push sizeof.ehci_static_ep - pop edx + movi ebx, 1 + movi edx, sizeof.ehci_static_ep shl ebx, cl shl edx, cl mov eax, 64*sizeof.ehci_static_ep @@ -282,8 +279,7 @@ end virtual ja @f mov [.bandwidth], edi mov [.target], edx - push 1 - pop eax + movi eax, 1 shl eax, cl mov [.targetsmask], eax @@: @@ -317,8 +313,7 @@ end virtual mov ecx, [.targetsmask] add [edx+ehci_static_ep.Bandwidths+ecx*2], ax add edx, ehci_static_ep.SoftwarePart - push 1 - pop eax + movi eax, 1 shl eax, cl pop edi ebx ; restore used registers to be stdcall ret @@ -371,8 +366,7 @@ virtual at esp end virtual ; 10. Select the best variant. ; edx = S-Mask = bitmask of scheduled microframes - push 0x11 - pop edx + movi edx, 0x11 cmp ecx, 1 ja @f mov dl, 0x55 diff --git a/kernel/trunk/bus/usb/uhci.inc b/kernel/trunk/bus/usb/uhci.inc index 06360fc9d7..960500b60d 100644 --- a/kernel/trunk/bus/usb/uhci.inc +++ b/kernel/trunk/bus/usb/uhci.inc @@ -315,8 +315,7 @@ end if ; 2b. Fill first 32 entries. inc eax inc eax ; set QH bit for uhci_pipe.NextQH - push 32 - pop ecx + movi ecx, 32 mov edx, ecx @@: stosd @@ -416,12 +415,10 @@ end if mov ax, 2 out dx, ax ; 5f. Wait up to 10ms. - push 10 - pop ecx + movi ecx, 10 @@: push esi - push 1 - pop esi + movi esi, 1 call delay_ms pop esi in ax, dx @@ -435,8 +432,7 @@ if 0 ; emergency variant for tests - always wait 10 ms ; wait 10 ms push esi - push 10 - pop esi + movi esi, 10 call delay_ms pop esi ; clear reset signal @@ -998,8 +994,7 @@ end if ; * if several non-fatal errors have occured during transaction retries, ; all corresponding bits are set. In this case, return some error code, ; the order is quite arbitrary. - push USB_STATUS_UNDERRUN - pop ecx + movi ecx, USB_STATUS_UNDERRUN test al, 1 shl (22-16) ; not Stalled? jz .know_error mov cl, USB_STATUS_OVERRUN @@ -1260,8 +1255,7 @@ proc uhci_port_reset_done ; 2. Status bits in UHCI are invalid during reset signalling. ; Wait a millisecond while status bits become valid again. push esi - push 1 - pop esi + movi esi, 1 call delay_ms pop esi ; 3. ConnectStatus bit is zero during reset and becomes 1 during step 2; @@ -1458,8 +1452,7 @@ end virtual ; if so, return an error. lea edx, [esi + uhci_controller.IntEDs - sizeof.uhci_controller] lea eax, [esi + uhci_controller.IntEDs + 32*sizeof.uhci_static_ep - sizeof.uhci_controller] - push 64 - pop ecx + movi ecx, 64 call usb1_select_interrupt_list test edx, edx jz .return0 diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 1f3b4837b4..a39b082694 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -504,8 +504,7 @@ terminate: ; terminate application mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] test eax, eax jz .nodebug - push 8 - pop ecx + movi ecx, 8 push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID push 2 call debugger_notify diff --git a/kernel/trunk/core/timers.inc b/kernel/trunk/core/timers.inc index ecf62e1ddd..33797fb4c8 100644 --- a/kernel/trunk/core/timers.inc +++ b/kernel/trunk/core/timers.inc @@ -82,8 +82,7 @@ proc timer_hs stdcall uses ebx, deltaStart:dword, interval:dword, \ timerFunc:dword, userData:dword ; 1. Allocate memory for the TIMER structure. ; 1a. Call the allocator. - push sizeof.TIMER - pop eax + movi eax, sizeof.TIMER call malloc ; 1b. If allocation failed, return (go to 5) with eax = 0. test eax, eax diff --git a/kernel/trunk/drivers/fdo.inc b/kernel/trunk/drivers/fdo.inc index d7dff6ff5b..c42cefa30d 100644 --- a/kernel/trunk/drivers/fdo.inc +++ b/kernel/trunk/drivers/fdo.inc @@ -19,6 +19,20 @@ ; __DEBUG__ equ 1 ; __DEBUG_LEVEL__ equ 5 +; MOV Immediate. +; Useful for things like movi eax,10: +; shorter than regular mov, but slightly slower, +; do not use it in performance-critical places. +macro movi dst, imm +{ +if imm >= -0x80 & imm <= 0x7F + push imm + pop dst +else + mov dst, imm +end if +} + macro debug_func name { if used name name@of@func equ name @@ -273,8 +287,7 @@ debug_beginf call fdo_debug_outchar pop eax @@: - push 10 - pop ecx + movi ecx, 10 push -'0' .l1: xor edx, edx diff --git a/kernel/trunk/drivers/usbhid.asm b/kernel/trunk/drivers/usbhid.asm index cc997a1cd0..eb9abc9775 100644 --- a/kernel/trunk/drivers/usbhid.asm +++ b/kernel/trunk/drivers/usbhid.asm @@ -234,8 +234,7 @@ AddDevice: ; 8 bytes for a packet and 8 bytes for previous packet, used by a keyboard. ; 9. Initialize device data. mov [ebx+device_data.intpipe], eax - push 8 - pop ecx + movi ecx, 8 cmp edx, ecx jb @f mov edx, ecx @@ -364,8 +363,7 @@ keyboard_data_ready: jb .controlloop .nocontrol: ; 3. Initialize before loop for normal keys. esi = index. - push 2 - pop esi + movi esi, 2 .normalloop: ; 4. Process one key which was pressed in the previous packet. ; 4a. Get the next pressed key from the previous packet. @@ -486,8 +484,7 @@ keyboard_data_ready: ; Auxiliary procedure for keyboard_data_ready. haskey: - push 2 - pop edx + movi edx, 2 @@: cmp byte [ecx+edx], al jz @f diff --git a/kernel/trunk/drivers/usbstor.asm b/kernel/trunk/drivers/usbstor.asm index 4ecdfcde46..e72d1a8bae 100644 --- a/kernel/trunk/drivers/usbstor.asm +++ b/kernel/trunk/drivers/usbstor.asm @@ -298,8 +298,7 @@ virtual at esp .UserData dd ? ; request_queue_item.UserData end virtual ; 1. Allocate the memory for the request description. - push request_queue_item.sizeof - pop eax + movi eax, request_queue_item.sizeof call Kmalloc test eax, eax jnz @f @@ -1004,10 +1003,8 @@ proc inquiry_callback ; 4. Thus, create a temporary kernel thread which would do it. mov edx, [esp+8] push ebx ecx - push 51 - pop eax - push 1 - pop ebx + movi eax, 51 + movi ebx, 1 mov ecx, new_disk_thread ; edx = parameter int 0x40 @@ -1069,8 +1066,7 @@ end virtual cmp [edx+usb_unit_data.UnitReadyAttempts], 3 jz @f push ecx edx esi - push 10 - pop esi + movi esi, 10 call Sleep pop esi edx ecx stdcall queue_request, ecx, test_unit_ready_req, 0, test_unit_ready_callback, edx @@ -1124,8 +1120,7 @@ end virtual mov byte [edi-1], 'd' push eax push -'0' - push 10 - pop ecx + movi ecx, 10 @@: cdq div ecx diff --git a/kernel/trunk/fdo.inc b/kernel/trunk/fdo.inc index b2b29e3b69..fa720ace5e 100644 --- a/kernel/trunk/fdo.inc +++ b/kernel/trunk/fdo.inc @@ -278,8 +278,7 @@ debug_beginf call fdo_debug_outchar pop eax @@: - push 10 - pop ecx + movi ecx, 10 push -'0' .l1: xor edx, edx diff --git a/kernel/trunk/fs/fat12.inc b/kernel/trunk/fs/fat12.inc index 8d46af49af..114ce88f92 100644 --- a/kernel/trunk/fs/fat12.inc +++ b/kernel/trunk/fs/fat12.inc @@ -1311,8 +1311,7 @@ fs_FloppyRewrite: push ecx edi mov ecx, 8 repnz scasb - push 1 - pop eax ; 1 entry + movi eax, 1 ; 1 entry jnz .notilde ; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total xor eax, eax @@ -1822,8 +1821,7 @@ floppy_extend_file: jb @b .fat_err: pop ecx - push ERROR_FAT_TABLE - pop eax + movi eax, ERROR_FAT_TABLE stc ret @@: @@ -1885,8 +1883,7 @@ floppy_extend_file: pop edi ecx pop esi edx stc - push ERROR_DISK_FULL - pop eax + movi eax, ERROR_DISK_FULL ret ;---------------------------------------------------------------- diff --git a/kernel/trunk/fs/fat32.inc b/kernel/trunk/fs/fat32.inc index 35db54c14c..11c2b1159a 100644 --- a/kernel/trunk/fs/fat32.inc +++ b/kernel/trunk/fs/fat32.inc @@ -167,8 +167,7 @@ fat_create_partition: ; in the normal operation, let's hope for the best and allocate data now; if ; it will prove wrong, just deallocate it. push ebx - push sizeof.FAT - pop eax + movi eax, sizeof.FAT call malloc pop ebx test eax, eax @@ -972,8 +971,7 @@ fs_HdReadFolder: jz ntfs_HdReadFolder cmp [fs_type], 2 jz ext2_HdReadFolder - push ERROR_UNSUPPORTED_FS - pop eax + movi eax, ERROR_UNSUPPORTED_FS or ebx, -1 ret @@: @@ -1659,8 +1657,7 @@ fat_Rewrite: push ecx edi mov ecx, 8 repnz scasb - push 1 - pop eax ; 1 entry + movi eax, 1 ; 1 entry jnz .notilde ; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total xor eax, eax @@ -2362,8 +2359,7 @@ hd_extend_file: jmp .device_err2 .disk_full: pop eax edx esi - push ERROR_DISK_FULL - pop eax + movi eax, ERROR_DISK_FULL stc ret @@ -2390,8 +2386,7 @@ fs_HdSetFileEnd: jz ntfs_HdSetFileEnd cmp [fs_type], 2 jz ext2_HdSetFileEnd - push ERROR_UNKNOWN_FS - pop eax + movi eax, ERROR_UNKNOWN_FS ret @@: sub ebx, 4 @@ -2566,8 +2561,7 @@ fat_SetFileEnd: pop eax ecx eax edi call update_disk call fat_unlock - push ERROR_DEVICE - pop eax + movi eax, ERROR_DEVICE ret @@: ; we will zero data at the end of last sector - remember it @@ -2640,8 +2634,7 @@ fat_SetFileEnd: pop eax ecx eax edi call update_disk call fat_unlock - push ERROR_FAT_TABLE - pop eax + movi eax, ERROR_FAT_TABLE ret fs_HdGetFileInfo: @@ -2771,8 +2764,7 @@ fs_HdDelete: jz ntfs_HdDelete cmp [fs_type], 2 jz ext2_HdDelete - push ERROR_UNKNOWN_FS - pop eax + movi eax, ERROR_UNKNOWN_FS ret @@: sub ebx, 4 @@ -2866,23 +2858,20 @@ fat_Delete: .err2: pop edi call fat_unlock - push ERROR_DEVICE - pop eax + movi eax, ERROR_DEVICE ret .error_fat: popad pop edi call fat_unlock - push ERROR_FAT_TABLE - pop eax + movi eax, ERROR_FAT_TABLE ret .notempty: popad .access_denied2: pop edi call fat_unlock - push ERROR_ACCESS_DENIED - pop eax + movi eax, ERROR_ACCESS_DENIED ret .empty: popad diff --git a/kernel/trunk/fs/ntfs.inc b/kernel/trunk/fs/ntfs.inc index b70837ee87..6c0f3f726b 100644 --- a/kernel/trunk/fs/ntfs.inc +++ b/kernel/trunk/fs/ntfs.inc @@ -1139,15 +1139,13 @@ ntfs_HdRead: cmp byte [esi], 0 jnz @f or ebx, -1 - push ERROR_ACCESS_DENIED - pop eax + movi eax, ERROR_ACCESS_DENIED ret @@: call ntfs_find_lfn jnc .found or ebx, -1 - push ERROR_FILE_NOT_FOUND - pop eax + movi eax, ERROR_FILE_NOT_FOUND ret .found: mov [ntfs_cur_attr], 0x80 ; $DATA @@ -1156,8 +1154,7 @@ ntfs_HdRead: call ntfs_read_attr jnc @f or ebx, -1 - push ERROR_ACCESS_DENIED - pop eax + movi eax, ERROR_ACCESS_DENIED ret @@: pushad @@ -1171,8 +1168,7 @@ ntfs_HdRead: popad xor ebx, ebx .eof: - push ERROR_END_OF_FILE - pop eax + movi eax, ERROR_END_OF_FILE ret @@: mov eax, [ebx] @@ -1349,8 +1345,7 @@ ntfs_HdReadFolder: .nomem: popad or ebx, -1 - push 12 - pop eax + movi eax, 12 ret @@: mov [ntfs_data.cur_index_buf], eax @@ -1804,14 +1799,12 @@ ntfs_HdDelete: ntfs_HdGetFileInfo: cmp byte [esi], 0 jnz @f - push 2 - pop eax + movi eax, 2 ret @@: call ntfs_find_lfn jnc .doit - push ERROR_FILE_NOT_FOUND - pop eax + movi eax, ERROR_FILE_NOT_FOUND cmp [hd_error], 0 jz @f mov al, 11 diff --git a/kernel/trunk/hid/keyboard.inc b/kernel/trunk/hid/keyboard.inc index 87b2a33454..83ee8f8c54 100644 --- a/kernel/trunk/hid/keyboard.inc +++ b/kernel/trunk/hid/keyboard.inc @@ -139,8 +139,7 @@ endg register_keyboard: push ebx - push sizeof.KEYBOARD - pop eax + movi eax, sizeof.KEYBOARD call malloc test eax, eax jz .nothing diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 01f5f6dba6..bfc748669f 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -5567,8 +5567,7 @@ system_shutdown: ; shut down the system ret @@: call stop_all_services - push 3 ; stop playing cd - pop eax + movi eax, 3 call sys_cd_audio yes_shutdown_param: @@ -5576,8 +5575,7 @@ yes_shutdown_param: if ~ defined extended_primary_loader mov eax, kernel_file ; load kernel.mnt to 0x7000:0 - push 12 - pop esi + movi esi, 12 xor ebx, ebx or ecx, -1 mov edx, OS_BASE+0x70000 diff --git a/kernel/trunk/macros.inc b/kernel/trunk/macros.inc index 619ed97712..280fc4dc0e 100644 --- a/kernel/trunk/macros.inc +++ b/kernel/trunk/macros.inc @@ -117,3 +117,16 @@ macro list_del entry mov [ecx+list_fd], edx } +; MOV Immediate. +; Useful for things like movi eax,10: +; shorter than regular mov, but slightly slower, +; do not use it in performance-critical places. +macro movi dst, imm +{ +if imm >= -0x80 & imm <= 0x7F + push imm + pop dst +else + mov dst, imm +end if +} diff --git a/kernel/trunk/network/tcp.inc b/kernel/trunk/network/tcp.inc index d5f3dd5126..2f4df68930 100644 --- a/kernel/trunk/network/tcp.inc +++ b/kernel/trunk/network/tcp.inc @@ -160,8 +160,7 @@ macro TCP_init { init_queue TCP_queue - push 1 - pop ebx + movi ebx, 1 mov ecx, TCP_process_input call new_sys_threads diff --git a/kernel/trunk/sec_loader/trunk/boot/cdfs/bootsect.asm b/kernel/trunk/sec_loader/trunk/boot/cdfs/bootsect.asm index f19bb55ab3..3a5d89fbff 100644 --- a/kernel/trunk/sec_loader/trunk/boot/cdfs/bootsect.asm +++ b/kernel/trunk/sec_loader/trunk/boot/cdfs/bootsect.asm @@ -50,8 +50,7 @@ real_start: ; get file system information ; scan for Primary Volume Descriptor db 66h - push 10h-1 - pop eax + movi eax, 10h-1 pvd_scan_loop: mov cx, 1 inc eax