qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

test-i386-code16.S (1319B)


      1         .code16
      2         .globl code16_start
      3         .globl code16_end
      4 
      5 CS_SEG = 0xf
      6 
      7 code16_start:
      8 
      9         .globl code16_func1
     10 
     11         /* basic test */
     12 code16_func1 = . - code16_start
     13         mov $1, %eax
     14         data32 lret
     15 
     16 /* test push/pop in 16 bit mode */
     17         .globl code16_func2
     18 code16_func2 = . - code16_start
     19         xor %eax, %eax
     20         mov $0x12345678, %ebx
     21         movl %esp, %ecx
     22         push %bx
     23         subl %esp, %ecx
     24         pop %ax
     25         data32 lret
     26 
     27 /* test various jmp opcodes */
     28         .globl code16_func3
     29 code16_func3 = . - code16_start
     30         jmp 1f
     31         nop
     32 1:
     33         mov $4, %eax
     34         mov $0x12345678, %ebx
     35         xor %bx, %bx
     36         jz 2f
     37         add $2, %ax
     38 2:
     39 
     40         call myfunc
     41 
     42         lcall $CS_SEG, $(myfunc2 - code16_start)
     43 
     44         ljmp $CS_SEG, $(myjmp1 - code16_start)
     45 myjmp1_next:
     46 
     47         cs lcall *myfunc2_addr - code16_start
     48 
     49         cs ljmp *myjmp2_addr - code16_start
     50 myjmp2_next:
     51 
     52         data32 lret
     53 
     54 myfunc2_addr:
     55         .short myfunc2 - code16_start
     56         .short CS_SEG
     57 
     58 myjmp2_addr:
     59         .short myjmp2 - code16_start
     60         .short CS_SEG
     61 
     62 myjmp1:
     63         add $8, %ax
     64         jmp myjmp1_next
     65 
     66 myjmp2:
     67         add $16, %ax
     68         jmp myjmp2_next
     69 
     70 myfunc:
     71         add $1, %ax
     72         ret
     73 
     74 myfunc2:
     75         add $4, %ax
     76         lret
     77 
     78 
     79 code16_end: