Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. __asm__(
  2. ".code16gcc;"
  3. "call dosmain;"
  4. "mov $0x4C, %AH;"
  5. "int $0x21;"
  6. );
  7.  
  8. void print(char *str)
  9. {
  10. __asm__(
  11. "mov $0x09, %%ah;"
  12. "int $0x21;"
  13. : // no output
  14. : "d"(str)
  15. : "ah"
  16. );
  17. }
  18.  
  19. void dosmain()
  20. {
  21. // DOS system call expects strings to be terminated by $.
  22. print("Hello world$");
  23. }
  24.  
  25. OUTPUT_FORMAT(binary)
  26. SECTIONS
  27. {
  28. . = 0x0100;
  29. .text :
  30. {
  31. *(.text);
  32. }
  33. .data :
  34. {
  35. *(.data);
  36. *(.bss);
  37. *(.rodata);
  38. }
  39. _heap = ALIGN(4);
  40. }
  41.  
  42. gcc -fno-pie -Os -nostdlib -ffreestanding -m16 -march=i386
  43. -Wl,--nmagic,--script=simple_dos.ld simple_dos.c -o simple_dos.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement