ss.S 695 B

1234567891011121314151617181920212223242526272829303132
  1. /* https://github.com/cirosantilli/x86-bare-metal-examples#ss */
  2. #include "common.h"
  3. BEGIN
  4. /* Save the good sp for later. */
  5. mov %sp, %bx
  6. /* Control group: ss == 0. */
  7. mov $stack, %sp
  8. pop %ax
  9. /* Restore the old stack so that it won't mess with our other functions. */
  10. mov %bx, %sp
  11. PRINT_HEX <%al>
  12. /* Now let's move ss and see if anything happens. */
  13. mov $1, %ax
  14. mov %ax, %ss
  15. mov $stack, %sp
  16. /* This pop should happen 16 bytes higher than the first one. */
  17. pop %ax
  18. mov %bx, %sp
  19. PRINT_HEX <%al>
  20. hlt
  21. stack:
  22. .word 1
  23. /* 2 bytes from the word above + 14 = 16 */
  24. .skip 14
  25. /* This is at stack0 + 16 */
  26. .word 2