repo_id
stringlengths
5
115
size
int64
590
5.01M
file_path
stringlengths
4
212
content
stringlengths
590
5.01M
soarbear/stm32f446-ihm07m1
1,912
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/startup_generic.S
#if defined (__CC_ARM) #if (defined (ARM_MATH_CM0)) #include "ARMCC\startup_armv6-m.s" #elif (defined (ARM_MATH_CM0P)) #include "ARMCC\startup_armv6-m.s" #elif (defined (ARM_MATH_CM3)) #include "ARMCC\startup_armv7-m.s" #elif (defined (ARM_MATH_CM4)) #include "ARMCC\startup_armv7-m.s" #elif (defined (ARM_MATH_CM7)) #include "ARMCC\startup_armv7-m.s" #elif (defined (ARM_MATH_ARMV8MBL)) #include "ARMCC\startup_armv6-m.s" #elif (defined (ARM_MATH_ARMV8MML)) #include "ARMCC\startup_armv7-m.s" #else #error "No appropriate startup file found!" #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #if (defined (ARM_MATH_CM0)) #include "ARMCLANG\startup_armv6-m.S" #elif (defined (ARM_MATH_CM0P)) #include "ARMCLANG\startup_armv6-m.S" #elif (defined (ARM_MATH_CM3)) #include "ARMCLANG\startup_armv7-m.S" #elif (defined (ARM_MATH_CM4)) #include "ARMCLANG\startup_armv7-m.S" #elif (defined (ARM_MATH_CM7)) #include "ARMCLANG\startup_armv7-m.S" #elif (defined (ARM_MATH_ARMV8MBL)) #include "ARMCLANG\startup_armv6-m.S" #elif (defined (ARM_MATH_ARMV8MML)) #include "ARMCLANG\startup_armv7-m.S" #else #error "No appropriate startup file found!" #endif #elif defined (__GNUC__) #if (defined (ARM_MATH_CM0)) #include "GCC\startup_armv6-m.S" #elif (defined (ARM_MATH_CM0P)) #include "GCC\startup_armv6-m.S" #elif (defined (ARM_MATH_CM3)) #include "GCC\startup_armv7-m.S" #elif (defined (ARM_MATH_CM4)) #include "GCC\startup_armv7-m.S" #elif (defined (ARM_MATH_CM7)) #include "GCC\startup_armv7-m.S" #elif (defined (ARM_MATH_ARMV8MBL)) #include "GCC\startup_armv6-m.S" #elif (defined (ARM_MATH_ARMV8MML)) #include "GCC\startup_armv7-m.S" #else #error "No appropriate startup file found!" #endif #else #error "Compiler not supported!" #endif
soarbear/stm32f446-ihm07m1
6,458
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/ARMCLANG/startup_armv7-m.S
/* File: startup_armv7-m.S * Purpose: startup file for armv7-m architecture devices. * Should be used with ARMCLANG * Version: V2.00 * Date: 16 November 2015 * */ /* Copyright (c) 2011 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ /* ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ */ .syntax unified .arch armv6-m /* .eabi_attribute Tag_ABI_align8_preserved,1 www.support.code-red-tech.com/CodeRedWiki/Preserve8 */ .eabi_attribute 25, 1 /* Tag_ABI_align_preserved */ /* ;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> */ .equ Stack_Size, 0x00000400 .section STACK, "w" .align 3 .globl __StackTop .globl __StackLimit __StackLimit: .space Stack_Size __StackTop: /* formerly known as __initial_sp */ /* ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> */ .equ Heap_Size, 0x00000C00 .section HEAP, "w" .align 3 .globl __HeapBase .globl __HeapLimit __HeapBase: .if Heap_Size .space Heap_Size .endif __HeapLimit: .section RESET, "x" .align 2 .globl __Vectors .globl __Vectors_End .globl __Vectors_Size __Vectors: .long __StackTop /* Top of Stack */ .long Reset_Handler /* Reset Handler */ .long NMI_Handler /* NMI Handler */ .long HardFault_Handler /* Hard Fault Handler */ .long MemManage_Handler /* MPU Fault Handler */ .long BusFault_Handler /* Bus Fault Handler */ .long UsageFault_Handler /* Usage Fault Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long SVC_Handler /* SVCall Handler */ .long DebugMon_Handler /* Debug Monitor Handler */ .long 0 /* Reserved */ .long PendSV_Handler /* PendSV Handler */ .long SysTick_Handler /* SysTick Handler */ __Vectors_End: .equ __Vectors_Size, __Vectors_End - __Vectors .text .thumb .align 2 .globl Reset_Handler .weak Reset_Handler .type Reset_Handler, %function .thumb_func Reset_Handler: bl SystemInit bl __main .globl NMI_Handler .weak NMI_Handler .type NMI_Handler, %function .thumb_func NMI_Handler: bkpt #0 b . .globl HardFault_Handler .weak HardFault_Handler .type HardFault_Handler, %function .thumb_func HardFault_Handler: bkpt #0 b . .globl MemManage_Handler .weak MemManage_Handler .type MemManage_Handler, %function .thumb_func MemManage_Handler: bkpt #0 b . .globl BusFault_Handler .weak BusFault_Handler .type BusFault_Handler, %function .thumb_func BusFault_Handler: bkpt #0 b . .globl UsageFault_Handler .weak UsageFault_Handler .type UsageFault_Handler, %function .thumb_func UsageFault_Handler: bkpt #0 b . .globl SVC_Handler .weak SVC_Handler .type SVC_Handler, %function .thumb_func SVC_Handler: bkpt #0 b . .globl DebugMon_Handler .weak DebugMon_Handler .type DebugMon_Handler, %function .thumb_func DebugMon_Handler: bkpt #0 b . .globl PendSV_Handler .weak PendSV_Handler .type PendSV_Handler, %function .thumb_func PendSV_Handler: bkpt #0 b . .globl SysTick_Handler .weak SysTick_Handler .type SysTick_Handler, %function .thumb_func SysTick_Handler: bkpt #0 b . .global __use_two_region_memory /* __user_setup_stackheap() returns the: - heap base in r0 (if the program uses the heap) - stack base in sp - heap limit in r2 (if the program uses the heap and uses two-region memory). */ .globl __user_setup_stackheap .type __user_setup_stackheap, %function .thumb_func __user_setup_stackheap: ldr r0, =__StackTop mov sp, r0 .if Heap_Size ldr r0, =__HeapBase ldr r2, =__HeapLimit .else mov r0, #0 mov r2, #0 .endif bx lr /* __user_initial_stackheap() returns the: - heap base in r0 - stack base in r1, that is, the highest address in the stack region - heap limit in r2 - stack limit in r3, that is, the lowest address in the stack region. */ /* DEPRICATED .globl __user_initial_stackheap .type __user_initial_stackheap, %function .thumb_func __user_initial_stackheap: ldr r0, = __HeapBase ldr r1, = __StackTop ldr r2, = __HeapLimit ldr r3, = __StackLimit bx lr */ .end
soarbear/stm32f446-ihm07m1
5,756
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/ARMCLANG/startup_armv6-m.S
/* File: startup_armv6-m.S * Purpose: startup file for armv6-m architecture devices. * Should be used with ARMCLANG * Version: V2.00 * Date: 16 November 2015 * */ /* Copyright (c) 2011 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ /* ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ */ .syntax unified .arch armv6-m /* .eabi_attribute Tag_ABI_align8_preserved,1 www.support.code-red-tech.com/CodeRedWiki/Preserve8 */ .eabi_attribute 25, 1 /* Tag_ABI_align_preserved */ /* ;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> */ .equ Stack_Size, 0x00000400 .section STACK, "w" .align 3 .globl __StackTop .globl __StackLimit __StackLimit: .space Stack_Size __StackTop: /* formerly known as __initial_sp */ /* ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> */ .equ Heap_Size, 0x00000C00 .section HEAP, "w" .align 3 .globl __HeapBase .globl __HeapLimit __HeapBase: .if Heap_Size .space Heap_Size .endif __HeapLimit: .section RESET, "x" .align 2 .globl __Vectors .globl __Vectors_End .globl __Vectors_Size __Vectors: .long __StackTop /* Top of Stack */ .long Reset_Handler /* Reset Handler */ .long NMI_Handler /* NMI Handler */ .long HardFault_Handler /* Hard Fault Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long SVC_Handler /* SVCall Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long PendSV_Handler /* PendSV Handler */ .long SysTick_Handler /* SysTick Handler */ __Vectors_End: .equ __Vectors_Size, __Vectors_End - __Vectors .text .thumb .align 2 .globl Reset_Handler .weak Reset_Handler .type Reset_Handler, %function .thumb_func Reset_Handler: bl SystemInit bl __main .globl NMI_Handler .weak NMI_Handler .type NMI_Handler, %function .thumb_func NMI_Handler: bkpt #0 b . .globl HardFault_Handler .weak HardFault_Handler .type HardFault_Handler, %function .thumb_func HardFault_Handler: bkpt #0 b . .globl SVC_Handler .weak SVC_Handler .type SVC_Handler, %function .thumb_func SVC_Handler: bkpt #0 b . .globl PendSV_Handler .weak PendSV_Handler .type PendSV_Handler, %function .thumb_func PendSV_Handler: bkpt #0 b . .globl SysTick_Handler .weak SysTick_Handler .type SysTick_Handler, %function .thumb_func SysTick_Handler: bkpt #0 b . .global __use_two_region_memory /* __user_setup_stackheap() returns the: - heap base in r0 (if the program uses the heap) - stack base in sp - heap limit in r2 (if the program uses the heap and uses two-region memory). */ .globl __user_setup_stackheap .type __user_setup_stackheap, %function .thumb_func __user_setup_stackheap: ldr r0, =__StackTop mov sp, r0 .if Heap_Size ldr r0, =__HeapBase ldr r2, =__HeapLimit .else mov r0, #0 mov r2, #0 .endif bx lr /* __user_initial_stackheap() returns the: - heap base in r0 - stack base in r1, that is, the highest address in the stack region - heap limit in r2 - stack limit in r3, that is, the lowest address in the stack region. */ /* DEPRICATED .globl __user_initial_stackheap .type __user_initial_stackheap, %function .thumb_func __user_initial_stackheap: ldr r0, = __HeapBase ldr r1, = __StackTop ldr r2, = __HeapLimit ldr r3, = __StackLimit bx lr */ .end
soarbear/stm32f446-ihm07m1
6,394
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/ARMCC/startup_armv6-m.s
;/* File: startup_armv6-m.s ; * Purpose: startup file for armv7-m architecture devices. ; * Should be used with ARMCC ; * Version: V2.00 ; * Date: 16 November 2015 ; * ; */ ;/* Copyright (c) 2011 - 2014 ARM LIMITED ; ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; - Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; - Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; - Neither the name of ARM nor the names of its contributors may be used ; to endorse or promote products derived from this software without ; specific prior written permission. ; * ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ; ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. ; ---------------------------------------------------------------------------*/ ;/* ; //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ ;*/ ; <h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ; <h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Heap_Size EQU 0x00000C00 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; SVCall Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD PendSV_Handler ; PendSV Handler DCD SysTick_Handler ; SysTick Handler __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; Dummy Exception Handlers (infinite loops which can be modified) NMI_Handler PROC EXPORT NMI_Handler [WEAK] BKPT #0 B . ENDP HardFault_Handler\ PROC EXPORT HardFault_Handler [WEAK] BKPT #0 B . ENDP SVC_Handler PROC EXPORT SVC_Handler [WEAK] B . ENDP PendSV_Handler PROC EXPORT PendSV_Handler [WEAK] B . ENDP SysTick_Handler PROC EXPORT SysTick_Handler [WEAK] B . ENDP ALIGN ; User Initial Stack & Heap IF :DEF:__MICROLIB EXPORT __initial_sp EXPORT __heap_base EXPORT __heap_limit ELSE IMPORT __use_two_region_memory ;/* ; __user_setup_stackheap() returns the: ; - heap base in r0 (if the program uses the heap) ; - stack base in sp ; - heap limit in r2 (if the program uses the heap and uses two-region memory). ; */ EXPORT __user_setup_stackheap __user_setup_stackheap PROC LDR R0, = __initial_sp MOV SP, R0 IF Heap_Size > 0 LDR R2, = __heap_limit LDR R0, = __heap_base ELSE MOV R0, #0 MOV R2, #0 ENDIF BX LR ENDP ;/* ;__user_initial_stackheap() returns the: ; - heap base in r0 ; - stack base in r1, that is, the highest address in the stack region ; - heap limit in r2 ; - stack limit in r3, that is, the lowest address in the stack region. ; */ ; ;/* DEPRICATED ; EXPORT __user_initial_stackheap ; ;__user_initial_stackheap PROC ; LDR R0, = Heap_Mem ; LDR R1, =(Stack_Mem + Stack_Size) ; LDR R2, = (Heap_Mem + Heap_Size) ; LDR R3, = Stack_Mem ; BX LR ; ENDP ; */ ALIGN ENDIF END
soarbear/stm32f446-ihm07m1
7,083
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/ARMCC/startup_armv7-m.s
;/* File: startup_armv7-m.s ; * Purpose: startup file for armv7-m architecture devices. ; * Should be used with ARMCC ; * Version: V2.00 ; * Date: 16 November 2015 ; * ; */ ;/* Copyright (c) 2011 - 2014 ARM LIMITED ; ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; - Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; - Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; - Neither the name of ARM nor the names of its contributors may be used ; to endorse or promote products derived from this software without ; specific prior written permission. ; * ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ; ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. ; ---------------------------------------------------------------------------*/ ;/* ; //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ ;*/ ; <h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ; <h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Heap_Size EQU 0x00000C00 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD MemManage_Handler ; MPU Fault Handler DCD BusFault_Handler ; Bus Fault Handler DCD UsageFault_Handler ; Usage Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; SVCall Handler DCD DebugMon_Handler ; Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; PendSV Handler DCD SysTick_Handler ; SysTick Handler __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; Dummy Exception Handlers (infinite loops which can be modified) NMI_Handler PROC EXPORT NMI_Handler [WEAK] BKPT #0 B . ENDP HardFault_Handler\ PROC EXPORT HardFault_Handler [WEAK] BKPT #0 B . ENDP MemManage_Handler\ PROC EXPORT MemManage_Handler [WEAK] BKPT #0 B . ENDP BusFault_Handler\ PROC EXPORT BusFault_Handler [WEAK] BKPT #0 B . ENDP UsageFault_Handler\ PROC EXPORT UsageFault_Handler [WEAK] BKPT #0 B . ENDP SVC_Handler PROC EXPORT SVC_Handler [WEAK] B . ENDP DebugMon_Handler\ PROC EXPORT DebugMon_Handler [WEAK] B . ENDP PendSV_Handler PROC EXPORT PendSV_Handler [WEAK] B . ENDP SysTick_Handler PROC EXPORT SysTick_Handler [WEAK] B . ENDP ALIGN ; User Initial Stack & Heap IF :DEF:__MICROLIB EXPORT __initial_sp EXPORT __heap_base EXPORT __heap_limit ELSE IMPORT __use_two_region_memory ;/* ; __user_setup_stackheap() returns the: ; - heap base in r0 (if the program uses the heap) ; - stack base in sp ; - heap limit in r2 (if the program uses the heap and uses two-region memory). ; */ EXPORT __user_setup_stackheap __user_setup_stackheap PROC LDR R0, = __initial_sp MOV SP, R0 IF Heap_Size > 0 LDR R2, = __heap_limit LDR R0, = __heap_base ELSE MOV R0, #0 MOV R2, #0 ENDIF BX LR ENDP ;/* ;__user_initial_stackheap() returns the: ; - heap base in r0 ; - stack base in r1, that is, the highest address in the stack region ; - heap limit in r2 ; - stack limit in r3, that is, the lowest address in the stack region. ; */ ; ;/* DEPRICATED ; EXPORT __user_initial_stackheap ; ;__user_initial_stackheap PROC ; LDR R0, = Heap_Mem ; LDR R1, =(Stack_Mem + Stack_Size) ; LDR R2, = (Heap_Mem + Heap_Size) ; LDR R3, = Stack_Mem ; BX LR ; ENDP ; */ ALIGN ENDIF END
soarbear/stm32f446-ihm07m1
7,347
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/GCC/startup_armv7-m.S
/* File: startup_armv7-m.S * Purpose: startup file for armv7-m architecture devices. * Should be used with GCC for ARM Embedded Processors * Version: V2.00 * Date: 16 November 2015 * */ /* Copyright (c) 2011 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ .syntax unified .arch armv7-m .section .stack .align 3 #ifdef __STACK_SIZE .equ Stack_Size, __STACK_SIZE #else .equ Stack_Size, 0x00000400 #endif .globl __StackTop .globl __StackLimit __StackLimit: .space Stack_Size .size __StackLimit, . - __StackLimit __StackTop: .size __StackTop, . - __StackTop .section .heap .align 3 #ifdef __HEAP_SIZE .equ Heap_Size, __HEAP_SIZE #else .equ Heap_Size, 0x00000C00 #endif .globl __HeapBase .globl __HeapLimit __HeapBase: .if Heap_Size .space Heap_Size .endif .size __HeapBase, . - __HeapBase __HeapLimit: .size __HeapLimit, . - __HeapLimit .section .vectors .align 2 .globl __Vectors __Vectors: .long __StackTop /* Top of Stack */ .long Reset_Handler /* Reset Handler */ .long NMI_Handler /* NMI Handler */ .long HardFault_Handler /* Hard Fault Handler */ .long MemManage_Handler /* MPU Fault Handler */ .long BusFault_Handler /* Bus Fault Handler */ .long UsageFault_Handler /* Usage Fault Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long SVC_Handler /* SVCall Handler */ .long DebugMon_Handler /* Debug Monitor Handler */ .long 0 /* Reserved */ .long PendSV_Handler /* PendSV Handler */ .long SysTick_Handler /* SysTick Handler */ .size __Vectors, . - __Vectors .text .thumb .thumb_func .align 2 .globl Reset_Handler .type Reset_Handler, %function Reset_Handler: /* Firstly it copies data from read only memory to RAM. There are two schemes * to copy. One can copy more than one sections. Another can only copy * one section. The former scheme needs more instructions and read-only * data to implement than the latter. * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */ #ifdef __STARTUP_COPY_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of triplets, each of which specify: * offset 0: LMA of start of a section to copy from * offset 4: VMA of start of a section to copy to * offset 8: size of the section to copy. Must be multiply of 4 * * All addresses must be aligned to 4 bytes boundary. */ ldr r4, =__copy_table_start__ ldr r5, =__copy_table_end__ .L_loop0: cmp r4, r5 bge .L_loop0_done ldr r1, [r4] ldr r2, [r4, #4] ldr r3, [r4, #8] .L_loop0_0: subs r3, #4 ittt ge ldrge r0, [r1, r3] strge r0, [r2, r3] bge .L_loop0_0 adds r4, #12 b .L_loop0 .L_loop0_done: #else /* Single section scheme. * * The ranges of copy from/to are specified by following symbols * __etext: LMA of start of the section to copy from. Usually end of text * __data_start__: VMA of start of the section to copy to * __data_end__: VMA of end of the section to copy to * * All addresses must be aligned to 4 bytes boundary. */ ldr r1, =__etext ldr r2, =__data_start__ ldr r3, =__data_end__ .L_loop1: cmp r2, r3 ittt lt ldrlt r0, [r1], #4 strlt r0, [r2], #4 blt .L_loop1 #endif /*__STARTUP_COPY_MULTIPLE */ /* This part of work usually is done in C library startup code. Otherwise, * define this macro to enable it in this startup. * * There are two schemes too. One can clear multiple BSS sections. Another * can only clear one section. The former is more size expensive than the * latter. * * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former. * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later. */ #ifdef __STARTUP_CLEAR_BSS_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of tuples specifying: * offset 0: Start of a BSS section * offset 4: Size of this BSS section. Must be multiply of 4 */ ldr r3, =__zero_table_start__ ldr r4, =__zero_table_end__ .L_loop2: cmp r3, r4 bge .L_loop2_done ldr r1, [r3] ldr r2, [r3, #4] movs r0, 0 .L_loop2_0: subs r2, #4 itt ge strge r0, [r1, r2] bge .L_loop2_0 adds r3, #8 b .L_loop2 .L_loop2_done: #elif defined (__STARTUP_CLEAR_BSS) /* Single BSS section scheme. * * The BSS section is specified by following symbols * __bss_start__: start of the BSS section. * __bss_end__: end of the BSS section. * * Both addresses must be aligned to 4 bytes boundary. */ ldr r1, =__bss_start__ ldr r2, =__bss_end__ movs r0, 0 .L_loop3: cmp r1, r2 itt lt strlt r0, [r1], #4 blt .L_loop3 #endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */ #ifndef __NO_SYSTEM_INIT bl SystemInit #endif #ifndef __START #define __START _start #endif bl __START .pool .size Reset_Handler, . - Reset_Handler .align 1 .thumb_func .weak Default_Handler .type Default_Handler, %function Default_Handler: bkpt #0 b . .size Default_Handler, . - Default_Handler /* Macro to define default handlers. Default handler * will be weak symbol and just dead loops. They can be * overwritten by other handlers */ .macro def_irq_handler handler_name .weak \handler_name .set \handler_name, Default_Handler .endm def_irq_handler NMI_Handler def_irq_handler HardFault_Handler def_irq_handler MemManage_Handler def_irq_handler BusFault_Handler def_irq_handler UsageFault_Handler def_irq_handler SVC_Handler def_irq_handler DebugMon_Handler def_irq_handler PendSV_Handler def_irq_handler SysTick_Handler .end
soarbear/stm32f446-ihm07m1
7,290
f446-ihm07-a2208/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/platform/GCC/startup_armv6-m.S
/* File: startup_armv6-m.S * Purpose: startup file for armv6-m architecture devices. * Should be used with GCC for ARM Embedded Processors * Version: V2.00 * Date: 16 November 2015 * */ /* Copyright (c) 2011 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ .syntax unified .arch armv6-m .section .stack .align 3 #ifdef __STACK_SIZE .equ Stack_Size, __STACK_SIZE #else .equ Stack_Size, 0x00000400 #endif .globl __StackTop .globl __StackLimit __StackLimit: .space Stack_Size .size __StackLimit, . - __StackLimit __StackTop: .size __StackTop, . - __StackTop .section .heap .align 3 #ifdef __HEAP_SIZE .equ Heap_Size, __HEAP_SIZE #else .equ Heap_Size, 0x00000C00 #endif .globl __HeapBase .globl __HeapLimit __HeapBase: .if Heap_Size .space Heap_Size .endif .size __HeapBase, . - __HeapBase __HeapLimit: .size __HeapLimit, . - __HeapLimit .section .vectors .align 2 .globl __Vectors __Vectors: .long __StackTop /* Top of Stack */ .long Reset_Handler /* Reset Handler */ .long NMI_Handler /* NMI Handler */ .long HardFault_Handler /* Hard Fault Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long SVC_Handler /* SVCall Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long PendSV_Handler /* PendSV Handler */ .long SysTick_Handler /* SysTick Handler */ .size __Vectors, . - __Vectors .text .thumb .thumb_func .align 1 .globl Reset_Handler .type Reset_Handler, %function Reset_Handler: /* Firstly it copies data from read only memory to RAM. There are two schemes * to copy. One can copy more than one sections. Another can only copy * one section. The former scheme needs more instructions and read-only * data to implement than the latter. * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */ #ifdef __STARTUP_COPY_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of triplets, each of which specify: * offset 0: LMA of start of a section to copy from * offset 4: VMA of start of a section to copy to * offset 8: size of the section to copy. Must be multiply of 4 * * All addresses must be aligned to 4 bytes boundary. */ ldr r4, =__copy_table_start__ ldr r5, =__copy_table_end__ .L_loop0: cmp r4, r5 bge .L_loop0_done ldr r1, [r4] ldr r2, [r4, #4] ldr r3, [r4, #8] .L_loop0_0: subs r3, #4 blt .L_loop0_0_done ldr r0, [r1, r3] str r0, [r2, r3] b .L_loop0_0 .L_loop0_0_done: adds r4, #12 b .L_loop0 .L_loop0_done: #else /* Single section scheme. * * The ranges of copy from/to are specified by following symbols * __etext: LMA of start of the section to copy from. Usually end of text * __data_start__: VMA of start of the section to copy to * __data_end__: VMA of end of the section to copy to * * All addresses must be aligned to 4 bytes boundary. */ ldr r1, =__etext ldr r2, =__data_start__ ldr r3, =__data_end__ subs r3, r2 ble .L_loop1_done .L_loop1: subs r3, #4 ldr r0, [r1,r3] str r0, [r2,r3] bgt .L_loop1 .L_loop1_done: #endif /*__STARTUP_COPY_MULTIPLE */ /* This part of work usually is done in C library startup code. Otherwise, * define this macro to enable it in this startup. * * There are two schemes too. One can clear multiple BSS sections. Another * can only clear one section. The former is more size expensive than the * latter. * * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former. * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later. */ #ifdef __STARTUP_CLEAR_BSS_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of tuples specifying: * offset 0: Start of a BSS section * offset 4: Size of this BSS section. Must be multiply of 4 */ ldr r3, =__zero_table_start__ ldr r4, =__zero_table_end__ .L_loop2: cmp r3, r4 bge .L_loop2_done ldr r1, [r3] ldr r2, [r3, #4] movs r0, 0 .L_loop2_0: subs r2, #4 blt .L_loop2_0_done str r0, [r1, r2] b .L_loop2_0 .L_loop2_0_done: adds r3, #8 b .L_loop2 .L_loop2_done: #elif defined (__STARTUP_CLEAR_BSS) /* Single BSS section scheme. * * The BSS section is specified by following symbols * __bss_start__: start of the BSS section. * __bss_end__: end of the BSS section. * * Both addresses must be aligned to 4 bytes boundary. */ ldr r1, =__bss_start__ ldr r2, =__bss_end__ movs r0, 0 subs r2, r1 ble .L_loop3_done .L_loop3: subs r2, #4 str r0, [r1, r2] bgt .L_loop3 .L_loop3_done: #endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */ #ifndef __NO_SYSTEM_INIT bl SystemInit #endif #ifndef __START #define __START _start #endif bl __START .pool .size Reset_Handler, . - Reset_Handler .align 1 .thumb_func .weak Default_Handler .type Default_Handler, %function Default_Handler: bkpt #0 b . .size Default_Handler, . - Default_Handler /* Macro to define default handlers. Default handler * will be weak symbol and just dead loops. They can be * overwritten by other handlers */ .macro def_irq_handler handler_name .weak \handler_name .set \handler_name, Default_Handler .endm def_irq_handler NMI_Handler def_irq_handler HardFault_Handler def_irq_handler SVC_Handler def_irq_handler PendSV_Handler def_irq_handler SysTick_Handler .end
SolaceHarmony/ember-ml-kotlin
5,198
external/kcoro/lab/mirror/arch/aarch64/kc_ctx_switch.S
/* * ARM64/aarch64 context switching for kcoro * * This file implements the low-level register/stack switch primitive `kcoro`: * void* kcoro(kcoro_t* from_co, kcoro_t* to_co); * * Conceptually: * - Save the current coroutine's callee-saved registers and stack pointer * into from_co->reg[] * - Restore the target coroutine's registers and stack pointer from * to_co->reg[] * - Branch to to_co->reg[RETADDR] (the saved continuation / entry point) * * Stack model: * libkcoro uses a shared stack. Higher-level C code copies the active slice * of the stack between a coroutine-private save buffer and the shared stack * before/after calling `kcoro`. This assembly switches only registers and SP. * * Register layout in kcoro_t.reg for ARM64 (indices into void* reg[32]): * reg[ 0.. 9] : x19..x28 (callee-saved) * reg[15] : x29 (frame pointer) * reg[13] : x30 (return addr) (a.k.a. link register / continuation) * reg[14] : sp (stack pointer) * * Byte offsets = index * 8 (because reg[] is an array of void* on 64-bit): * x19 @ 0x00 (reg[0]) ... x28 @ 0x48 (reg[9]) * x30 @ 0x68 (reg[13]) * sp @ 0x70 (reg[14]) * x29 @ 0x78 (reg[15]) * * ABI notes: * - ARM64 requires 16-byte stack alignment on public interfaces. The C * runtime sets up align_retptr accordingly; this routine preserves SP. * - We only touch callee-saved registers; caller-saved regs/args are the * responsibility of the surrounding C code. * - We do not save/restore FP/SIMD state here; libkcoro avoids using it on * ARM64 (kcoro_save_fpucw_mxcsr is a no-op stub). * * License: * Inspired by work done on libkcoro, Sen Han <00hnes@gmail.com> * */ .text .align 4 #ifdef __APPLE__ #define FUNC_TYPE(name) #define FUNC_SIZE(name, expr) #define GLOBAL(name) .globl _##name #define LABEL(name) _##name #else #define FUNC_TYPE(name) .type name, %function #define FUNC_SIZE(name, expr) .size name, expr #define GLOBAL(name) .globl name #define LABEL(name) name #endif #ifndef KC_VM_SWITCH GLOBAL(kcoro) FUNC_TYPE(LABEL(kcoro)) GLOBAL(kcoro_switch) FUNC_TYPE(LABEL(kcoro_switch)) LABEL(kcoro): LABEL(kcoro_switch): /* * ARM64 calling convention: * x0 = from_co (source context) * x1 = to_co (target context) * * Save from_co callee-saved registers and SP, then restore to_co's. * Finally, branch to to_co's saved continuation (reg[13]). */ /* Save from_co context */ /* Save callee-saved registers at indices 0-9 */ str x19, [x0, #0x00] /* reg[0] */ str x20, [x0, #0x08] /* reg[1] */ str x21, [x0, #0x10] /* reg[2] */ str x22, [x0, #0x18] /* reg[3] */ str x23, [x0, #0x20] /* reg[4] */ str x24, [x0, #0x28] /* reg[5] */ str x25, [x0, #0x30] /* reg[6] */ str x26, [x0, #0x38] /* reg[7] */ str x27, [x0, #0x40] /* reg[8] */ str x28, [x0, #0x48] /* reg[9] */ /* Save special registers at their designated indices */ str x30, [x0, #0x68] /* save lr (link register) as continuation at reg[13] */ mov x9, sp str x9, [x0, #0x70] /* save sp at reg[14] */ str x29, [x0, #0x78] /* save x29 (frame pointer) at reg[15] */ /* Load to_co context */ /* Restore callee-saved registers from indices 0-9 */ ldr x19, [x1, #0x00] /* reg[0] */ ldr x20, [x1, #0x08] /* reg[1] */ ldr x21, [x1, #0x10] /* reg[2] */ ldr x22, [x1, #0x18] /* reg[3] */ ldr x23, [x1, #0x20] /* reg[4] */ ldr x24, [x1, #0x28] /* reg[5] */ ldr x25, [x1, #0x30] /* reg[6] */ ldr x26, [x1, #0x38] /* reg[7] */ ldr x27, [x1, #0x40] /* reg[8] */ ldr x28, [x1, #0x48] /* reg[9] */ /* Restore special registers */ ldr x29, [x1, #0x78] /* restore x29 (frame pointer) from reg[15] */ ldr x9, [x1, #0x70] /* load sp from reg[14] */ mov sp, x9 /* Jump to target continuation */ ldr x9, [x1, #0x68] /* load continuation (lr) from reg[13] */ br x9 FUNC_SIZE(LABEL(kcoro), .-LABEL(kcoro)) FUNC_SIZE(LABEL(kcoro_switch), .-LABEL(kcoro_switch)) #endif /* KC_VM_SWITCH */ GLOBAL(kcoro_save_fpucw_mxcsr) FUNC_TYPE(LABEL(kcoro_save_fpucw_mxcsr)) LABEL(kcoro_save_fpucw_mxcsr): /* ARM64 doesn't have FPU control words. * This is intentionally a no-op to avoid touching FP/SIMD in kernel-like * environments or when not required in userland. */ ret FUNC_SIZE(LABEL(kcoro_save_fpucw_mxcsr), .-LABEL(kcoro_save_fpucw_mxcsr)) GLOBAL(kcoro_funcp_protector_asm) FUNC_TYPE(LABEL(kcoro_funcp_protector_asm)) LABEL(kcoro_funcp_protector_asm): /* Ensure LR is preserved while we call into C helpers */ stp x29, x30, [sp, #-16]! mov x29, sp bl LABEL(kcoro_funcp_protector) bl LABEL(abort) /* Should never reach here */ ldp x29, x30, [sp], #16 ret FUNC_SIZE(LABEL(kcoro_funcp_protector_asm), .-LABEL(kcoro_funcp_protector_asm)) #ifdef __APPLE__ #undef FUNC_TYPE #undef FUNC_SIZE #undef GLOBAL #undef LABEL #endif
SolaceHarmony/ember-ml-kotlin
4,010
external/kcoro/lab/mirror/arch/x86_64/kc_ctx_switch.S
/* * x86_64 System V context switching for kcoro * * Implements the low-level primitive: * void* kcoro_switch(kcoro_t* from_co, kcoro_t* to_co); * * Contract (matches kcoro_core.c expectations): * kcoro_t has `void* reg[32]` as its first field. Indices used on x86_64: * reg[ 0..5] : r12, r13, r14, r15, rbx, rbp (callee-saved) * reg[13] : rip (continuation to jump/return to) * reg[14] : rsp (stack pointer) * reg[15] : rbp (frame/base pointer) * * Save from_co's callee-saved regs, RIP (from [rsp]), and RSP/RBP. * Restore to_co's RSP/RBP and callee-saved regs, then transfer control to * its saved continuation. To make the continuation look like a normal call * target w.r.t. ABI stack alignment, we push the saved rip and `ret` to it. * * Notes: * - System V AMD64: caller ensures 16-byte alignment before `call`. At function * entry, after the return address is pushed, RSP % 16 == 8. By pushing the * saved continuation and using `ret`, we preserve the expected entry state. * - We do not save/restore XMM/FPU state here; kcoro avoids relying on it across * switches (mirrors the ARM64 implementation policy). */ .text .align 4 #ifdef __APPLE__ #define FUNC_TYPE(name) #define FUNC_SIZE(name, expr) #define GLOBAL(name) .globl _##name #define LABEL(name) _##name #else #define FUNC_TYPE(name) .type name, %function #define FUNC_SIZE(name, expr) .size name, expr #define GLOBAL(name) .globl name #define LABEL(name) name #endif /* Indices expressed as byte offsets (index * 8) */ .set REG_R12, 0x00 /* reg[0] */ .set REG_R13, 0x08 /* reg[1] */ .set REG_R14, 0x10 /* reg[2] */ .set REG_R15, 0x18 /* reg[3] */ .set REG_RBX, 0x20 /* reg[4] */ .set REG_RBP, 0x28 /* reg[5] */ .set REG_RIP, 0x68 /* reg[13] */ .set REG_RSP, 0x70 /* reg[14] */ .set REG_FP, 0x78 /* reg[15] (rbp mirror for parity with ARM mapping) */ GLOBAL(kcoro) FUNC_TYPE(LABEL(kcoro)) GLOBAL(kcoro_switch) FUNC_TYPE(LABEL(kcoro_switch)) /* System V: rdi=from_co, rsi=to_co */ LABEL(kcoro): LABEL(kcoro_switch): /* Save callee-saved registers into from_co->reg[] */ movq %r12, REG_R12(%rdi) movq %r13, REG_R13(%rdi) movq %r14, REG_R14(%rdi) movq %r15, REG_R15(%rdi) movq %rbx, REG_RBX(%rdi) movq %rbp, REG_RBP(%rdi) /* Save return address (current continuation) from [rsp] into reg[13] */ movq (%rsp), %rax movq %rax, REG_RIP(%rdi) /* Save stack pointers */ movq %rsp, %rax movq %rax, REG_RSP(%rdi) /* Mirror rbp in reg[15] for parity with kcoro_core.c setup */ movq %rbp, %rax movq %rax, REG_FP(%rdi) /* Restore to_co state */ /* Load stack pointers first */ movq REG_RSP(%rsi), %rsp movq REG_FP(%rsi), %rbp /* Restore callee-saved regs */ movq REG_R12(%rsi), %r12 movq REG_R13(%rsi), %r13 movq REG_R14(%rsi), %r14 movq REG_R15(%rsi), %r15 movq REG_RBX(%rsi), %rbx /* rbp already restored */ /* Transfer to continuation: push RIP then ret to keep ABI entry semantics */ movq REG_RIP(%rsi), %rax pushq %rax ret FUNC_SIZE(LABEL(kcoro), .-LABEL(kcoro)) FUNC_SIZE(LABEL(kcoro_switch), .-LABEL(kcoro_switch)) /* Optional stub: no-op FPU control save (matches ARM64 policy) */ GLOBAL(kcoro_save_fpucw_mxcsr) FUNC_TYPE(LABEL(kcoro_save_fpucw_mxcsr)) LABEL(kcoro_save_fpucw_mxcsr): ret FUNC_SIZE(LABEL(kcoro_save_fpucw_mxcsr), .-LABEL(kcoro_save_fpucw_mxcsr)) /* Protector thunk that calls into C helper and aborts */ GLOBAL(kcoro_funcp_protector_asm) FUNC_TYPE(LABEL(kcoro_funcp_protector_asm)) LABEL(kcoro_funcp_protector_asm): /* Preserve rbp and call C helper */ pushq %rbp movq %rsp, %rbp #ifdef __APPLE__ callq _kcoro_funcp_protector callq _abort #else callq kcoro_funcp_protector callq abort #endif /* Should not return, but restore frame if it does */ leave ret #ifdef __APPLE__ #undef FUNC_TYPE #undef FUNC_SIZE #undef GLOBAL #undef LABEL #endif
SolaceHarmony/ember-ml-kotlin
5,151
external/kcoro/arch/aarch64/kc_ctx_switch.S
/* * ARM64/aarch64 context switching for kcoro * * This file implements the low-level register/stack switch primitive `kcoro`: * void* kcoro(kcoro_t* from_co, kcoro_t* to_co); * * Conceptually: * - Save the current coroutine's callee-saved registers and stack pointer * into from_co->reg[] * - Restore the target coroutine's registers and stack pointer from * to_co->reg[] * - Branch to to_co->reg[RETADDR] (the saved continuation / entry point) * * Stack model: * libkcoro uses a shared stack. Higher-level C code copies the active slice * of the stack between a coroutine-private save buffer and the shared stack * before/after calling `kcoro`. This assembly switches only registers and SP. * * Register layout in kcoro_t.reg for ARM64 (indices into void* reg[32]): * reg[ 0.. 9] : x19..x28 (callee-saved) * reg[15] : x29 (frame pointer) * reg[13] : x30 (return addr) (a.k.a. link register / continuation) * reg[14] : sp (stack pointer) * * Byte offsets = index * 8 (because reg[] is an array of void* on 64-bit): * x19 @ 0x00 (reg[0]) ... x28 @ 0x48 (reg[9]) * x30 @ 0x68 (reg[13]) * sp @ 0x70 (reg[14]) * x29 @ 0x78 (reg[15]) * * ABI notes: * - ARM64 requires 16-byte stack alignment on public interfaces. The C * runtime sets up align_retptr accordingly; this routine preserves SP. * - We only touch callee-saved registers; caller-saved regs/args are the * responsibility of the surrounding C code. * - We do not save/restore FP/SIMD state here; libkcoro avoids using it on * ARM64 (kcoro_save_fpucw_mxcsr is a no-op stub). * * License: * Inspired by work done on libkcoro, Sen Han <00hnes@gmail.com> * */ .text .align 4 #ifdef __APPLE__ #define FUNC_TYPE(name) #define FUNC_SIZE(name, expr) #define GLOBAL(name) .globl _##name #define LABEL(name) _##name #else #define FUNC_TYPE(name) .type name, %function #define FUNC_SIZE(name, expr) .size name, expr #define GLOBAL(name) .globl name #define LABEL(name) name #endif GLOBAL(kcoro) FUNC_TYPE(LABEL(kcoro)) GLOBAL(kcoro_switch) FUNC_TYPE(LABEL(kcoro_switch)) LABEL(kcoro): LABEL(kcoro_switch): /* * ARM64 calling convention: * x0 = from_co (source context) * x1 = to_co (target context) * * Save from_co callee-saved registers and SP, then restore to_co's. * Finally, branch to to_co's saved continuation (reg[13]). */ /* Save from_co context */ /* Save callee-saved registers at indices 0-9 */ str x19, [x0, #0x00] /* reg[0] */ str x20, [x0, #0x08] /* reg[1] */ str x21, [x0, #0x10] /* reg[2] */ str x22, [x0, #0x18] /* reg[3] */ str x23, [x0, #0x20] /* reg[4] */ str x24, [x0, #0x28] /* reg[5] */ str x25, [x0, #0x30] /* reg[6] */ str x26, [x0, #0x38] /* reg[7] */ str x27, [x0, #0x40] /* reg[8] */ str x28, [x0, #0x48] /* reg[9] */ /* Save special registers at their designated indices */ str x30, [x0, #0x68] /* save lr (link register) as continuation at reg[13] */ mov x9, sp str x9, [x0, #0x70] /* save sp at reg[14] */ str x29, [x0, #0x78] /* save x29 (frame pointer) at reg[15] */ /* Load to_co context */ /* Restore callee-saved registers from indices 0-9 */ ldr x19, [x1, #0x00] /* reg[0] */ ldr x20, [x1, #0x08] /* reg[1] */ ldr x21, [x1, #0x10] /* reg[2] */ ldr x22, [x1, #0x18] /* reg[3] */ ldr x23, [x1, #0x20] /* reg[4] */ ldr x24, [x1, #0x28] /* reg[5] */ ldr x25, [x1, #0x30] /* reg[6] */ ldr x26, [x1, #0x38] /* reg[7] */ ldr x27, [x1, #0x40] /* reg[8] */ ldr x28, [x1, #0x48] /* reg[9] */ /* Restore special registers */ ldr x29, [x1, #0x78] /* restore x29 (frame pointer) from reg[15] */ ldr x9, [x1, #0x70] /* load sp from reg[14] */ mov sp, x9 /* Jump to target continuation */ ldr x9, [x1, #0x68] /* load continuation (lr) from reg[13] */ br x9 FUNC_SIZE(LABEL(kcoro), .-LABEL(kcoro)) FUNC_SIZE(LABEL(kcoro_switch), .-LABEL(kcoro_switch)) GLOBAL(kcoro_save_fpucw_mxcsr) FUNC_TYPE(LABEL(kcoro_save_fpucw_mxcsr)) LABEL(kcoro_save_fpucw_mxcsr): /* ARM64 doesn't have FPU control words. * This is intentionally a no-op to avoid touching FP/SIMD in kernel-like * environments or when not required in userland. */ ret FUNC_SIZE(LABEL(kcoro_save_fpucw_mxcsr), .-LABEL(kcoro_save_fpucw_mxcsr)) GLOBAL(kcoro_funcp_protector_asm) FUNC_TYPE(LABEL(kcoro_funcp_protector_asm)) LABEL(kcoro_funcp_protector_asm): /* Ensure LR is preserved while we call into C helpers */ stp x29, x30, [sp, #-16]! mov x29, sp bl LABEL(kcoro_funcp_protector) bl LABEL(abort) /* Should never reach here */ ldp x29, x30, [sp], #16 ret FUNC_SIZE(LABEL(kcoro_funcp_protector_asm), .-LABEL(kcoro_funcp_protector_asm)) #ifdef __APPLE__ #undef FUNC_TYPE #undef FUNC_SIZE #undef GLOBAL #undef LABEL #endif
SolaceHarmony/ember-ml-kotlin
4,010
external/kcoro/arch/x86_64/kc_ctx_switch.S
/* * x86_64 System V context switching for kcoro * * Implements the low-level primitive: * void* kcoro_switch(kcoro_t* from_co, kcoro_t* to_co); * * Contract (matches kcoro_core.c expectations): * kcoro_t has `void* reg[32]` as its first field. Indices used on x86_64: * reg[ 0..5] : r12, r13, r14, r15, rbx, rbp (callee-saved) * reg[13] : rip (continuation to jump/return to) * reg[14] : rsp (stack pointer) * reg[15] : rbp (frame/base pointer) * * Save from_co's callee-saved regs, RIP (from [rsp]), and RSP/RBP. * Restore to_co's RSP/RBP and callee-saved regs, then transfer control to * its saved continuation. To make the continuation look like a normal call * target w.r.t. ABI stack alignment, we push the saved rip and `ret` to it. * * Notes: * - System V AMD64: caller ensures 16-byte alignment before `call`. At function * entry, after the return address is pushed, RSP % 16 == 8. By pushing the * saved continuation and using `ret`, we preserve the expected entry state. * - We do not save/restore XMM/FPU state here; kcoro avoids relying on it across * switches (mirrors the ARM64 implementation policy). */ .text .align 4 #ifdef __APPLE__ #define FUNC_TYPE(name) #define FUNC_SIZE(name, expr) #define GLOBAL(name) .globl _##name #define LABEL(name) _##name #else #define FUNC_TYPE(name) .type name, %function #define FUNC_SIZE(name, expr) .size name, expr #define GLOBAL(name) .globl name #define LABEL(name) name #endif /* Indices expressed as byte offsets (index * 8) */ .set REG_R12, 0x00 /* reg[0] */ .set REG_R13, 0x08 /* reg[1] */ .set REG_R14, 0x10 /* reg[2] */ .set REG_R15, 0x18 /* reg[3] */ .set REG_RBX, 0x20 /* reg[4] */ .set REG_RBP, 0x28 /* reg[5] */ .set REG_RIP, 0x68 /* reg[13] */ .set REG_RSP, 0x70 /* reg[14] */ .set REG_FP, 0x78 /* reg[15] (rbp mirror for parity with ARM mapping) */ GLOBAL(kcoro) FUNC_TYPE(LABEL(kcoro)) GLOBAL(kcoro_switch) FUNC_TYPE(LABEL(kcoro_switch)) /* System V: rdi=from_co, rsi=to_co */ LABEL(kcoro): LABEL(kcoro_switch): /* Save callee-saved registers into from_co->reg[] */ movq %r12, REG_R12(%rdi) movq %r13, REG_R13(%rdi) movq %r14, REG_R14(%rdi) movq %r15, REG_R15(%rdi) movq %rbx, REG_RBX(%rdi) movq %rbp, REG_RBP(%rdi) /* Save return address (current continuation) from [rsp] into reg[13] */ movq (%rsp), %rax movq %rax, REG_RIP(%rdi) /* Save stack pointers */ movq %rsp, %rax movq %rax, REG_RSP(%rdi) /* Mirror rbp in reg[15] for parity with kcoro_core.c setup */ movq %rbp, %rax movq %rax, REG_FP(%rdi) /* Restore to_co state */ /* Load stack pointers first */ movq REG_RSP(%rsi), %rsp movq REG_FP(%rsi), %rbp /* Restore callee-saved regs */ movq REG_R12(%rsi), %r12 movq REG_R13(%rsi), %r13 movq REG_R14(%rsi), %r14 movq REG_R15(%rsi), %r15 movq REG_RBX(%rsi), %rbx /* rbp already restored */ /* Transfer to continuation: push RIP then ret to keep ABI entry semantics */ movq REG_RIP(%rsi), %rax pushq %rax ret FUNC_SIZE(LABEL(kcoro), .-LABEL(kcoro)) FUNC_SIZE(LABEL(kcoro_switch), .-LABEL(kcoro_switch)) /* Optional stub: no-op FPU control save (matches ARM64 policy) */ GLOBAL(kcoro_save_fpucw_mxcsr) FUNC_TYPE(LABEL(kcoro_save_fpucw_mxcsr)) LABEL(kcoro_save_fpucw_mxcsr): ret FUNC_SIZE(LABEL(kcoro_save_fpucw_mxcsr), .-LABEL(kcoro_save_fpucw_mxcsr)) /* Protector thunk that calls into C helper and aborts */ GLOBAL(kcoro_funcp_protector_asm) FUNC_TYPE(LABEL(kcoro_funcp_protector_asm)) LABEL(kcoro_funcp_protector_asm): /* Preserve rbp and call C helper */ pushq %rbp movq %rsp, %rbp #ifdef __APPLE__ callq _kcoro_funcp_protector callq _abort #else callq kcoro_funcp_protector callq abort #endif /* Should not return, but restore frame if it does */ leave ret #ifdef __APPLE__ #undef FUNC_TYPE #undef FUNC_SIZE #undef GLOBAL #undef LABEL #endif
SquidTWL/SquidTWL
8,607
squidtwl/src/start.s
.section ".crt","ax" .global _start // TODO: Need to copy ITCM and DTCM // TODO: Replace the C1/C0 constants with ones not stolen from the decompiled game. setup_coprocessor: // The creatively named MCR and MRC stand for "Move Coprocessor to Register" and // "Move Register to Coprocessor", respectively. The names are misleading; it really means // "do coprocessor command". // C1/C0/0 = System control, copy the definition into R0 mrc p15, 0x0, r0, cr1, cr0, 0x0 // load constant control value // this (temporarrily) disables the protection unit, the DTCM and ITCM, and disables // caching for them ldr r1, =0x000F90053 // BIC = Rd AND (NOT Rn) // clear any set bits in R0 that are set in R1, leave the rest alone bic r0, r0, r1 // write it back mcr p15, 0x0, r0, cr1, cr0, 0x0 // Disable caches for both TCMs (?) // C7,C5,0 0 Yes Invalidate Entire Instruction Cache // C7,C6,0 0 Yes Invalidate Entire Data Cache mov r0, #0 mcr p15, 0, r0, c7, c5, 0 mcr p15, 0, r0, c7, c6, 0 // C7,C10,4 0 - Drain Write Buffer mcr p15, 0, r0, c7, c10, 4 // == Memory Protection == // // The protection regions are almost identical to the ones on GBATEK, which are in themselves // identical to the ones setup by the CRT of the game I've decompiled. // // Control register C6 defines the region, C0-C7 all define a specific subregion. // Bit 0: 1 = enable protection, 0 = disable protection // Bit 1-5: 2 SHL value = region size // Bit 6-11: reserved // Bit 12-31: Region address * 4096 // // The official ARM docs marks sizees less than 0b01011 as unpredictable, so the base unit is // in 4KB blocks? // // "The address of the first byte is required to be a multiple of the region size." // Protection region 0: 0x04000000, 64MiB (i.e. up to 0x8000000) // This is the I/O registers all the way up to the end of the OAM! ldr r0, =(0x04000000 | 0x33) mcr p15, 0, r0, c6, c0, 0 // Protection region 1: 0x02000000, 4MiB // The compiled game I'm looking at has it incorrectly set to 8MiB. I guess the SDK always // sets it that high? This is main memory. ldr r0, =(0x02000000 | 0x2b) mcr p15, 0, r0, c6, c1, 0 // Protection region 2: 0x027FF00, 4KiB. // This is used by the BIOS and by the ARM7 to send data to the ARM9 without using FIFO. // Due to how the mirroring works, this is written to *underneath* the DTCM and isn't accessible // via main memory, but is accessible via the mirror up here. ldr r0, =(0x027FF00 | 0x17) mcr p15, 0, r0, c6, c2, 0 // Protection region 3: 0x08000000, 128MiB // GBATEK: GBA Slot should be max 32MB+64KB, rounded up to 64MB, no idea why it is 128MB? ldr r0, =(0x08000000 | 0x35) mcr p15, 0, r0, c6, c3, 0 // Protection region 4: 0x027e0000, 16KiB // This is the DTCM. ldr r0, =__dtcm_region_start orr r0, r0, #0x1b mcr p15, 0, r0, c6, c4, 0 // Protection region 5: 0x01000000, 32KiB // ITCM. Thanks to mirroring, this repeats itself every 32KiB. ldr r0, =__itcm_region_start orr r0, r0, #0x1d mcr p15, 0, r0, c6, c5, 0 // Protection region 6: 0xFFFF0000, 32KiB. // This is where the BIOS is mapped. ldr r0, =(0xFFFF0000 | 0x1d) mcr p15, 0, r0, c6, c6, 0 // Protection region 7: 0x037F8000, 32KiB. // This is shared WRAM. ldr r0, =__shram_region_start orr r0, r0, #0x1d mcr p15, 0, r0, c6, c7, 0 // == Tightly Coupled Memory == // // C9, C1 controls the TCM Region. // // The ARM manual states "Prior to ARMv6 it is IMPLEMENTATION DEFINED how TCMs are supported, // "though generally this is through a System Control Coprocessor interface."" // // ITCM is fixed, so just set the size to 32MiB so it covers the entire first part of memory // space. It'll get mirrored apparently. // Table B7-2: 32MiB is 0b10000 (<< 1), 16KiB is 0b00101 (<< 1). mov r0, 0x20 mcr p15, 0, r0, c9, c1, 1 // DTCM is movable, so load it at the right address and set its size to 16KiB. ldr r0, =__dtcm_region_start orr r0, r0, 0xa mcr p15, 0, r0, c9, c1, 0 // == Protection Unit, Pt 2 == // // Register C2,C0 controls data caching and it's a bitfield for every region that needs caches. // 0x1 = instructions, 0x0 = data // // The only regions that needs caching is main memory, which is region 1, and the BIOS, which // is region 6. (The bitfield starts from the LSB.) mov r0, #0b01000010 mcr p15, 0, r0, c2, c0, 0 mcr p15, 0, r0, c2, c0, 1 // C3,C0,0 is... write-bufferability? This is too far into the details of CPUs for me. // Just do what the official CRT does, which is region 1 (main memory). mov r0, #0b00000010 mcr p15, 0, r0, c3, c0, 0 // C5,C0 controls the permissions for the various memory protection regions. Immediate // value 2 and 3 control *extended* permissions, which give 4 bits per region with up to // six values. 2 = Data/Unified, 3 = Instruction. Immediate value 0 and 1 control basic // permissions, with two bits per region. // // We're just going to fill this with 0b11 for all eight regions as constructing the individual // permission bits is fiddly and not really needed. ldr r0, =0xffff mcr p15, 0, r0, c5, c0, 0 mcr p15, 0, r0, c5, c0, 1 // Re-enable ITCM, DTCM, caches, and protection unit. mrc p15, 0, r0, c1, c0, 0 ldr r1, =0x0005707D orr r0, r0, r1 mcr p15, 0, r0, c1, c0, 0 bx lr .arm // R0: value // R1: ptr to start // R2: size _ASM_primitive_memset: // R12 (end) = start + size add r12, r1, r2 .L0: // Compare current pointer to end cmp r1, r12 // Store if less than, increment multiple registers // *R1 = R0, R1 += 4 // Also, the double braces are because this is being compiled with ``global_asm!()``, and single // braces means it would think it's a parameter and flip out at me for not providing an ``R0`` // parameter. // Doesn't clear the condition bits so... stmialt r1!, {{R0}} // ... jump back if the condition still matches blt .L0 // Return bx lr _start: // The IME is at address 0x4000208, and is a 32-bit register. // The only bit in it that matters is bit zero, which acts as the enable bit. // 1 = interrupts controlled by IE // 0 = interrupts forcibly disabled. // // The ``mov`` instruction with an immediate can only operate on any 8-bit value that is shifted // by an even power of two, which 0x04000208 is not. 0x04000000 (the base address for I/O // registers) is, so that's loaded into register zero. Then, exploiting the fact that the // LSB of 0x04000000 is 0, we store that into IME and the upper bits are ignored. mov r0, #0x04000000 str r0, [r0, #0x208] // Wait for vertical sync. // Note: The syntax ``.L<name>`` signifies a local label, which isn't exported as a symbol // in the final compiled object. .Lvsync: // Load half-word at REG_DISP_VCOUNT. R0 was already the base of the I/O registers, so we // can just add 0x6 to it to load it into R1. ldrh r1, [r0, #0x6] // Compare to 0x0 and set the comparison flag. cmp r1, #0 // Branch if not equal back to the VSYNC label. bne .Lvsync // Jump to a separate function to set up the CP15. There's a lot of noise that we don't // really want clogging up our main function. bl setup_coprocessor // Stack setup for every mode // 0b10010 == 0x12, IRQ mode mov r0, #0x12 msr cpsr, r0 ldr sp, =__stack_start_irq // 0b10011 == 0x13, Supervisor mode mov r0, #0x13 msr cpsr, r0 ldr sp, =__stack_start_svc // 0b11111 == 0x1f, System mode mov r0, #0x1f msr cpsr, r0 ldr sp, =__stack_start_sys // Clear BSS ldr r2, =__bss_size ldr r1, =__bss_start mov r0, #0 bl _ASM_primitive_memset // Less of a minefield to just set the IRQ handler in ``_start`` ldr r0, =irq_handler ldr r1, =__dtcm_region_end str r0, [r1] // After all of our setup is done, we can finally switch to main. // For future-proofing, we do a branch-with-exchange in case ``main`` ends up as a thumb // function. ldr r0, =main blx r0 // Uh oh, somebody returned from main! // Set IME to 0 and halt the CPU to prevent further damage. mov r0, #0x04000000 str r0, [r0, #0x208] .Lhalt: swi #0x60000 b .Lhalt
StarlightConsole/Starlight
3,096
src/arch/aarch64/exception.s
/// call the function provided by paramter `\handler` after saving the exeption context /// provide the context as the first parameter to `\handler` .macro CALL_WITH_CONTEXT handler __vector_\handler: // make room on the stack for the exception context sub sp, sp, #16 * 17 // store all general purpose registers on the stack stp x0, x1, [sp, #16 * 0] stp x2, x3, [sp, #16 * 1] stp x4, x5, [sp, #16 * 2] stp x6, x7, [sp, #16 * 3] stp x8, x9, [sp, #16 * 4] stp x10, x11, [sp, #16 * 5] stp x12, x13, [sp, #16 * 6] stp x14, x15, [sp, #16 * 7] stp x16, x17, [sp, #16 * 8] stp x18, x19, [sp, #16 * 9] stp x20, x21, [sp, #16 * 10] stp x22, x23, [sp, #16 * 11] stp x24, x25, [sp, #16 * 12] stp x26, x27, [sp, #16 * 13] stp x28, x29, [sp, #16 * 14] // add the exception link register (ELR_EL1), saved program status (SPSR_EL1) and exception syndrome register (ESR_EL1) mrs x1, ELR_EL1 mrs x2, SPSR_EL1 mrs x3, ESR_EL1 stp lr, x1, [sp, #16 * 15] stp x2, x3, [sp, #16 * 16] // x0 is the first argument for the function called through `\handler` mov x0, sp // call `\handler` bl \handler // after returning from exception handling code, replay the saved context and return via `eret` b __exception_restore_context .size __vector_\handler, . - __vector_\handler .type __vector_\handler, function .endm .macro FIQ_SUSPEND 1: wfe b 1b .endm .section .text // align by 2^11 bytes as demanded by ARMv8-A, same as ALIGN(2048) in an ld script .align 11 // export a symbol for the Rust code to use // # safety // - it must be ensured that `CALL_WITH_CONTEXT` <= 0x80 bytes __exception_vector_table_start: // SP_EL0 .org 0x000 CALL_WITH_CONTEXT current_el0_synchronous .org 0x080 CALL_WITH_CONTEXT current_el0_irq .org 0x100 FIQ_SUSPEND .org 0x180 CALL_WITH_CONTEXT current_el0_serror // SP_ELx, x > 0 .org 0x200 CALL_WITH_CONTEXT current_elx_synchronous .org 0x280 CALL_WITH_CONTEXT current_elx_irq .org 0x300 FIQ_SUSPEND .org 0x380 CALL_WITH_CONTEXT current_elx_serror // lower, aarch64 .org 0x400 CALL_WITH_CONTEXT lower_aarch64_synchronous .org 0x480 CALL_WITH_CONTEXT lower_aarch64_irq .org 0x500 FIQ_SUSPEND .org 0x580 CALL_WITH_CONTEXT lower_aarch64_serror // lower, aarch32 .org 0x600 CALL_WITH_CONTEXT lower_aarch32_synchronous .org 0x680 CALL_WITH_CONTEXT lower_aarch32_irq .org 0x700 FIQ_SUSPEND .org 0x780 CALL_WITH_CONTEXT lower_aarch32_serror __exception_restore_context: ldr w19, [sp, #16 * 16] ldp lr, x20, [sp, #16 * 15] msr SPSR_EL1, x19 msr ELR_EL1, x20 ldp x0, x1, [sp, #16 * 0] ldp x2, x3, [sp, #16 * 1] ldp x4, x5, [sp, #16 * 2] ldp x6, x7, [sp, #16 * 3] ldp x8, x9, [sp, #16 * 4] ldp x10, x11, [sp, #16 * 5] ldp x12, x13, [sp, #16 * 6] ldp x14, x15, [sp, #16 * 7] ldp x16, x17, [sp, #16 * 8] ldp x18, x19, [sp, #16 * 9] ldp x20, x21, [sp, #16 * 10] ldp x22, x23, [sp, #16 * 11] ldp x24, x25, [sp, #16 * 12] ldp x26, x27, [sp, #16 * 13] ldp x28, x29, [sp, #16 * 14] add sp, sp, #16 * 17 eret .size __exception_restore_context, . - __exception_restore_context .type __exception_restore_context, function
StarlightConsole/Starlight
1,761
src/arch/aarch64/cpu/boot.s
// loads the address of a symbol into a register, relative .macro ADR_REL register, symbol adrp \register, \symbol add \register, \register, #:lo12:\symbol .endm .macro ADR_ABS register, symbol movz \register, #:abs_g3:\symbol movk \register, #:abs_g2_nc:\symbol movk \register, #:abs_g1_nc:\symbol movk \register, #:abs_g0_nc:\symbol .endm // fn _start() .section .text._start _start: // only proceed if the core executes in EL2, park otherwise mrs x0, CurrentEL cmp x0, {CONST_CURRENTEL_EL2} b.ne .L_parking_loop // only proceed on the boot core mrs x1, MPIDR_EL1 and x1, x1, {CONST_CORE_ID_MASK} ldr x2, BOOT_CORE_ID // provided by bsp/*/cpu.rs cmp x1, x2 b.ne .L_parking_loop // this is the boot core // init DRAM ADR_REL x0, __bss_start ADR_REL x1, __bss_end_exclusive .L_bss_init_loop: cmp x0, x1 b.eq .L_prepare_rust stp xzr, xzr, [x0], #16 b .L_bss_init_loop // prepare the jump to rust code .L_prepare_rust: // load the base address of the kernel's translation tables ldr x0, PHYS_KERNEL_TABLES_BASE_ADDR // provided by bsp/*/memory/mmu.rs // load the absolute addresses of the following symbols ADR_ABS x1, __boot_core_stack_end_exclusive ADR_ABS x2, kernel_init // set the stack pointer ensuring EL2 code can use the stack ADR_REL x3, __boot_core_stack_end_exclusive mov sp, x3 // get the cpu's timer counter frequency ADR_REL x4, ARCH_TIMER_COUNTER_FREQUENCY // provided by aarch64/time.rs mrs x5, CNTFRQ_EL0 cmp x5, xzr b.eq .L_parking_loop str w5, [x4] // jump to rust code, x0, x1 and x2 hold the function arguments provided to _start_rust() b _start_rust // wait for events indefinitely .L_parking_loop: wfe b .L_parking_loop .size _start, . - _start .type _start, function .global _start
StarlightConsole/Starship
1,360
src/arch/aarch64/cpu/boot.s
// loads the address of a symbol into a register, relative .macro ADR_REL register, symbol adrp \register, \symbol add \register, \register, #:lo12:\symbol .endm // loads the address of a symbol into a register, absolute .macro ADR_ABS register, symbol movz \register, #:abs_g2:\symbol movk \register, #:abs_g1_nc:\symbol movk \register, #:abs_g0_nc:\symbol .endm // fn _start() .section .text._start _start: // only proceed on the boot core mrs x0, MPIDR_EL1 and x0, x0, {CONST_CORE_ID_MASK} ldr x1, BOOT_CORE_ID // provided by bsp/__board__/cpu.rs cmp x0, x1 b.ne .L_parking_loop // this is the boot core // init DRAM ADR_ABS x0, __bss_start ADR_ABS x1, __bss_end_exclusive .L_bss_init_loop: cmp x0, x1 b.eq .L_relocate_binary stp xzr, xzr, [x0], #16 b .L_bss_init_loop // relocate the binary .L_relocate_binary: ADR_REL x0, __binary_nonzero_start // loaded addr ADR_ABS x1, __binary_nonzero_start // linked addr ADR_ABS x2, __binary_nonzero_end_exclusive .L_copy_loop: ldr x3, [x0], #8 str x3, [x1], #8 cmp x1, x2 b.lo .L_copy_loop // set the stack pointer ADR_ABS x0, __boot_core_stack_end_exclusive mov sp, x0 // jump to the relocated rust code ADR_ABS x1, _start_rust br x1 // wait for events indefinitely .L_parking_loop: wfe b .L_parking_loop .size _start, . - _start .type _start, function .global _start
Starry-Mix-THU/arceos-backup
2,544
tools/raspi4/chainloader/src/_arch/aarch64/cpu/boot.s
// SPDX-License-Identifier: MIT OR Apache-2.0 // // Copyright (c) 2021-2022 Andre Richter <andre.o.richter@gmail.com> //-------------------------------------------------------------------------------------------------- // Definitions //-------------------------------------------------------------------------------------------------- // Load the address of a symbol into a register, PC-relative. // // The symbol must lie within +/- 4 GiB of the Program Counter. // // # Resources // // - https://sourceware.org/binutils/docs-2.36/as/AArch64_002dRelocations.html .macro ADR_REL register, symbol adrp \register, \symbol add \register, \register, #:lo12:\symbol .endm // Load the address of a symbol into a register, absolute. // // # Resources // // - https://sourceware.org/binutils/docs-2.36/as/AArch64_002dRelocations.html .macro ADR_ABS register, symbol movz \register, #:abs_g2:\symbol movk \register, #:abs_g1_nc:\symbol movk \register, #:abs_g0_nc:\symbol .endm //-------------------------------------------------------------------------------------------------- // Public Code //-------------------------------------------------------------------------------------------------- .section .text._start //------------------------------------------------------------------------------ // fn _start() //------------------------------------------------------------------------------ _start: // Only proceed on the boot core. Park it otherwise. mrs x0, MPIDR_EL1 and x0, x0, {CONST_CORE_ID_MASK} ldr x1, BOOT_CORE_ID // provided by bsp/__board_name__/cpu.rs cmp x0, x1 b.ne .L_parking_loop // If execution reaches here, it is the boot core. // Initialize DRAM. ADR_ABS x0, __bss_start ADR_ABS x1, __bss_end_exclusive .L_bss_init_loop: cmp x0, x1 b.eq .L_relocate_binary stp xzr, xzr, [x0], #16 b .L_bss_init_loop // Next, relocate the binary. .L_relocate_binary: ADR_REL x0, __binary_nonzero_start // The address the binary got loaded to. ADR_ABS x1, __binary_nonzero_start // The address the binary was linked to. ADR_ABS x2, __binary_nonzero_end_exclusive .L_copy_loop: ldr x3, [x0], #8 str x3, [x1], #8 cmp x1, x2 b.lo .L_copy_loop // Prepare the jump to Rust code. // Set the stack pointer. ADR_ABS x0, __boot_core_stack_end_exclusive mov sp, x0 // Jump to the relocated Rust code. ADR_ABS x1, _start_rust br x1 // Infinitely wait for events (aka "park the core"). .L_parking_loop: wfe b .L_parking_loop .size _start, . - _start .type _start, function .global _start
Starry-Mix-THU/arceos-backup
2,904
modules/axhal/linker.lds.S
OUTPUT_ARCH(%ARCH%) BASE_ADDRESS = %KERNEL_BASE%; ENTRY(_start) SECTIONS { . = BASE_ADDRESS; _skernel = .; .text : ALIGN(4K) { _stext = .; *(.text.boot) *(.text .text.*) . = ALIGN(4K); _etext = .; } _srodata = .; .rodata : ALIGN(4K) { *(.rodata .rodata.*) *(.srodata .srodata.*) *(.sdata2 .sdata2.*) } .init_array : ALIGN(0x10) { __init_array_start = .; *(.init_array .init_array.*) __init_array_end = .; } .debug : { _debug_start = .; . += SIZEOF(.debug_abbrev); _debug_abbrev_end = .; . += SIZEOF(.debug_addr); _debug_addr_end = .; . += SIZEOF(.debug_aranges); _debug_aranges_end = .; . += SIZEOF(.debug_info); _debug_info_end = .; . += SIZEOF(.debug_line); _debug_line_end = .; . += SIZEOF(.debug_line_str); _debug_line_str_end = .; . += SIZEOF(.debug_ranges); _debug_ranges_end = .; . += SIZEOF(.debug_rnglists); _debug_rnglists_end = .; . += SIZEOF(.debug_str); _debug_str_end = .; . += SIZEOF(.debug_str_offsets); _debug_str_offsets_end = .; } . = ALIGN(4K); _erodata = .; .data : ALIGN(4K) { _sdata = .; *(.data.boot_page_table) . = ALIGN(4K); *(.data .data.*) *(.sdata .sdata.*) *(.got .got.*) } .tdata : ALIGN(0x10) { _stdata = .; *(.tdata .tdata.*) _etdata = .; } .tbss : ALIGN(0x10) { _stbss = .; *(.tbss .tbss.*) *(.tcommon) _etbss = .; } . = ALIGN(4K); _percpu_start = .; _percpu_end = _percpu_start + SIZEOF(.percpu); .percpu 0x0 : AT(_percpu_start) { _percpu_load_start = .; *(.percpu .percpu.*) _percpu_load_end = .; . = _percpu_load_start + ALIGN(64) * %SMP%; } . = _percpu_end; . = ALIGN(4K); _edata = .; .bss : AT(.) ALIGN(4K) { boot_stack = .; *(.bss.stack) . = ALIGN(4K); boot_stack_top = .; _sbss = .; *(.bss .bss.*) *(.sbss .sbss.*) *(COMMON) . = ALIGN(4K); _ebss = .; } _ekernel = .; /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) } } SECTIONS { linkme_IRQ : { *(linkme_IRQ) } linkm2_IRQ : { *(linkm2_IRQ) } linkme_PAGE_FAULT : { *(linkme_PAGE_FAULT) } linkm2_PAGE_FAULT : { *(linkm2_PAGE_FAULT) } linkme_SYSCALL : { *(linkme_SYSCALL) } linkm2_SYSCALL : { *(linkm2_SYSCALL) } linkme_PRE_TRAP : { *(linkme_PRE_TRAP) } linkm2_PRE_TRAP : { *(linkm2_PRE_TRAP) } linkme_POST_TRAP : { *(linkme_POST_TRAP) } linkm2_POST_TRAP : { *(linkm2_POST_TRAP) } scope_local : { *(scope_local) } } INSERT AFTER .tbss;
Starry-Mix-THU/arceos-backup
1,791
modules/axhal/src/arch/loongarch64/trap.S
.macro SAVE_REGS, from_user move $t0, $sp .if \from_user == 1 csrrd $sp, KSAVE_KSP // restore kernel sp addi.d $sp, $sp, -{trapframe_size} STD $tp, $sp, 2 STD $r21, $sp, 21 csrrd $tp, KSAVE_TP csrrd $r21, KSAVE_R21 .else addi.d $sp, $sp, -{trapframe_size} .endif STD $t0, $sp, 3 csrrd $t0, KSAVE_TEMP PUSH_GENERAL_REGS csrrd $t1, LA_CSR_PRMD csrrd $t2, LA_CSR_ERA STD $t1, $sp, 32 // prmd STD $t2, $sp, 33 // era .endm .macro RESTORE_REGS, from_user .if \from_user == 1 csrwr $tp, KSAVE_TP csrwr $r21, KSAVE_R21 LDD $tp, $sp, 2 LDD $r21, $sp, 21 addi.d $t1, $sp, {trapframe_size} csrwr $t1, KSAVE_KSP // save kernel sp .endif LDD $t1, $sp, 33 // era LDD $t2, $sp, 32 // prmd csrwr $t1, LA_CSR_ERA csrwr $t2, LA_CSR_PRMD POP_GENERAL_REGS LDD $sp, $sp, 3 .endm .section .text .balign 4096 .global exception_entry_base exception_entry_base: csrwr $t0, KSAVE_TEMP csrrd $t0, LA_CSR_PRMD andi $t0, $t0, 0x3 bnez $t0, .Lfrom_userspace .Lfrom_kernel: SAVE_REGS 0 move $a0, $sp addi.d $a1, $zero, 0 bl loongarch64_trap_handler RESTORE_REGS 0 ertn .Lfrom_userspace: SAVE_REGS 1 move $a0, $sp addi.d $a1, $zero, 1 bl loongarch64_trap_handler RESTORE_REGS 1 ertn .section .text .balign 4096 .global handle_tlb_refill handle_tlb_refill: csrwr $t0, LA_CSR_TLBRSAVE csrrd $t0, LA_CSR_PGD lddir $t0, $t0, 3 lddir $t0, $t0, 2 lddir $t0, $t0, 1 ldpte $t0, 0 ldpte $t0, 1 tlbfill csrrd $t0, LA_CSR_TLBRSAVE ertn
Starry-Mix-THU/arceos-backup
2,989
modules/axhal/src/arch/aarch64/trap.S
.macro SAVE_REGS sub sp, sp, {trapframe_size} stp x0, x1, [sp] stp x2, x3, [sp, 2 * 8] stp x4, x5, [sp, 4 * 8] stp x6, x7, [sp, 6 * 8] stp x8, x9, [sp, 8 * 8] stp x10, x11, [sp, 10 * 8] stp x12, x13, [sp, 12 * 8] stp x14, x15, [sp, 14 * 8] stp x16, x17, [sp, 16 * 8] stp x18, x19, [sp, 18 * 8] stp x20, x21, [sp, 20 * 8] stp x22, x23, [sp, 22 * 8] stp x24, x25, [sp, 24 * 8] stp x26, x27, [sp, 26 * 8] stp x28, x29, [sp, 28 * 8] str x30, [sp, 30 * 8] mrs x9, sp_el0 mrs x10, tpidr_el0 mrs x11, elr_el1 mrs x12, spsr_el1 stp x9, x10, [sp, 31 * 8] stp x11, x12, [sp, 33 * 8] # restore kernel tpidr_el0 mrs x1, tpidrro_el0 msr tpidr_el0, x1 # We may have interrupted userspace, or a guest, or exit-from or # return-to either of those. So we can't trust sp_el0, and need to # restore it. bl {cache_current_task_ptr} .endm .macro RESTORE_REGS # backup kernel tpidr_el0 mrs x1, tpidr_el0 msr tpidrro_el0, x1 ldp x11, x12, [sp, 33 * 8] ldp x9, x10, [sp, 31 * 8] msr sp_el0, x9 msr tpidr_el0, x10 msr elr_el1, x11 msr spsr_el1, x12 ldr x30, [sp, 30 * 8] ldp x28, x29, [sp, 28 * 8] ldp x26, x27, [sp, 26 * 8] ldp x24, x25, [sp, 24 * 8] ldp x22, x23, [sp, 22 * 8] ldp x20, x21, [sp, 20 * 8] ldp x18, x19, [sp, 18 * 8] ldp x16, x17, [sp, 16 * 8] ldp x14, x15, [sp, 14 * 8] ldp x12, x13, [sp, 12 * 8] ldp x10, x11, [sp, 10 * 8] ldp x8, x9, [sp, 8 * 8] ldp x6, x7, [sp, 6 * 8] ldp x4, x5, [sp, 4 * 8] ldp x2, x3, [sp, 2 * 8] ldp x0, x1, [sp] add sp, sp, {trapframe_size} .endm .macro INVALID_EXCP, kind, source .p2align 7 SAVE_REGS mov x0, sp mov x1, \kind mov x2, \source bl invalid_exception b .Lexception_return .endm .macro HANDLE_SYNC, source .p2align 7 SAVE_REGS mov x0, sp mov x1, \source bl handle_sync_exception b .Lexception_return .endm .macro HANDLE_IRQ, source .p2align 7 SAVE_REGS mov x0, sp mov x1, \source bl handle_irq_exception b .Lexception_return .endm .section .text .p2align 11 .global exception_vector_base exception_vector_base: // current EL, with SP_EL0 INVALID_EXCP 0 0 INVALID_EXCP 1 0 INVALID_EXCP 2 0 INVALID_EXCP 3 0 // current EL, with SP_ELx HANDLE_SYNC 1 HANDLE_IRQ 1 INVALID_EXCP 2 1 INVALID_EXCP 3 1 // lower EL, aarch64 HANDLE_SYNC 2 HANDLE_IRQ 2 INVALID_EXCP 2 2 INVALID_EXCP 3 2 // lower EL, aarch32 INVALID_EXCP 0 3 INVALID_EXCP 1 3 INVALID_EXCP 2 3 INVALID_EXCP 3 3 .Lexception_return: RESTORE_REGS eret
Starry-Mix-THU/arceos-backup
2,285
modules/axhal/src/arch/riscv/trap.S
.macro SAVE_REGS, from_user addi sp, sp, -{trapframe_size} PUSH_GENERAL_REGS csrr t0, sepc csrr t1, sstatus csrrw t2, sscratch, zero // save sscratch (sp) and zero it STR t0, sp, 32 // tf.sepc STR t1, sp, 33 // tf.sstatus STR t2, sp, 2 // tf.regs.sp .if \from_user == 1 LDR t0, sp, 3 // load supervisor gp and tp LDR t1, sp, 4 STR gp, sp, 3 // save user gp and tp STR tp, sp, 4 mv gp, t0 mv tp, t1 .endif .endm .macro RESTORE_REGS, from_user .if \from_user == 1 LDR t1, sp, 3 // load user gp and tp LDR t0, sp, 4 STR gp, sp, 3 // save supervisor gp and tp STR tp, sp, 4 mv gp, t1 mv tp, t0 addi t0, sp, {trapframe_size} // put supervisor sp to scratch csrw sscratch, t0 .endif // restore sepc LDR t0, sp, 32 csrw sepc, t0 // restore sstatus, but don't change FS LDR t0, sp, 33 // t0 = sstatus to restore csrr t1, sstatus // t1 = current sstatus li t2, 0x6000 // t2 = mask for FS and t1, t1, t2 // t1 = current FS not t2, t2 // t2 = ~(mask for FS) and t0, t0, t2 // t0 = sstatus to restore(cleared FS) or t0, t0, t1 // t0 = sstatus to restore with current FS csrw sstatus, t0 // restore sstatus POP_GENERAL_REGS LDR sp, sp, 2 // load sp from tf.regs.sp .endm .section .text .balign 4 .global trap_vector_base trap_vector_base: // sscratch == 0: trap from S mode // sscratch != 0: trap from U mode csrrw sp, sscratch, sp // swap sscratch and sp bnez sp, .Ltrap_entry_u csrr sp, sscratch // put supervisor sp back j .Ltrap_entry_s .Ltrap_entry_s: SAVE_REGS 0 mv a0, sp li a1, 0 call riscv_trap_handler RESTORE_REGS 0 sret .Ltrap_entry_u: SAVE_REGS 1 mv a0, sp li a1, 1 call riscv_trap_handler RESTORE_REGS 1 sret
Starry-Mix-THU/arceos-backup
1,627
modules/axhal/src/arch/x86_64/trap.S
.equ NUM_INT, 256 .altmacro .macro DEF_HANDLER, i .Ltrap_handler_\i: .if \i == 8 || (\i >= 10 && \i <= 14) || \i == 17 # error code pushed by CPU push \i # interrupt vector jmp .Ltrap_common .else push 0 # fill in error code in TrapFrame push \i # interrupt vector jmp .Ltrap_common .endif .endm .macro DEF_TABLE_ENTRY, i .quad .Ltrap_handler_\i .endm .section .text .code64 _trap_handlers: .set i, 0 .rept NUM_INT DEF_HANDLER %i .set i, i + 1 .endr .Ltrap_common: test byte ptr [rsp + 3 * 8], 3 # swap GS if it comes from user space jz 1f swapgs 1: sub rsp, 16 # reserve space for fs_base push r15 push r14 push r13 push r12 push r11 push r10 push r9 push r8 push rdi push rsi push rbp push rbx push rdx push rcx push rax mov rdi, rsp call x86_trap_handler pop rax pop rcx pop rdx pop rbx pop rbp pop rsi pop rdi pop r8 pop r9 pop r10 pop r11 pop r12 pop r13 pop r14 pop r15 add rsp, 16 # pop fs_base test byte ptr [rsp + 3 * 8], 3 # swap GS back if return to user space jz 2f swapgs 2: add rsp, 16 # pop vector, error_code iretq .section .rodata .global trap_handler_table trap_handler_table: .set i, 0 .rept NUM_INT DEF_TABLE_ENTRY %i .set i, i + 1 .endr
Starry-Mix-THU/arceos-backup
1,397
modules/axhal/src/arch/x86_64/syscall.S
.section .text .code64 syscall_entry: swapgs // switch to kernel gs mov gs:[offset __PERCPU_USER_RSP_OFFSET], rsp // save user rsp mov rsp, gs:[offset __PERCPU_TSS + {tss_rsp0_offset}] // switch to kernel stack sub rsp, 8 // skip user ss push gs:[offset __PERCPU_USER_RSP_OFFSET] // user rsp push r11 // rflags push {ucode64} // cs push rcx // rip sub rsp, 4 * 8 // skip until general registers push r15 push r14 push r13 push r12 push r11 push r10 push r9 push r8 push rdi push rsi push rbp push rbx push rdx push rcx push rax mov rdi, rsp call x86_syscall_handler pop rax pop rcx pop rdx pop rbx pop rbp pop rsi pop rdi pop r8 pop r9 pop r10 pop r11 pop r12 pop r13 pop r14 pop r15 add rsp, 9 * 8 mov rcx, [rsp - 5 * 8] // rip mov r11, [rsp - 3 * 8] // rflags mov rsp, [rsp - 2 * 8] // user rsp swapgs sysretq
Starry-Mix-THU/arceos-backup
1,965
modules/axhal/src/platform/x86_pc/ap_start.S
# Boot application processors into the protected mode. # Each non-boot CPU ("AP") is started up in response to a STARTUP # IPI from the boot CPU. Section B.4.2 of the Multi-Processor # Specification says that the AP will start in real mode with CS:IP # set to XY00:0000, where XY is an 8-bit value sent with the # STARTUP. Thus this code must start at a 4096-byte boundary. # # Because this code sets DS to zero, it must sit # at an address in the low 2^16 bytes. .equ pa_ap_start32, ap_start32 - ap_start + {start_page_paddr} .equ pa_ap_gdt, .Lap_tmp_gdt - ap_start + {start_page_paddr} .equ pa_ap_gdt_desc, .Lap_tmp_gdt_desc - ap_start + {start_page_paddr} .equ stack_ptr, {start_page_paddr} + 0xff0 .equ entry_ptr, {start_page_paddr} + 0xff8 # 0x6000 .section .text .code16 .p2align 12 .global ap_start ap_start: cli wbinvd xor ax, ax mov ds, ax mov es, ax mov ss, ax mov fs, ax mov gs, ax # load the 64-bit GDT lgdt [pa_ap_gdt_desc] # switch to protected-mode mov eax, cr0 or eax, (1 << 0) mov cr0, eax # far jump to 32-bit code. 0x8 is code32 segment selector ljmp 0x8, offset pa_ap_start32 .code32 ap_start32: mov esp, [stack_ptr] mov eax, [entry_ptr] jmp eax .balign 8 # .type multiboot_header, STT_OBJECT .Lap_tmp_gdt_desc: .short .Lap_tmp_gdt_end - .Lap_tmp_gdt - 1 # limit .long pa_ap_gdt # base .balign 16 .Lap_tmp_gdt: .quad 0x0000000000000000 # 0x00: null .quad 0x00cf9b000000ffff # 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) .quad 0x00af9b000000ffff # 0x10: code segment (base=0, limit=0xfffff, type=64bit code exec/read, DPL=0, 4k) .quad 0x00cf93000000ffff # 0x18: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) .Lap_tmp_gdt_end: # 0x7000 .p2align 12 .global ap_end ap_end:
Starry-Mix-THU/arceos-backup
4,325
modules/axhal/src/platform/x86_pc/multiboot.S
# Bootstrapping from 32-bit with the Multiboot specification. # See https://www.gnu.org/software/grub/manual/multiboot/multiboot.html .section .text.boot .code32 .global _start _start: mov edi, eax # arg1: magic: 0x2BADB002 mov esi, ebx # arg2: multiboot info jmp bsp_entry32 .balign 4 .type multiboot_header, STT_OBJECT multiboot_header: .int {mb_hdr_magic} # magic: 0x1BADB002 .int {mb_hdr_flags} # flags .int -({mb_hdr_magic} + {mb_hdr_flags}) # checksum .int multiboot_header - {offset} # header_addr .int _skernel - {offset} # load_addr .int _edata - {offset} # load_end .int _ebss - {offset} # bss_end_addr .int _start - {offset} # entry_addr # Common code in 32-bit, prepare states to enter 64-bit. .macro ENTRY32_COMMON # set data segment selectors mov ax, 0x18 mov ss, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax # set PAE, PGE bit in CR4 mov eax, {cr4} mov cr4, eax # load the temporary page table lea eax, [.Ltmp_pml4 - {offset}] mov cr3, eax # set LME, NXE bit in IA32_EFER mov ecx, {efer_msr} mov edx, 0 mov eax, {efer} wrmsr # set protected mode, write protect, paging bit in CR0 mov eax, {cr0} mov cr0, eax .endm # Common code in 64-bit .macro ENTRY64_COMMON # clear segment selectors xor ax, ax mov ss, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax .endm .code32 bsp_entry32: lgdt [.Ltmp_gdt_desc - {offset}] # load the temporary GDT ENTRY32_COMMON ljmp 0x10, offset bsp_entry64 - {offset} # 0x10 is code64 segment .code32 .global ap_entry32 ap_entry32: ENTRY32_COMMON ljmp 0x10, offset ap_entry64 - {offset} # 0x10 is code64 segment .code64 bsp_entry64: ENTRY64_COMMON # set RSP to boot stack movabs rsp, offset {boot_stack} add rsp, {boot_stack_size} # call rust_entry(magic, mbi) movabs rax, offset {entry} call rax jmp .Lhlt .code64 ap_entry64: ENTRY64_COMMON # set RSP to high address (already set in ap_start.S) mov rax, {offset} add rsp, rax # call rust_entry_secondary(magic) mov rdi, {mb_magic} movabs rax, offset {entry_secondary} call rax jmp .Lhlt .Lhlt: hlt jmp .Lhlt .section .rodata .balign 8 .Ltmp_gdt_desc: .short .Ltmp_gdt_end - .Ltmp_gdt - 1 # limit .long .Ltmp_gdt - {offset} # base .section .data .balign 16 .Ltmp_gdt: .quad 0x0000000000000000 # 0x00: null .quad 0x00cf9b000000ffff # 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) .quad 0x00af9b000000ffff # 0x10: code segment (base=0, limit=0xfffff, type=64bit code exec/read, DPL=0, 4k) .quad 0x00cf93000000ffff # 0x18: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) .Ltmp_gdt_end: .balign 4096 .Ltmp_pml4: # 0x0000_0000 ~ 0xffff_ffff .quad .Ltmp_pdpt_low - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt) .zero 8 * 255 # 0xffff_8000_0000_0000 ~ 0xffff_8000_ffff_ffff .quad .Ltmp_pdpt_high - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt) .zero 8 * 255 # FIXME: may not work on macOS using hvf as the CPU does not support 1GB page (pdpe1gb) .Ltmp_pdpt_low: .quad 0x0000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x0) .quad 0x40000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x4000_0000) .quad 0x80000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x8000_0000) .quad 0xc0000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0xc000_0000) .zero 8 * 508 .Ltmp_pdpt_high: .quad 0x0000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x0) .quad 0x40000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x4000_0000) .quad 0x80000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0x8000_0000) .quad 0xc0000000 | 0x83 # PRESENT | WRITABLE | HUGE_PAGE | paddr(0xc000_0000) .zero 8 * 508
STashakkori/Rustyvisor_REPAIRED
8,669
uefi/src/isr.S
.intel_syntax noprefix .extern interrupts_dispatcher .global _service_interrupt _service_interrupt: /* Save all registers. */ push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 /* We don't need to clear the high bits of rax but we do anyway */ xor rax, rax /* Save data segment. */ mov ax, ds push rax mov ax, es push rax mov ax, fs push rax mov ax, gs push rax # Load kernel data segment. mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov rcx, rsp /* Call interrupt dispatcher. */ .dispatch: .extern interrupt_dispatcher call interrupt_dispatcher /* Restore data segment. */ pop rax mov ds, ax pop rax mov es, ax pop rax mov fs, ax pop rax mov gs, ax /* Restore all registers. */ pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp pop rdx pop rcx pop rbx pop rax .global iret iret: # Add back extra bit pushed to the stack by the interrupt handler. add rsp, 16 iretq # Certain interrupts push an error code to the stack. # When one of these interrupts happens, push the interrupt number after # the error code which is already on the stack. .macro interrupt number .global _isr\number _isr\number: cli push \number jmp _service_interrupt .endm # Other interrupts don't push an error code to the stack. In the name of # consistency, push a dummy value, and then the interrupt number .macro no_error_code_interrupt number .global _isr\number _isr\number: cli push 0 push \number jmp _service_interrupt .endm no_error_code_interrupt 0 no_error_code_interrupt 1 no_error_code_interrupt 2 no_error_code_interrupt 3 no_error_code_interrupt 4 no_error_code_interrupt 5 no_error_code_interrupt 6 no_error_code_interrupt 7 interrupt 8 no_error_code_interrupt 9 interrupt 10 interrupt 11 interrupt 12 interrupt 13 interrupt 14 no_error_code_interrupt 15 no_error_code_interrupt 16 interrupt 17 no_error_code_interrupt 18 no_error_code_interrupt 19 no_error_code_interrupt 20 # Filler irqs no_error_code_interrupt 21 no_error_code_interrupt 22 no_error_code_interrupt 23 no_error_code_interrupt 24 no_error_code_interrupt 25 no_error_code_interrupt 26 no_error_code_interrupt 27 no_error_code_interrupt 28 no_error_code_interrupt 29 # end of Filler irqs interrupt 30 no_error_code_interrupt 31 # User defined IRQs no_error_code_interrupt 32 no_error_code_interrupt 33 no_error_code_interrupt 34 no_error_code_interrupt 35 no_error_code_interrupt 36 no_error_code_interrupt 37 # End of user defined irqs no_error_code_interrupt 38 no_error_code_interrupt 39 no_error_code_interrupt 40 no_error_code_interrupt 41 no_error_code_interrupt 42 no_error_code_interrupt 43 no_error_code_interrupt 44 no_error_code_interrupt 45 no_error_code_interrupt 46 no_error_code_interrupt 47 no_error_code_interrupt 48 no_error_code_interrupt 49 no_error_code_interrupt 50 no_error_code_interrupt 51 no_error_code_interrupt 52 no_error_code_interrupt 53 no_error_code_interrupt 54 no_error_code_interrupt 55 no_error_code_interrupt 56 no_error_code_interrupt 57 no_error_code_interrupt 58 no_error_code_interrupt 59 no_error_code_interrupt 60 no_error_code_interrupt 61 no_error_code_interrupt 62 no_error_code_interrupt 63 no_error_code_interrupt 64 no_error_code_interrupt 65 no_error_code_interrupt 66 no_error_code_interrupt 67 no_error_code_interrupt 68 no_error_code_interrupt 69 no_error_code_interrupt 70 no_error_code_interrupt 71 no_error_code_interrupt 72 no_error_code_interrupt 73 no_error_code_interrupt 74 no_error_code_interrupt 75 no_error_code_interrupt 76 no_error_code_interrupt 77 no_error_code_interrupt 78 no_error_code_interrupt 79 no_error_code_interrupt 80 no_error_code_interrupt 81 no_error_code_interrupt 82 no_error_code_interrupt 83 no_error_code_interrupt 84 no_error_code_interrupt 85 no_error_code_interrupt 86 no_error_code_interrupt 87 no_error_code_interrupt 88 no_error_code_interrupt 89 no_error_code_interrupt 90 no_error_code_interrupt 91 no_error_code_interrupt 92 no_error_code_interrupt 93 no_error_code_interrupt 94 no_error_code_interrupt 95 no_error_code_interrupt 96 no_error_code_interrupt 97 no_error_code_interrupt 98 no_error_code_interrupt 99 no_error_code_interrupt 100 no_error_code_interrupt 101 no_error_code_interrupt 102 no_error_code_interrupt 103 no_error_code_interrupt 104 no_error_code_interrupt 105 no_error_code_interrupt 106 no_error_code_interrupt 107 no_error_code_interrupt 108 no_error_code_interrupt 109 no_error_code_interrupt 110 no_error_code_interrupt 111 no_error_code_interrupt 112 no_error_code_interrupt 113 no_error_code_interrupt 114 no_error_code_interrupt 115 no_error_code_interrupt 116 no_error_code_interrupt 117 no_error_code_interrupt 118 no_error_code_interrupt 119 no_error_code_interrupt 120 no_error_code_interrupt 121 no_error_code_interrupt 122 no_error_code_interrupt 123 no_error_code_interrupt 124 no_error_code_interrupt 125 no_error_code_interrupt 126 no_error_code_interrupt 127 no_error_code_interrupt 128 no_error_code_interrupt 129 no_error_code_interrupt 130 no_error_code_interrupt 131 no_error_code_interrupt 132 no_error_code_interrupt 133 no_error_code_interrupt 134 no_error_code_interrupt 135 no_error_code_interrupt 136 no_error_code_interrupt 137 no_error_code_interrupt 138 no_error_code_interrupt 139 no_error_code_interrupt 140 no_error_code_interrupt 141 no_error_code_interrupt 142 no_error_code_interrupt 143 no_error_code_interrupt 144 no_error_code_interrupt 145 no_error_code_interrupt 146 no_error_code_interrupt 147 no_error_code_interrupt 148 no_error_code_interrupt 149 no_error_code_interrupt 150 no_error_code_interrupt 151 no_error_code_interrupt 152 no_error_code_interrupt 153 no_error_code_interrupt 154 no_error_code_interrupt 155 no_error_code_interrupt 156 no_error_code_interrupt 157 no_error_code_interrupt 158 no_error_code_interrupt 159 no_error_code_interrupt 160 no_error_code_interrupt 161 no_error_code_interrupt 162 no_error_code_interrupt 163 no_error_code_interrupt 164 no_error_code_interrupt 165 no_error_code_interrupt 166 no_error_code_interrupt 167 no_error_code_interrupt 168 no_error_code_interrupt 169 no_error_code_interrupt 170 no_error_code_interrupt 171 no_error_code_interrupt 172 no_error_code_interrupt 173 no_error_code_interrupt 174 no_error_code_interrupt 175 no_error_code_interrupt 176 no_error_code_interrupt 177 no_error_code_interrupt 178 no_error_code_interrupt 179 no_error_code_interrupt 180 no_error_code_interrupt 181 no_error_code_interrupt 182 no_error_code_interrupt 183 no_error_code_interrupt 184 no_error_code_interrupt 185 no_error_code_interrupt 186 no_error_code_interrupt 187 no_error_code_interrupt 188 no_error_code_interrupt 189 no_error_code_interrupt 190 no_error_code_interrupt 191 no_error_code_interrupt 192 no_error_code_interrupt 193 no_error_code_interrupt 194 no_error_code_interrupt 195 no_error_code_interrupt 196 no_error_code_interrupt 197 no_error_code_interrupt 198 no_error_code_interrupt 199 no_error_code_interrupt 200 no_error_code_interrupt 201 no_error_code_interrupt 202 no_error_code_interrupt 203 no_error_code_interrupt 204 no_error_code_interrupt 205 no_error_code_interrupt 206 no_error_code_interrupt 207 no_error_code_interrupt 208 no_error_code_interrupt 209 no_error_code_interrupt 210 no_error_code_interrupt 211 no_error_code_interrupt 212 no_error_code_interrupt 213 no_error_code_interrupt 214 no_error_code_interrupt 215 no_error_code_interrupt 216 no_error_code_interrupt 217 no_error_code_interrupt 218 no_error_code_interrupt 219 no_error_code_interrupt 220 no_error_code_interrupt 221 no_error_code_interrupt 222 no_error_code_interrupt 223 no_error_code_interrupt 224 no_error_code_interrupt 225 no_error_code_interrupt 226 no_error_code_interrupt 227 no_error_code_interrupt 228 no_error_code_interrupt 229 no_error_code_interrupt 230 no_error_code_interrupt 231 no_error_code_interrupt 232 no_error_code_interrupt 233 no_error_code_interrupt 234 no_error_code_interrupt 235 no_error_code_interrupt 236 no_error_code_interrupt 237 no_error_code_interrupt 238 no_error_code_interrupt 239 no_error_code_interrupt 240 no_error_code_interrupt 241 no_error_code_interrupt 242 no_error_code_interrupt 243 no_error_code_interrupt 244 no_error_code_interrupt 245 no_error_code_interrupt 246 no_error_code_interrupt 247 no_error_code_interrupt 248 no_error_code_interrupt 249 no_error_code_interrupt 250 no_error_code_interrupt 251 no_error_code_interrupt 252 no_error_code_interrupt 253 no_error_code_interrupt 254 no_error_code_interrupt 255
STashakkori/Rustyvisor_REPAIRED
1,306
uefi/src/host_entrypoint.S
.intel_syntax noprefix .global _guest_first_entry _guest_first_entry: lea rcx, [rip+.guest_enters_here] mov rax, 0x0000681e // vmwrite Guest rip vmwrite rax, rcx jc .errorc jz .errorz mov rax, 0x00006820 // vmwrite Guest rflags pushfq pop rcx vmwrite rax, rcx jc .errorc jz .errorz mov rcx, rsp mov rax, 0x0000681c // vmwrite Guest rsp vmwrite rax, rcx jc .errorc jz .errorz vmlaunch jc .errorc jz .errorz .errorz: mov rax, 1 ret .errorc: mov rax, 2 ret .guest_enters_here: xor rax, rax ret .global _host_entrypoint _host_entrypoint: push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov rcx, rsp call hypervisor_handle_vmexit pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp pop rdx pop rcx pop rbx pop rax vmresume push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov rcx, rsp pushf pop rdx call hypervisor_vmresume_failure int3 .global platform_halt platform_halt: cli hlt jmp platform_halt
STashakkori/Rustyvisor_REPAIRED
8,669
linux/src/isr.S
.intel_syntax noprefix .extern interrupts_dispatcher .global _service_interrupt _service_interrupt: /* Save all registers. */ push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 /* We don't need to clear the high bits of rax but we do anyway */ xor rax, rax /* Save data segment. */ mov ax, ds push rax mov ax, es push rax mov ax, fs push rax mov ax, gs push rax # Load kernel data segment. mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov rdi, rsp /* Call interrupt dispatcher. */ .dispatch: .extern interrupt_dispatcher call interrupt_dispatcher /* Restore data segment. */ pop rax mov ds, ax pop rax mov es, ax pop rax mov fs, ax pop rax mov gs, ax /* Restore all registers. */ pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp pop rdx pop rcx pop rbx pop rax .global iret iret: # Add back extra bit pushed to the stack by the interrupt handler. add rsp, 16 iretq # Certain interrupts push an error code to the stack. # When one of these interrupts happens, push the interrupt number after # the error code which is already on the stack. .macro interrupt number .global _isr\number _isr\number: cli push \number jmp _service_interrupt .endm # Other interrupts don't push an error code to the stack. In the name of # consistency, push a dummy value, and then the interrupt number .macro no_error_code_interrupt number .global _isr\number _isr\number: cli push 0 push \number jmp _service_interrupt .endm no_error_code_interrupt 0 no_error_code_interrupt 1 no_error_code_interrupt 2 no_error_code_interrupt 3 no_error_code_interrupt 4 no_error_code_interrupt 5 no_error_code_interrupt 6 no_error_code_interrupt 7 interrupt 8 no_error_code_interrupt 9 interrupt 10 interrupt 11 interrupt 12 interrupt 13 interrupt 14 no_error_code_interrupt 15 no_error_code_interrupt 16 interrupt 17 no_error_code_interrupt 18 no_error_code_interrupt 19 no_error_code_interrupt 20 # Filler irqs no_error_code_interrupt 21 no_error_code_interrupt 22 no_error_code_interrupt 23 no_error_code_interrupt 24 no_error_code_interrupt 25 no_error_code_interrupt 26 no_error_code_interrupt 27 no_error_code_interrupt 28 no_error_code_interrupt 29 # end of Filler irqs interrupt 30 no_error_code_interrupt 31 # User defined IRQs no_error_code_interrupt 32 no_error_code_interrupt 33 no_error_code_interrupt 34 no_error_code_interrupt 35 no_error_code_interrupt 36 no_error_code_interrupt 37 # End of user defined irqs no_error_code_interrupt 38 no_error_code_interrupt 39 no_error_code_interrupt 40 no_error_code_interrupt 41 no_error_code_interrupt 42 no_error_code_interrupt 43 no_error_code_interrupt 44 no_error_code_interrupt 45 no_error_code_interrupt 46 no_error_code_interrupt 47 no_error_code_interrupt 48 no_error_code_interrupt 49 no_error_code_interrupt 50 no_error_code_interrupt 51 no_error_code_interrupt 52 no_error_code_interrupt 53 no_error_code_interrupt 54 no_error_code_interrupt 55 no_error_code_interrupt 56 no_error_code_interrupt 57 no_error_code_interrupt 58 no_error_code_interrupt 59 no_error_code_interrupt 60 no_error_code_interrupt 61 no_error_code_interrupt 62 no_error_code_interrupt 63 no_error_code_interrupt 64 no_error_code_interrupt 65 no_error_code_interrupt 66 no_error_code_interrupt 67 no_error_code_interrupt 68 no_error_code_interrupt 69 no_error_code_interrupt 70 no_error_code_interrupt 71 no_error_code_interrupt 72 no_error_code_interrupt 73 no_error_code_interrupt 74 no_error_code_interrupt 75 no_error_code_interrupt 76 no_error_code_interrupt 77 no_error_code_interrupt 78 no_error_code_interrupt 79 no_error_code_interrupt 80 no_error_code_interrupt 81 no_error_code_interrupt 82 no_error_code_interrupt 83 no_error_code_interrupt 84 no_error_code_interrupt 85 no_error_code_interrupt 86 no_error_code_interrupt 87 no_error_code_interrupt 88 no_error_code_interrupt 89 no_error_code_interrupt 90 no_error_code_interrupt 91 no_error_code_interrupt 92 no_error_code_interrupt 93 no_error_code_interrupt 94 no_error_code_interrupt 95 no_error_code_interrupt 96 no_error_code_interrupt 97 no_error_code_interrupt 98 no_error_code_interrupt 99 no_error_code_interrupt 100 no_error_code_interrupt 101 no_error_code_interrupt 102 no_error_code_interrupt 103 no_error_code_interrupt 104 no_error_code_interrupt 105 no_error_code_interrupt 106 no_error_code_interrupt 107 no_error_code_interrupt 108 no_error_code_interrupt 109 no_error_code_interrupt 110 no_error_code_interrupt 111 no_error_code_interrupt 112 no_error_code_interrupt 113 no_error_code_interrupt 114 no_error_code_interrupt 115 no_error_code_interrupt 116 no_error_code_interrupt 117 no_error_code_interrupt 118 no_error_code_interrupt 119 no_error_code_interrupt 120 no_error_code_interrupt 121 no_error_code_interrupt 122 no_error_code_interrupt 123 no_error_code_interrupt 124 no_error_code_interrupt 125 no_error_code_interrupt 126 no_error_code_interrupt 127 no_error_code_interrupt 128 no_error_code_interrupt 129 no_error_code_interrupt 130 no_error_code_interrupt 131 no_error_code_interrupt 132 no_error_code_interrupt 133 no_error_code_interrupt 134 no_error_code_interrupt 135 no_error_code_interrupt 136 no_error_code_interrupt 137 no_error_code_interrupt 138 no_error_code_interrupt 139 no_error_code_interrupt 140 no_error_code_interrupt 141 no_error_code_interrupt 142 no_error_code_interrupt 143 no_error_code_interrupt 144 no_error_code_interrupt 145 no_error_code_interrupt 146 no_error_code_interrupt 147 no_error_code_interrupt 148 no_error_code_interrupt 149 no_error_code_interrupt 150 no_error_code_interrupt 151 no_error_code_interrupt 152 no_error_code_interrupt 153 no_error_code_interrupt 154 no_error_code_interrupt 155 no_error_code_interrupt 156 no_error_code_interrupt 157 no_error_code_interrupt 158 no_error_code_interrupt 159 no_error_code_interrupt 160 no_error_code_interrupt 161 no_error_code_interrupt 162 no_error_code_interrupt 163 no_error_code_interrupt 164 no_error_code_interrupt 165 no_error_code_interrupt 166 no_error_code_interrupt 167 no_error_code_interrupt 168 no_error_code_interrupt 169 no_error_code_interrupt 170 no_error_code_interrupt 171 no_error_code_interrupt 172 no_error_code_interrupt 173 no_error_code_interrupt 174 no_error_code_interrupt 175 no_error_code_interrupt 176 no_error_code_interrupt 177 no_error_code_interrupt 178 no_error_code_interrupt 179 no_error_code_interrupt 180 no_error_code_interrupt 181 no_error_code_interrupt 182 no_error_code_interrupt 183 no_error_code_interrupt 184 no_error_code_interrupt 185 no_error_code_interrupt 186 no_error_code_interrupt 187 no_error_code_interrupt 188 no_error_code_interrupt 189 no_error_code_interrupt 190 no_error_code_interrupt 191 no_error_code_interrupt 192 no_error_code_interrupt 193 no_error_code_interrupt 194 no_error_code_interrupt 195 no_error_code_interrupt 196 no_error_code_interrupt 197 no_error_code_interrupt 198 no_error_code_interrupt 199 no_error_code_interrupt 200 no_error_code_interrupt 201 no_error_code_interrupt 202 no_error_code_interrupt 203 no_error_code_interrupt 204 no_error_code_interrupt 205 no_error_code_interrupt 206 no_error_code_interrupt 207 no_error_code_interrupt 208 no_error_code_interrupt 209 no_error_code_interrupt 210 no_error_code_interrupt 211 no_error_code_interrupt 212 no_error_code_interrupt 213 no_error_code_interrupt 214 no_error_code_interrupt 215 no_error_code_interrupt 216 no_error_code_interrupt 217 no_error_code_interrupt 218 no_error_code_interrupt 219 no_error_code_interrupt 220 no_error_code_interrupt 221 no_error_code_interrupt 222 no_error_code_interrupt 223 no_error_code_interrupt 224 no_error_code_interrupt 225 no_error_code_interrupt 226 no_error_code_interrupt 227 no_error_code_interrupt 228 no_error_code_interrupt 229 no_error_code_interrupt 230 no_error_code_interrupt 231 no_error_code_interrupt 232 no_error_code_interrupt 233 no_error_code_interrupt 234 no_error_code_interrupt 235 no_error_code_interrupt 236 no_error_code_interrupt 237 no_error_code_interrupt 238 no_error_code_interrupt 239 no_error_code_interrupt 240 no_error_code_interrupt 241 no_error_code_interrupt 242 no_error_code_interrupt 243 no_error_code_interrupt 244 no_error_code_interrupt 245 no_error_code_interrupt 246 no_error_code_interrupt 247 no_error_code_interrupt 248 no_error_code_interrupt 249 no_error_code_interrupt 250 no_error_code_interrupt 251 no_error_code_interrupt 252 no_error_code_interrupt 253 no_error_code_interrupt 254 no_error_code_interrupt 255
STashakkori/Rustyvisor_REPAIRED
1,306
linux/src/host_entrypoint.S
.intel_syntax noprefix .global _guest_first_entry _guest_first_entry: lea rdi, [rip+.guest_enters_here] mov rax, 0x0000681e // vmwrite Guest rip vmwrite rax, rdi jc .errorc jz .errorz mov rax, 0x00006820 // vmwrite Guest rflags pushfq pop rdi vmwrite rax, rdi jc .errorc jz .errorz mov rdi, rsp mov rax, 0x0000681c // vmwrite Guest rsp vmwrite rax, rdi jc .errorc jz .errorz vmlaunch jc .errorc jz .errorz .errorz: mov rax, 1 ret .errorc: mov rax, 2 ret .guest_enters_here: xor rax, rax ret .global _host_entrypoint _host_entrypoint: push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov rdi, rsp call hypervisor_handle_vmexit pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp pop rdx pop rcx pop rbx pop rax vmresume push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov rcx, rsp pushf pop rdx call hypervisor_vmresume_failure int3 .global platform_halt platform_halt: cli hlt jmp platform_halt
steve-anunknown/bytecode-assembler-generator
2,225
example/hello-world.s
JUMP 4b 0 PUSH1 0 PUSH1 a PUSH1 21 PUSH1 67 PUSH1 6e PUSH1 69 PUSH1 6b PUSH1 72 PUSH1 6f PUSH1 77 PUSH1 20 PUSH1 74 PUSH1 6f PUSH1 6e PUSH1 20 PUSH1 73 PUSH1 69 PUSH1 20 PUSH1 70 PUSH1 6d PUSH1 75 PUSH1 6a PUSH1 20 PUSH1 3a PUSH1 72 PUSH1 6f PUSH1 72 PUSH1 72 PUSH1 45 DUP 0 JNZ 46 0 DROP JUMP 4a 0 OUTPUT JUMP 3d 0 HALT PUSH4 28 38 70 9 PUSH1 0 PUSH1 a PUSH1 21 PUSH1 64 PUSH1 6c PUSH1 72 PUSH1 6f PUSH1 77 PUSH1 20 PUSH1 6f PUSH1 6c PUSH1 6c PUSH1 65 PUSH1 48 DUP 0 JNZ 75 0 DROP JUMP 79 0 OUTPUT JUMP 6c 0 PUSH1 11 PUSH1 2a OUTPUT PUSH1 1 SUB DUP 0 JNZ 7b 0 DROP PUSH1 a OUTPUT CLOCK PUSH4 28 38 70 9 EQ JNZ ff 0 PUSH1 0 PUSH1 a PUSH1 21 PUSH1 79 PUSH1 6c PUSH1 72 PUSH1 65 PUSH1 70 PUSH1 6f PUSH1 72 PUSH1 70 PUSH1 20 PUSH1 67 PUSH1 6e PUSH1 69 PUSH1 6b PUSH1 72 PUSH1 6f PUSH1 77 PUSH1 20 PUSH1 74 PUSH1 6f PUSH1 6e PUSH1 20 PUSH1 73 PUSH1 6e PUSH1 6f PUSH1 69 PUSH1 74 PUSH1 61 PUSH1 72 PUSH1 65 PUSH1 70 PUSH1 6f PUSH1 20 PUSH1 6b PUSH1 63 PUSH1 61 PUSH1 74 PUSH1 73 PUSH1 20 PUSH1 3a PUSH1 72 PUSH1 6f PUSH1 72 PUSH1 72 PUSH1 45 DUP 0 JNZ fb 0 DROP JUMP ff 0 OUTPUT JUMP f2 0 HALT PUSH1 0 PUSH1 a PUSH1 21 PUSH1 67 PUSH1 6e PUSH1 69 PUSH1 6b PUSH1 72 PUSH1 6f PUSH1 77 PUSH1 20 PUSH1 74 PUSH1 6f PUSH1 6e PUSH1 20 PUSH1 73 PUSH1 69 PUSH1 20 PUSH1 74 PUSH1 6c PUSH1 61 PUSH1 68 PUSH1 20 PUSH1 3a PUSH1 72 PUSH1 6f PUSH1 72 PUSH1 72 PUSH1 45 DUP 0 JNZ 14 3 DROP JUMP 14 7 OUTPUT JUMP 13 a HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT HALT
stouset/8-bit-cpu
1,893
assembler/examples/primes.s
.equ prime_count, 0 .equ primes, 1 .org 0 ; ; void main(): halt ; main: data sp, #0 sto [#prime_count], sp ; prime_count=0 data ra, #2 data rc, #find_primes call rc hlt .org 32 ; ; void find_primes() ; ; clobbers: ra, rb, rc, rd ; find_primes: data rd, #3 ; rd = candidate = 3; tst rd _4: jc #_ret push rd ; stack = [..,candidate] data rc, #is_prime call rc tst rd jz #_5 lod ra, [sp] ; stack = [..,candidate].ra= candidate data rd, #primes lod rb, [#prime_count] add rd, rb sto [rd], ra ; primes[prime_count] = candidate inc rb sto [#prime_count], rb ; prime_count++ _5: pop rd data rb, #2 add rd, rb ; candidate +=2; jmp #_4 _ret: ret .org 64 ; ; bool is_prime(unsigned int candidate) ; ; expects: rd = candidate ; returns: rd = return value. ; clobbers: rb, rc ; is_prime: data rb, #0 ; unsigned int prime_index=0; _2: lod rc, [#prime_count] ; rc = prime_count; cmp rb,rc jc #_return_true ; if (prime_index >= prime_count) push rd ; stack = [..,candidate] data rd, #primes add rd, rb lod rc, [rd] ; rc =primes[prime_index] pop rd ; stack = [..]. rd = candidate push rb ; stack = [..,prime_index] data rb, #15 cmp rb, rc jc #_3 pop rb jmp #_return_true _3: mov rb, rc push rd ; stack = [..,prime_index,candidate] data rc, #calc_remaind call rc tst rd jz #_return_false pop rd ; stack =[..,prime_index].rd=candidate pop rb ; stack = [..]. rb = prime_index inc rb ; prime_index++ jmp #_2 _return_false: pop rd ; stack = [..,prime_index] pop rb ; stack = [..] data rd,#0 ret _return_true: data rd,#1 ret .org 128 ; ; unsigned int calc_remaind(unsigned int dividend, unsigned int divisor) ; ; expects: rd = dividend. rb = divisor ; returns: rd = return value. ; calc_remaind: cmp rd, rb jc #_1 ret _1: sub rd, rb jmp #calc_remaind
stsp/libi86
3,225
tests/capture-ack.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Capture the contents of the current screen page. This is a tiny memory model program. */ .sect .text .sect .rom .sect .data .sect .bss .sect .text xor ax, ax /* get number of rows on screen */ mov ds, ax movb al, (0x484) push ss pop ds testb al, al /* if maximum row number is 0, */ jnz .rows /* assume 25 rows */ movb al, 24 .rows: inc ax movb (rows), al movb ah, 0x0f /* get number of columns on screen, */ int 0x10 /* and active display page */ movb (page), bh movb (cols), ah mov di, buf xor dx, dx .loop: /* now loop through the whole screen */ movb ah, 0x02 movb bh, (page) push dx push di int 0x10 movb ah, 0x08 movb bh, (page) int 0x10 pop di pop dx cld cmpb al, ' ' /* escape special characters */ jb .special cmpb al, '~' jae .special .special_ok: stosb incb dl cmpb dl, (cols) jnz .loop movb al, '\n' /* add a '\n' after each row */ stosb xorb dl, dl incb dh cmpb dh, (rows) jnz .loop movb ah, 0x40 /* we are done; write the captured */ mov bx, 1 /* screen contents to stdout */ mov dx, buf mov cx, di sub cx, dx int 0x21 jc .error cmp ax, cx jnz .error mov ax, 0x4c00 int 0x21 .error: mov ax, 0x4c01 int 0x21 .special: /* encode special characters as `~' */ xchg bx, ax /* followed by an octal char. code */ movb al, '~' stosb movb bh, bl rolb bl, 1 rolb bl, 1 movb al, bl andb al, 0x03 orb al, '0' stosb rolb bl, 1 rolb bl, 1 rolb bl, 1 movb al, bl andb al, 0x07 orb al, '0' stosb movb al, bh andb al, 0x07 orb al, '0' jmp .special_ok .sect .bss .comm page, 1 .comm cols, 1 .comm rows, 1 .comm curs_pos, 2 .comm buf, 0xc000
stsp/libi86
3,289
tests/capture-gcc.S
/* * Copyright (c) 2018--2020 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Capture the contents of the current screen page. This is a tiny memory model program. */ .arch i8086, jumps .code16 .att_syntax prefix .text .global _start _start: xorw %ax, %ax /* get number of rows on screen */ movw %ax, %ds movb 0x484, %al pushw %ss popw %ds testb %al, %al /* if maximum row number is 0, */ jnz .rows /* assume 25 rows */ movb $24, %al .rows: incw %ax movb %al, rows movb $0x0f, %ah /* get number of columns on screen, */ int $0x10 /* and active display page */ movb %bh, page movb %ah, cols movw $buf, %di xorw %dx, %dx .loop: /* now loop through the whole screen */ movb $0x02, %ah movb page, %bh pushw %dx pushw %di int $0x10 movb $0x08, %ah movb page, %bh int $0x10 popw %di popw %dx cld cmpb $' ', %al /* escape special characters */ jb .special cmpb $'~', %al jae .special .special_ok: stosb incb %dl cmpb cols, %dl jnz .loop movb $'\n', %al /* add a '\n' after each row */ stosb xorb %dl, %dl incb %dh cmpb rows, %dh jnz .loop movb $0x40, %ah /* we are done; write the captured */ movw $1, %bx /* screen contents to stdout */ movw $buf, %dx movw %di, %cx subw %dx, %cx int $0x21 jc .error cmpw %cx, %ax jnz .error movw $0x4c00, %ax int $0x21 .error: movw $0x4c01, %ax int $0x21 .special: /* encode special characters as `~' */ xchgw %ax, %bx /* followed by an octal char. code */ movb $'~', %al stosb movb %bl, %bh rolb %bl rolb %bl movb %bl, %al andb $0x03, %al orb $'0', %al stosb rolb %bl rolb %bl rolb %bl movb %bl, %al andb $0x07, %al orb $'0', %al stosb movb %bh, %al andb $0x07, %al orb $'0', %al jmp .special_ok .lcomm page, 1 .lcomm cols, 1 .lcomm rows, 1 .lcomm buf, 0xc000
stsp/libi86
1,882
host-ack/stdlib/libi86-get-psp.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_get_psp ___libi86_get_psp: mov ax, (.cached_psp) test ax, ax jz .init ret .init: movb ah, 0x51 int 0x21 xchg bx, ax mov (.cached_psp), ax ret .sect .bss /* workaround: prevent ACK as from using wrong section */ .comm .cached_psp, 2 #endif
stsp/libi86
1,899
host-ack/stdlib/libi86-get-osmajor-osminor.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_get_osmajor_osminor ___libi86_get_osmajor_osminor: mov ax, (.cached_osver) test ax, ax jz .init ret .init: movb ah, 0x30 int 0x21 mov (.cached_osver), ax ret .sect .bss /* workaround: prevent ACK as from using wrong section */ .comm .cached_osver, 2 #endif
stsp/libi86
1,903
host-ack/stdlib/libi86-ultoa-uldiv.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_ultoa_uldiv ___libi86_ultoa_uldiv: mov bx, sp mov cx, 6(bx) /* divisor */ mov ax, 4(bx) /* dividend high part */ xor dx, dx test ax, ax jz .hiz div cx .hiz: push ax mov ax, 2(bx) /* dividend low part */ div cx mov bx, 8(bx) /* remainder address */ mov (bx), dx pop dx ret
stsp/libi86
1,341
host-ack/process/spawnlx.s
# /* Copyright (c) 2022 TK Chia * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "libi86/internal/sect.h" #if defined L_spawnl .define __spawnl __spawnl: #elif defined L_spawnle .define __spawnle __spawnle: #elif defined L_spawnlp .define __spawnlp __spawnlp: #elif defined L_spawnlpe .define __spawnlpe __spawnlpe: #else # error "which function are we assembling?" #endif sub sp, 8 push es push si push di push ds pop es mov di, sp add di, 6 lea si, 8+2(di) movsw movsw mov ax, si stosw #if defined L_spawnle || defined L_spawnlpe .find_envp: lodsw test ax, ax jnz .find_envp movsw #else xor ax, ax stosw #endif pop di pop si pop es #if defined L_spawnlp || defined L_spawnlpe call __spawnvpe #else call __spawnve #endif add sp, 8 ret
stsp/libi86
1,687
host-ack/i86/nosound.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define _nosound _nosound: pushf cli inb 0x61 andb al, 0xfc outb 0x61 popf ret
stsp/libi86
2,600
host-ack/i86/libi86-intr-dispatch.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_intr_dispatch ___libi86_intr_dispatch: mov bx, sp movb al, 2(bx) xorb ah, ah mov bx, ax shl bx, 1 add ax, bx add ax, .dispatch ret #define INTS4(i) \ int [i]; \ ret; \ int [i] + 1; \ ret; \ int [i] + 2; \ ret; \ int [i] + 3; \ ret #define INTS8(i) \ INTS4 (i); \ INTS4 ([i] + 4) #define INTS16(i) \ INTS8 (i); \ INTS8 ([i] + 8) .dispatch: int 0x00 ret int 0x01 ret int 0x02 ret int 0x03 /* `int 3' is a 1-byte instruction; */ ret /* hence the `nop' */ nop INTS4 (0x04) INTS8 (0x08) INTS16 (0x10) INTS4 (0x20) #ifdef __MSDOS__ int 0x24 ret jmp .int25 jmp .int26 int 0x27 ret #else INTS4 (0x24) #endif INTS8 (0x28) INTS16 (0x30) INTS16 (0x40) INTS16 (0x50) INTS16 (0x60) INTS16 (0x70) INTS16 (0x80) INTS16 (0x90) INTS16 (0xa0) INTS16 (0xb0) INTS16 (0xc0) INTS16 (0xd0) INTS16 (0xe0) INTS16 (0xf0) #ifdef __MSDOS__ .int25: int 0x25 jc .cy .nc: popf clc ret .int26: int 0x26 jnc .nc .cy: popf stc ret #endif
stsp/libi86
1,725
host-ack/i86/libi86-CV-FP.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_CV_FP ___libi86_CV_FP: mov bx, sp mov ax, 4(bx) mov bx, 2(bx) mov (bx), ax mov 2(bx), ds xchg bx, ax ret
stsp/libi86
1,720
host-ack/i86/segread.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define _segread _segread: mov bx, sp mov bx, 2(bx) mov (bx), es mov 2(bx), cs mov 4(bx), ss mov 6(bx), ds ret
stsp/libi86
2,288
host-ack/i86/libi86-int86-do.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Internal implementation routine used by int86 (...) and _int86f (...). */ #include "libi86/internal/sect.h" #include "libi86/internal/struc.h" #ifndef _BORLANDC_SOURCE .define ___libi86_int86_do ___libi86_int86_do: #else .define ___libi86_bc_int86_do ___libi86_bc_int86_do: #endif mov bx, sp push bp push si push di push es mov si, ds /* good idea to set es = ds here */ mov es, si push 6(bx) /* out_regs */ mov si, .done push si push 2(bx) /* intr_call */ mov bx, 4(bx) /* in_regs */ LOAD_UNION_REGS_BX_ ret .done: push bx mov bx, ss /* restore ds */ mov ds, bx mov bx, sp mov bx, 2(bx) /* out_regs */ STORE_UNION_REGS_BX_POP_CLOBBER_ pop cx cld pop es pop di pop si pop bp ret
stsp/libi86
2,477
host-ack/i86/libi86-int86x-do.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Internal implementation routine used by int86 (...) and _int86f (...). */ #include "libi86/internal/sect.h" #include "libi86/internal/struc.h" #ifndef _BORLANDC_SOURCE .define ___libi86_int86x_do ___libi86_int86x_do: #else .define ___libi86_bc_int86x_do ___libi86_bc_int86x_do: #endif mov bx, sp push bp push si push di push es mov si, 8(bx) /* seg_regs */ push si mov es, (si) push 6(bx) /* out_regs */ mov di, .done push di push 2(bx) /* intr_call */ push 6(si) mov bx, 4(bx) /* in_regs */ LOAD_UNION_REGS_BX_ pop ds ret .done: push bx mov bx, sp sseg mov bx, 4(bx) /* seg_regs */ sseg mov 6(bx), ds /* store ds from interrupt call */ push ss /* restore ds */ pop ds mov (bx), es /* store es, cs, ss */ mov 2(bx), cs mov 4(bx), ss mov bx, sp mov bx, 2(bx) /* out_regs */ STORE_UNION_REGS_BX_POP_CLOBBER_ pop cx pop cx cld pop es pop di pop si pop bp ret
stsp/libi86
1,632
host-ack/i86/enable.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __enable __enable: sti ret
stsp/libi86
1,979
host-ack/i86/sound.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define _sound _sound: mov bx, sp mov cx, 2(bx) mov ax, 0x34dd /* 1193181 == 0x1234dd */ cwd cmp cx, 19 jb .play /* dx == 0 */ mov bx, cx shr bx, 1 add ax, bx adc dx, 0x12 div cx /* this will never overflow */ xchg dx, ax .play: pushf cli inb 0x61 orb al, 0x03 outb 0x61 movb al, 0xb6 outb 0x43 xchg dx, ax outb 0x42 movb al, ah outb 0x42 popf ret
stsp/libi86
1,655
host-ack/i86/libi86-get-cs.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_get_cs ___libi86_get_cs: mov ax, cs ret
stsp/libi86
1,664
host-ack/i86/libi86-get-flags.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_get_flags ___libi86_get_flags: pushf pop ax ret
stsp/libi86
1,634
host-ack/i86/disable.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __disable __disable: cli ret
stsp/libi86
1,655
host-ack/i86/libi86-get-ss.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_get_ss ___libi86_get_ss: mov ax, ss ret
stsp/libi86
2,119
host-ack/i86/libi86-intrf-do.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Internal implementation routine used by intr (...) and _intrf (...). */ #include "libi86/internal/sect.h" #include "libi86/internal/struc.h" .define ___libi86_intrf_do ___libi86_intrf_do: mov bx, sp push bp push si push di push es mov di, 4(bx) /* regs */ push di mov si, .done push si push 2(bx) /* intr_call */ movb ah, 6(bx) /* flags */ sahf LOAD_UNION_REGPACK_DI_ ret .done: push bp mov bp, sp mov bp, 2(bp) /* regs */ STORE_UNION_REGPACK_BP_POP_ pop ax cld mov ax, ss mov ds, ax pop es pop di pop si pop bp ret
stsp/libi86
1,717
host-ack/conio/outp.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_outp .define __outpw ___libi86_outp: __outp: pop bx pop dx pop ax outb dx sub sp, 4 jmp bx
stsp/libi86
1,925
host-ack/conio/kbhit.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __kbhit __kbhit: xor ax,ax cmp (___libi86_ungetch_buf), ax jnz .ungetch #ifdef __MSDOS__ mov bx, (___libi86_con_in_fd) cmp bx, ax jnz .fdnot0 movb ah, 0x0b int 0x21 cbw ret .fdnot0: mov ax, 0x4406 int 0x21 cbw ret #else movb ah, 1 int 0x16 mov ax, 0 jz .nokey #endif .ungetch: dec ax .nokey: ret
stsp/libi86
1,760
host-ack/conio/inpw.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_inpw .define ___libi86_inpw_signed .define __inpw ___libi86_inpw: ___libi86_inpw_signed: __inpw: pop bx pop dx in dx sub sp, 2 jmp bx
stsp/libi86
1,775
host-ack/conio/outpw.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_outpw .define ___libi86_outpw_signed .define __outpw ___libi86_outpw: ___libi86_outpw_signed: __outpw: pop bx pop dx pop ax out dx sub sp, 4 jmp bx
stsp/libi86
2,486
host-ack/conio/libi86-con-out-fd.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* * This module initializes the <conio.h> subsystem to make sure that there * is an output file descriptor which is open to the console device `CON'. */ .define ___libi86_con_out_fd_init ___libi86_con_out_fd_init: push (_errno) mov bx, 1 ! check if fd 1 is console output push bx mov ax, 0x4400 int 0x21 jc .opencon notb dl testb dl, 0x82 jnz .opencon .done: pop bx pop (_errno) ! if so, we are done; patch ! ourselves with a `ret' instruction cseg movb (___libi86_con_out_fd_init), 0xc3 ret .opencon: ! otherwise, open an output fd on `CON' mov ax, ___libi86_con_name ! fd no. 1 above doubles as O_WRONLY (: push ax call _open pop bx cmp ax, -1 ! if this fails, just use fd 1 :-\ jz .done ! otherwise record the new fd to use mov (___libi86_con_out_fd), ax jmp .done .sect .data .define ___libi86_con_out_fd ___libi86_con_out_fd: .data2 1
stsp/libi86
1,854
host-ack/conio/ungetch.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __ungetch __ungetch: mov bx, sp movb al, 2(bx) mov bx, ___libi86_ungetch_buf cmp (bx), 0 jnz .error lahf ! put something non-zero into ah; ! we know ZF is set at this point mov (bx), ax movb ah, 0 ret 2 .error: mov ax, -1 ret
stsp/libi86
1,715
host-ack/conio/inp.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_inp .define __inp ___libi86_inp: __inp: pop bx pop dx inb dx movb ah, 0 sub sp, 2 jmp bx
stsp/libi86
3,561
host-ack/conio/libi86-con-in-fd.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* * This module initializes the <conio.h> subsystem to make sure that there * is an input file descriptor which is open to the console device `CON'. * * This is (in a way) an improvement over the classical Turbo C and Open * Watcom C/C++'s <conio.h> code: they implement kbhit (), getch (), etc., * using int $0x21 calls in a way that assume that standard input (fd 0) * points to `CON', whether or not it does. * * (Watcom in addition assumes that standard output, fd 1, points to `CON'. * libi86 initializes the fd for console output in libi86-con-out-fd.c .) */ .define ___libi86_con_in_fd_init ___libi86_con_in_fd_init: push (_errno) xor bx, bx ! check if fd 0 is console input push bx mov ax, 0x4400 int 0x21 jc .opencon notb dl testb dl, 0x81 jnz .opencon .done: pop bx pop (_errno) ! if so, we are done; patch ! ourselves with a `ret' instruction cseg movb (___libi86_con_in_fd_init), 0xc3 ret .opencon: ! otherwise, open an output fd on `CON' mov ax, ___libi86_con_name ! fd no. 0 above doubles as O_RDONLY (: push ax call _open pop bx cmp ax, -1 ! if this fails, just use fd 0 :-\ jz .done ! otherwise record the new fd to use mov (___libi86_con_in_fd), ax xchg bx, ax push bx mov ax, 0x4400 ! store original device information int 0x21 ! word so that we can restore the fd pop bx ! to cooked mode xorb dh, dh mov (___libi86_con_in_info_word), dx testb dl, 0x80 ! if device, set to use raw binary jz .done ! mode testb dl, 0x20 jnz .done orb dl, 0x20 mov ax, 0x4401 int 0x21 ! register a function to be called ! at exit which will restore cooked ! mode mov ax, ___libi86_con_in_fd_fini push ax call _atexit pop ax jmp .done ___libi86_con_in_fd_fini: mov ax, 0x4401 mov bx, (___libi86_con_in_fd) mov dx, (___libi86_con_in_info_word) int 0x21 ret .sect .bss .define ___libi86_con_in_fd .comm ___libi86_con_in_fd, 2 .comm ___libi86_con_in_info_word, 2
stsp/libi86
1,949
host-ack/string/fmempcpy.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fmempcpy __fmempcpy: mov bx, sp push es push si push di push ds mov cx, 12(bx) /* N */ les di, 4(bx) /* DEST */ mov ax, 2(bx) /* return value */ lds si, 8(bx) /* SRC */ shr cx, 1 rep movsw adc cx, cx rep movsb pop ds mov si, ax /* return value := DEST + N */ mov (si), di mov 2(si), es pop di pop si pop es ret
stsp/libi86
1,896
host-ack/string/fmemset.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fmemset __fmemset: push di mov di, sp push es movb al, 10(di) /* C */ mov cx, 12(di) /* N */ mov bx, 4(di) /* return value := DEST */ les di, 6(di) /* DEST */ mov (bx), di mov 2(bx), es movb ah, al shr cx, 1 rep stosw adc cx, cx rep stosb xchg bx, ax pop es pop di ret
stsp/libi86
1,773
host-ack/string/fstrlen.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fstrlen __fstrlen: mov bx, sp push di push es les di, 2(bx) xor ax, ax mov cx, -1 repne scasb jnz .0 dec ax .0: dec ax sub ax, cx pop es pop di ret
stsp/libi86
2,227
host-ack/string/fmemcmp.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fmemcmp __fmemcmp: mov bx, sp push ds push es push si push di mov cx, 10(bx) /* N */ les di, 6(bx) /* S2 */ lds si, 2(bx) /* S1 */ shr cx, 1 sbb ax, ax jcxz .done_words repz cmpsw jnz .unequal_word .done_words: xchg cx, ax jcxz .munge_flags .final_byte: cmpsb .munge_flags: lahf /* SZ-A-P-C */ rorb ah, 1 and ax, 0b1010000000000000 /* CF set => ret. < 0 */ /* CSZ-A-P- */ /* CF clear, ZF set => ret. == 0 */ xor ax, 0b0010000000000000 /* CF, ZF clear => ret > 0 */ pop di pop si pop es pop ds ret .unequal_word: dec si dec si dec di dec di cmpsb jnz .munge_flags jmp .final_byte
stsp/libi86
1,905
host-ack/string/fstrcpy.s
# /* * Copyright (c) 2018--2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fstrcpy __fstrcpy: mov bx, sp push ds push es push si push di les di, 4(bx) /* DEST */ mov si, 2(bx) /* return value := DEST */ mov (si), di mov 2(si), es mov cx, si lds si, 8(bx) /* SRC */ .0: lodsb stosb testb al, al jnz .0 xchg cx, ax pop di pop si pop es pop ds ret
stsp/libi86
1,910
host-ack/string/fstpcpy.s
# /* * Copyright (c) 2018--2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fstpcpy __fstpcpy: mov bx, sp push ds push es push si push di les di, 4(bx) /* DEST */ lds si, 8(bx) /* SRC */ .0: lodsb stosb testb al, al jnz .0 dec di mov bx, 2(bx) /* return value := DEST + length */ mov (bx), di mov 2(bx), es xchg bx, ax pop di pop si pop es pop ds ret
stsp/libi86
1,916
host-ack/string/fmemchr.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fmemchr __fmemchr: push di mov di, sp push es movb al, 10(di) /* C */ mov cx, 12(di) /* N */ mov bx, 4(di) /* return value */ les di, 6(di) /* DEST */ repnz scasb jnz .1 dec di mov (bx), di mov 2(bx), es .0: xchg bx, ax pop es pop di ret .1: xor ax, ax mov (bx), ax mov 2(bx), ax jmp .0
stsp/libi86
1,987
host-ack/string/fmemcpy.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define __fmemcpy .define ___libi86_fmemmove_forward __fmemcpy: ___libi86_fmemmove_forward: mov bx, sp push ds push es push si push di mov cx, 12(bx) /* N */ les di, 4(bx) /* DEST */ mov si, 2(bx) /* return value := DEST */ mov (si), di mov 2(si), es xchg si, ax lds si, 8(bx) /* SRC */ shr cx, 1 rep movsw adc cx, cx rep movsb pop di pop si pop es pop ds ret
stsp/libi86
2,041
host-ack/string/libi86-fmemmove-backward.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" .define ___libi86_fmemmove_backward ___libi86_fmemmove_backward: mov bx, sp push ds push es push si push di mov cx, 12(bx) /* N */ les di, 4(bx) /* DEST */ mov si, 2(bx) /* return value := DEST */ mov (si), di mov 2(si), es xchg si, ax lds si, 8(bx) /* SRC */ add si, cx add di, cx dec si dec si dec di dec di std shr cx, 1 rep movsw adc cx, cx inc si inc di rep movsb cld pop di pop si pop es pop ds ret
stsp/libi86
1,875
host-ack/graph/libi86-vid-int-0x10.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* * Call int 0x10 with the given values of ax, bx, cx, & dx. Return the * resulting value of bx:ax. */ .define ___libi86_vid_int_0x10 ___libi86_vid_int_0x10: mov bx, sp mov ax, 2(bx) mov cx, 6(bx) mov dx, 8(bx) mov bx, 4(bx) push bp int 0x10 pop bp mov dx, bx ret
stsp/libi86
1,907
host-ack/graph/libi86-vid-set-vga-dac-reg.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #define __ASSEMBLER__ #include "graph.h" /* Get the value of an individual VGA or MCGA palette register. */ .define ___libi86_vid_set_vga_dac_reg ___libi86_vid_set_vga_dac_reg: mov bx, sp mov cx, 4(bx) movb dh, cl movb cl, 6(bx) movb bl, 2(bx) and cx, 0x3f3f andb dh, 0x3f mov ax, 0x1010 int 0x10 ret
stsp/libi86
1,902
host-ack/graph/libi86-vid-get-ega-info.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* * Get the current EGA information, &/or try to detect an EGA-compatible video * card. Return the value of bx:cx as returned by int 0x10, ah = 0x12, bl * = 0x10. */ .define ___libi86_vid_get_ega_info ___libi86_vid_get_ega_info: movb ah, 0x12 mov bx, 0xff10 int 0x10 xchg cx, ax mov dx, bx ret
stsp/libi86
1,896
host-ack/graph/libi86-vid-get-ega-pal-reg.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* * Get the value of an individual EGA palette register. If the BIOS does * not allow this, return a given default value. */ .define ___libi86_vid_get_ega_pal_reg ___libi86_vid_get_ega_pal_reg: mov bx, sp movb al, 2(bx) movb ah, 4(bx) xchg bx, ax mov ax, 0x1007 int 0x10 movb al, bh ret
stsp/libi86
1,799
host-ack/graph/libi86-vid-set-ega-pal-reg.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* Set an individual EGA palette register. */ .define ___libi86_vid_set_ega_pal_reg ___libi86_vid_set_ega_pal_reg: mov bx, sp movb al, 2(bx) movb ah, 4(bx) xchg bx, ax mov ax, 0x1000 int 0x10 ret
stsp/libi86
1,880
host-ack/graph/libi86-vid-get-vga-dac-reg.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* Get the value of an individual VGA or MCGA palette register. */ #define _BLACK 0x800000 .define ___libi86_vid_get_vga_dac_reg ___libi86_vid_get_vga_dac_reg: mov bx, sp movb bl, 2(bx) mov ax, 0x1015 int 0x10 movb al, dh movb ah, ch cwd movb dl, cl orb dl, _BLACK>>16 ret
stsp/libi86
1,777
host-ack/graph/libi86-vid-get-curs-shape.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" /* Get the current cursor shape (& size) via int 0x10. */ .define ___libi86_vid_get_curs_shape ___libi86_vid_get_curs_shape: movb ah, 0x03 xorb bh, bh int 0x10 xchg cx, ax ret
stsp/libi86
1,754
host-ack/dos/dos-freemem.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_freemem __dos_freemem: mov bx, sp push es mov es, 2(bx) movb ah, 0x49 int 0x21 pop es jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,775
host-ack/dos/dos-commit.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_commit __dos_commit: mov bx, sp mov bx, 2(bx) movb ah, 0x68 clc /* (?) per Open Watcom */ int 0x21 jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,764
host-ack/dos/dos-getdate.s
# /* * Copyright (c) 2019--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_getdate __dos_getdate: mov bx, sp mov bx, 2(bx) movb ah, 0x2a int 0x21 mov (bx), dx mov 2(bx), cx movb 4(bx), al ret #endif
stsp/libi86
1,863
host-ack/dos/dos-getvect.s
# /* * Copyright (c) 2021--2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_getvect .define ___libi86_bc_getvect __dos_getvect: ___libi86_bc_getvect: push si mov si, sp push es movb ah, 0x35 movb al, 6(si) int 0x21 mov si, 4(si) mov (si), bx mov 2(si), es xchg si, ax pop es pop si ret #endif
stsp/libi86
2,317
host-ack/dos/intdosx.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #include "libi86/internal/struc.h" #ifndef _BORLANDC_SOURCE .define _intdosx _intdosx: #else .define ___libi86_bc_intdosx ___libi86_bc_intdosx: #endif mov bx, sp push bp push si push di push es mov si, 6(bx) /* seg_regs */ push si mov es, (si) push 4(bx) /* out_regs */ push 6(si) mov bx, 2(bx) /* in_regs */ LOAD_UNION_REGS_BX_ pop ds int 0x21 push bx mov bx, sp sseg mov bx, 4(bx) /* seg_regs */ sseg mov 6(bx), ds /* store ds from interrupt call */ push ss /* restore ds */ pop ds mov (bx), es /* store es, cs, ss */ mov 2(bx), cs mov 4(bx), ss mov bx, sp mov bx, 2(bx) /* out_regs */ STORE_UNION_REGS_BX_POP_CLOBBER_ pop cx pop cx cld pop es pop di pop si pop bp ret
stsp/libi86
1,942
host-ack/dos/dos-setdrive.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_setdrive __dos_setdrive: mov bx, sp mov dx, 2(bx) mov bx, 4(bx) dec dx testb dh, dh /* if drive number > 0x100, then */ jz .0 /* map it to something bogus; but */ movb dl, 0xff /* we still need to return the */ .0: /* drive count... */ movb ah, 0x0e int 0x21 xorb ah, ah mov (bx), ax ret #endif
stsp/libi86
1,838
host-ack/dos/parsfnm.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __parsfnm __parsfnm: mov bx, sp push es push si push di mov si, 2(bx) mov di, 4(bx) movb al, 6(bx) movb ah, 0x29 int 0x21 cmpb al, 1 xchg si, ax jna .ok xor ax, ax .ok: pop di pop si pop es ret #endif
stsp/libi86
1,739
host-ack/dos/dos-close.s
# /* * Copyright (c) 2019--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_close __dos_close: mov bx, sp mov bx, 2(bx) movb ah, 0x3e int 0x21 jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,820
host-ack/dos/dos-creatnew.s
# /* * Copyright (c) 2019--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_creatnew __dos_creatnew: mov bx, sp mov dx, 2(bx) mov cx, 4(bx) movb ah, 0x5b int 0x21 jc .error mov bx, sp mov bx, 6(bx) mov (bx), ax .error: jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,765
host-ack/dos/peek.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_peek ___libi86_peek: mov bx, sp mov cx, es mov es, 2(bx) mov bx, 4(bx) eseg mov ax, (bx) mov es, cx ret #endif /* __MSDOS__ */
stsp/libi86
1,833
host-ack/dos/libi86-msdos-do-open.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_msdos_do_open ___libi86_msdos_do_open: mov bx, sp movb ah, 0x3d movb al, 4(bx) mov dx, 2(bx) int 0x21 jc .error mov bx, sp mov bx, 6(bx) mov (bx), ax .error: jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,921
host-ack/dos/dos-getdiskfree.s
# /* * Copyright (c) 2019--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_getdiskfree __dos_getdiskfree: push di mov di, sp movb dl, 4(di) mov di, 6(di) movb ah, 0x36 int 0x21 inc ax jz .error dec ax xchg dx, ax stosw xchg bx, ax stosw xchg dx, ax stosw xchg cx, ax stosw pop di xor ax, ax ret .error: pop di jmp ___libi86_ret_einval #endif
stsp/libi86
1,780
host-ack/dos/poke.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_poke ___libi86_poke: mov bx, sp mov cx, es mov ax, 6(bx) mov es, 2(bx) mov bx, 4(bx) eseg mov (bx), ax mov es, cx ret #endif /* __MSDOS__ */
stsp/libi86
2,128
host-ack/dos/intdos.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #include "libi86/internal/struc.h" #ifndef _BORLANDC_SOURCE .define _intdos _intdos: #else .define ___libi86_bc_intdos ___libi86_bc_intdos: #endif mov bx, sp push bp push si push di push es mov si, ds /* good idea to set es = ds here */ mov es, si push 4(bx) /* out_regs */ mov bx, 2(bx) /* in_regs */ LOAD_UNION_REGS_BX_ int 0x21 push bx mov bx, ss /* restore ds */ mov ds, bx mov bx, sp mov bx, 2(bx) /* out_regs */ STORE_UNION_REGS_BX_POP_CLOBBER_ pop cx cld pop es pop di pop si pop bp ret
stsp/libi86
1,783
host-ack/dos/libi86-msdos-do-findfirst.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_msdos_do_findfirst ___libi86_msdos_do_findfirst: mov bx, sp mov ax, 0x4e01 mov cx, 4(bx) mov dx, 2(bx) int 0x21 jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,814
host-ack/dos/libi86-msdos-do-truename.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_msdos_do_truename ___libi86_msdos_do_truename: mov bx, sp push si push di mov si, 2(bx) mov di, 4(bx) movb ah, 0x60 int 0x21 pop di pop si jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,829
host-ack/dos/dos-setblock.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_setblock __dos_setblock: mov bx, sp push es push si mov si, 6(bx) movb ah, 0x4a mov es, 4(bx) mov bx, 2(bx) int 0x21 jnc .0 mov (si), bx .0: pop si pop es jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,807
host-ack/dos/dos-setdate.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_setdate __dos_setdate: mov bx, sp mov bx, 2(bx) movb ah, 0x2b mov dx, (bx) mov cx, 2(bx) int 0x21 testb al, al jnz .error cbw ret .error: jmp ___libi86_ret_einval #endif
stsp/libi86
1,770
host-ack/dos/dos-gettime.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_gettime __dos_gettime: mov bx, sp mov bx, 2(bx) movb ah, 0x2c int 0x21 xchgb ch, cl mov (bx), cx xchgb dh, dl mov 2(bx), dx ret #endif
stsp/libi86
1,867
host-ack/dos/makefcb.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __makefcb __makefcb: push bp mov bp, sp push es push si push di mov si, 6(bp) mov di, 8(bp) movb al, 10(bp) movb ah, 0x29 int 0x21 mov di, 4(bp) cbw mov (di), ax mov 2(di), si xchg di, ax pop di pop si pop es pop bp ret #endif
stsp/libi86
2,104
host-ack/dos/dos-spawn.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_spawn __dos_spawn: mov bx, sp push ds push es push si push di push bp push ds pop es movb al, 2(bx) mov dx, 4(bx) mov bx, 6(bx) xor cx, cx movb ah, 0x4b cmpb al, 4 jnz .not_aexec movb ah, 0x80 .not_aexec: push cs mov si, .cont push si mov si, 0x9a90 push si mov si, 0x21cd push si mov si, sp push ss push si retf .cont: pop si cli pop ss mov sp, si sti pop bp pop di pop si pop es pop ds jmp .__libi86_ret_set_errno #endif /* __MSDOS__ */
stsp/libi86
1,868
host-ack/dos/bdos.s
# /* * Copyright (c) 2018--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define _bdos .define ___libi86_bdosptr _bdos: ___libi86_bdosptr: mov bx, sp push si push di push es push bp movb ah, 2(bx) mov dx, 4(bx) movb al, 6(bx) int 0x21 pop bp pop es pop di pop si push ss pop ds ret #endif /* __MSDOS__ */
stsp/libi86
1,863
host-ack/dos/dosexterr.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define _dosexterr _dosexterr: push bp push si push di push ds push es movb ah, 0x59 xor bx, bx int 0x21 pop es pop ds pop di pop si mov bp, sp mov bp, 4(bp) mov (bp), ax xchgb bh, bl mov 2(bp), bx movb 4(bp), ch pop bp ret #endif
stsp/libi86
1,835
host-ack/dos/dos-settime.s
# /* * Copyright (c) 2022 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_settime __dos_settime: mov bx, sp mov bx, 2(bx) movb ah, 0x2d mov cx, (bx) xchgb ch, cl mov dx, 2(bx) xchgb dh, dl int 0x21 testb al, al jnz .error cbw ret .error: jmp ___libi86_ret_einval #endif
stsp/libi86
1,738
host-ack/dos/libi86-msdos-do-findnext.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define ___libi86_msdos_do_findnext ___libi86_msdos_do_findnext: movb ah, 0x4f int 0x21 jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,770
host-ack/dos/dos-setftime.s
# /* * Copyright (c) 2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_setftime __dos_setftime: mov bx, sp mov dx, 4(bx) mov cx, 6(bx) mov bx, 2(bx) mov ax, 0x5701 int 0x21 jmp .__libi86_ret_set_errno #endif
stsp/libi86
1,683
host-ack/dos/dos-findclose.s
# /* * Copyright (c) 2019--2021 TK Chia * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the developer(s) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libi86/internal/sect.h" #ifdef __MSDOS__ .define __dos_findclose __dos_findclose: xor ax, ax ret #endif