You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

5 years ago
  1. void strcpy (destination, destination_segment, source, source_segment );
  2. void strcpy (destination, destination_segment, source, source_segment )
  3. char *destination;
  4. int destination_segment;
  5. char *source;
  6. int source_segment;
  7. {
  8. #asm
  9. ; copy two strings
  10. ; IN si: the first (zero terminated) string
  11. ; IN di: the second (zero terminated) string
  12. ; OUT SF and ZF (same semantics as cmp)
  13. #define DESTINATION 4[bp];
  14. #define DESTINATION_SEGMENT 6[bp];
  15. #define SOURCE 8[bp];
  16. #define SOURCE_SEGMENT 10[bp];
  17. push bp
  18. mov bp,sp
  19. stringcompare:
  20. push ax
  21. push bx
  22. push di
  23. push es
  24. push si
  25. push ds
  26. mov ax, DESTINATION;
  27. mov di, ax
  28. mov ax, DESTINATION_SEGMENT;
  29. mov es, ax
  30. mov ax, SOURCE;
  31. mov si, ax
  32. mov ax, SOURCE_SEGMENT;
  33. mov ds, ax
  34. mov cx, 0x050 // TODO(Jørn) Hardcded number of bytes to copy
  35. .loop:
  36. movsb
  37. cmp cx, 0x0
  38. je .end
  39. dec cx
  40. jmp .loop
  41. .end:
  42. pop ds
  43. pop si
  44. pop es
  45. pop di
  46. pop bx
  47. pop ax
  48. pop bp
  49. #endasm
  50. }