Advertisement
MichaelPetch

TASM inline assembly / FAR pointer example

Dec 23rd, 2022 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void printString(char * str){
  5.  
  6. asm {
  7. mov ah, 0x0e
  8. mov bh, 0 // BH=Display number to write to.
  9. les si, str // Load ES with segment and SI with offset stored at 'str'
  10. }
  11. nextchar:
  12.  
  13. asm{
  14. mov al,[es:si] // Override the segment with ES to retrieve data from offset
  15. test al, al
  16. jz done
  17. int 0x10
  18. inc si
  19. jmp nextchar
  20. }
  21. done:
  22. }
  23.  
  24. int main(){
  25.  
  26. char* str = "hello world!";
  27.  
  28.  
  29. printString(str);
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement