1
0

test-i386-code16.S 1.3 KB

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