Question

Write an assembly language 32 bit program that reads in lines of text by a .txt...

Write an assembly language 32 bit program that reads in lines of text by a .txt file and read in from the user and prints them diagonally. Using good commenting.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
 
  1. .386
  2. .model small, c
  3. ;----------------------------------------------------------------
  4. ; Stak segment
  5. stack_seg SEGMENT stack
  6. DB 100 DUP(?)
  7. stack_seg ENDS
  8. ;----------------------------------------------------------------
  9. ; Data segment
  10. data_seg SEGMENT USE16 'DATA'
  11. Msg1 db 0ah,0dh,0ah,0dh,"*******************Write Some Text*******************$"
  12. reader db 1024 dup(?)
  13. datText db 1024 dup(?)
  14. filename db "dat.txt", 0h
  15. data_seg ENDS
  16. ;----------------------------------------------------------------
  17. ; CODE segment
  18. code_seg SEGMENT USE16 'CODE'
  19. ASSUME cs:code_seg, ds:data_seg
  20. start:
  21. mov ax, data_seg
  22. mov ds, ax
  23. mov ax,0
  24. mov cx,0
  25. ;----------------------------------------------------------------
  26. main PROC
  27. ;Write on scrin TITLE
  28. lea dx,Msg1
  29. mov ah,09h
  30. int 021h
  31. ;New Line
  32. mov ah,02h
  33. mov dl,0ah
  34. int 021h
  35. mov ah,02h
  36. mov dl,0dh
  37. int 021h
  38. lea si,reader
  39. mov cx,0
  40. Here:
  41. mov ah,08h
  42. int 021h
  43. cmp al,0dh
  44. je exit; if user press ENTER key exit
  45. mov [si],al
  46. inc si
  47. inc cx
  48. jmp Here
  49. exit:
  50. mov di,cx; counter
  51. mov ah, 03ch
  52. mov cx, 0
  53. lea dx, filename
  54. int 21h
  55. mov ah, 03Dh
  56. mov al, 01h ;
  57. lea dx, filename
  58. int 21h
  59. mov bx, ax ; file-handle
  60. mov cx,di
  61. ; WRITE in .txt file
  62. mov ah, 040h
  63. lea dx, reader
  64. int 21h
  65. ; Close .txt file
  66. mov ah, 03eh
  67. int 21h
  68. ;Open .txt file
  69. mov ah,3dh
  70. mov al,02h
  71. lea dx,filename
  72. int 021h
  73. MOV CX,??????
  74. mov ah,3fh
  75. lea dx,datText
  76. int 021h
  77. lea si,datText
  78. ;Here i ned to now count of chars readed from .txt file and mov that number in CX reg (in this case 11 from "Hello world") for example
  79. print:
  80. cmp CX,0
  81. je endX
  82. mov ah,02h
  83. mov dl,[si]
  84. int 021h
  85. inc si
  86. dec CX
  87. jmp print
  88. EndX:
  89. ;Close .txt file
  90. mov ah, 03eh
  91. int 21h
  92. mov ax, 04c00h
  93. int 021h
  94. ;*************************************************************************************
  95. main ENDP
  96. code_seg ENDS
  97. END start
Add a comment
Know the answer?
Add Answer to:
Write an assembly language 32 bit program that reads in lines of text by a .txt...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT