test-i386-code16.S (1319B)
1 .code16 2 .globl code16_start 3 .globl code16_end 4 5CS_SEG = 0xf 6 7code16_start: 8 9 .globl code16_func1 10 11 /* basic test */ 12code16_func1 = . - code16_start 13 mov $1, %eax 14 data32 lret 15 16/* test push/pop in 16 bit mode */ 17 .globl code16_func2 18code16_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 29code16_func3 = . - code16_start 30 jmp 1f 31 nop 321: 33 mov $4, %eax 34 mov $0x12345678, %ebx 35 xor %bx, %bx 36 jz 2f 37 add $2, %ax 382: 39 40 call myfunc 41 42 lcall $CS_SEG, $(myfunc2 - code16_start) 43 44 ljmp $CS_SEG, $(myjmp1 - code16_start) 45myjmp1_next: 46 47 cs lcall *myfunc2_addr - code16_start 48 49 cs ljmp *myjmp2_addr - code16_start 50myjmp2_next: 51 52 data32 lret 53 54myfunc2_addr: 55 .short myfunc2 - code16_start 56 .short CS_SEG 57 58myjmp2_addr: 59 .short myjmp2 - code16_start 60 .short CS_SEG 61 62myjmp1: 63 add $8, %ax 64 jmp myjmp1_next 65 66myjmp2: 67 add $16, %ax 68 jmp myjmp2_next 69 70myfunc: 71 add $1, %ax 72 ret 73 74myfunc2: 75 add $4, %ax 76 lret 77 78 79code16_end: