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
  • Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like...

    Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like C or Java. It does not need to run for me, but the code should be included in a text document called FirstnameLastnameHLA3.txt along with your assignment submission. Implement the program in MIPSzy Assembly language. Use the high level code as comments to the right of the Assembly code as the textbook does. If you write that MIPSzy...

  • IN PYTHON Write a program that reads two text files, take one sentence from each text...

    IN PYTHON Write a program that reads two text files, take one sentence from each text file and print them one after another. Example: If line1 is from text1.txt and line2 is from text2.txt, then print line1 line2 Repeat this for all the lines of the two files

  • JAVA Write a program that 1. opens a text file 2. reads lines of text from...

    JAVA Write a program that 1. opens a text file 2. reads lines of text from the file 3. Converts each line to uppercase 4. saves them in an ArrayList 5. Writes the list of Strings to a new file named "CAPSTEXT.txt" Mainjavo ext.txt Instructions from your teacher 1 My mistress' eyes are nothing like the sun; 2 Coral is far more red than her lips' red; 3 If snow be white, why then her breasts are dun; 4 If...

  • 3. Write a program in assembly language that reads a number from the keyboard and displays...

    3. Write a program in assembly language that reads a number from the keyboard and displays it on the screen. 4. Write a program in assembly language to ask two digits from the user, store the digits in the EAX and EBX register, respectively, add the values, store the result in a memory location 'res' and finally display the result.

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • Code in assembly language please "Write an assembly 32 bit program that adds two numbers (other...

    Code in assembly language please "Write an assembly 32 bit program that adds two numbers (other than 5 and 6) and stores the value to a variable called 'sum'. Also, use a block COMMENT to depict the name and description of the program, author of the program, and date."

  • Write a program that allows the user to navigate the lines of text in a file....

    Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program...

  • Write a program that reads in a text file, infile.txt, and prints out all the lines...

    Write a program that reads in a text file, infile.txt, and prints out all the lines in the file to the screen until it encounters a line with fewer than 4 characters. Once it finds a short line (one with fewer than 4 characters), the program stops. For your testing you should create a file named infile.txt. Only upload your Python program, I will create my own infile.txt. Please use a while-loop BUT do not use break, Exit or Quit...

  • Write a program that performs the following: - Reads from the file "myfile.txt" using readlines() -...

    Write a program that performs the following: - Reads from the file "myfile.txt" using readlines() - Prints out the contents of the file "myfile.txt", that was read into a list by readlines(). Note that this should not look like a list, so you will need to loop through the list created by readlines and print the text. - Use the try/except method to create the file if it does not exist - If the file does not exist, prompt the...

  • Write a MIPS Assembly language program to request a file name from the user, open the...

    Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write it out to the console.

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