ss.S 810 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. # SS segment register
  3. Expected output: "0102".
  4. I think the major effect of it is that anything that uses
  5. `SP` like `PUSH` and `POP`, will actually use 16 * SS + SP instead.
  6. */
  7. #include "common.h"
  8. BEGIN
  9. /* Save the good sp for later. */
  10. mov %sp, %bx
  11. /* Control group: ss == 0. */
  12. mov $stack, %sp
  13. pop %ax
  14. /* Restore the old stack so that it won't mess with our othe functions. */
  15. mov %bx, %sp
  16. PRINT_HEX <%al>
  17. /* Now let's move ss and see if anything happens. */
  18. mov $1, %ax
  19. mov %ax, %ss
  20. mov $stack, %sp
  21. /* This pop should happen 16 bytes higher than the first one. */
  22. pop %ax
  23. mov %bx, %sp
  24. PRINT_HEX <%al>
  25. hlt
  26. stack:
  27. .word 1
  28. /* 2 bytes from the word above + 14 = 16 */
  29. .skip 14
  30. /* This is at stack0 + 16 */
  31. .word 2