Reputation: 21
.MODEL TINY
Kod SEGMENT
ORG 100h/256
ASSUME CS:Kod, DS:Tekst, SS:Stosik
Start:
jmp Petla
Tekst DD napis, '$'
Poczatek:
mov bl, napis
Petla:
cmp ah, '$'
mov al, [bx]
jne Wyswietlenie
inc bh
mov [bx], ax
cmp al, '$'
mov [bx - 1], ax
je Wyswietlenie
mov [bx], bl
dec bl
jmp Petla
Wyswietlenie:
mov ah, 09h
mov dx, OFFSET Tekst
int 21h
mov ax, 4C70h
int 21h
ENDPRG Poczatek
KOD ENDS
the error in the DOS is "Fatal program.asm(56) Unexpected end of file encounter". The program should change letters in the word. Any suggests what can I do? I don't know what to edit to make it even lunch in DOS to check it step by step in the debugger.
Upvotes: 0
Views: 7188
Reputation: 21
First and foremost, if you have used
;then you have to end it also and to end it please write
; at the end of code
Further, the assembler NEEDS END directive as the END OF FILE command. So, as we saw that "END START" is to be included in the code. But where?
The answer is that assembler always looks for END directive for END OF FILE command. So, include END START as the last line of code.
Note: FATAL ERROR ,UNEXPECTED END OF FILE error will be solved by this, but I have not debugged other possible errors if there
Upvotes: 0
Reputation: 47633
Without knowing what the original code you were given to fix is,and what the program is suppose to do I can tell you how to fix the issues that will allow you to at least compile and link this as a DOS COM program. I know that this assignment has a header (comments) that you have removed so I don't know what the program is suppose to do. If you provided the original assignment (including the header) in an update your question I might be able to help you further.
As it stands, with a DOS COM program you don't create SEGMENTS
like a DOS EXE. So you have to remove the kod SEGMENT
, ASSUME CS:Kod, DS:Tekst, SS:Stosik
, KOD ENDS
. You will have to place a .code
directive after .model TINY
and set the origin point with org 100h
. A COM program needs an entry point. The entry point is Start
. You need to end a COM program with an END
statement that has the name of entry point in it. So the end of your file needs END Start
.
The line Tekst DD napis, '$'
needs to be Tekst DB "napis", '$'
. Strings are created with DB
(byte) directive and the string needs to be enclosed in quotes. The line mov bl, napis
needs to move the offset (address) of Tekst
to BX, not napis
, so it should be mov bx, offset Tekst
The code to get you started so that you can at least assemble and link can look like this:
.MODEL TINY
.code
ORG 100h
Start:
jmp Poczatek
Tekst DB "napis", '$'
Poczatek:
mov bx, offset Tekst
Petla:
cmp ah, '$'
mov al, [bx]
jne Wyswietlenie
inc bh
mov [bx], ax
cmp al, '$'
mov [bx - 1], ax
je Wyswietlenie
mov [bx], bl
dec bl
jmp Petla
Wyswietlenie:
mov ah, 09h
mov dx, OFFSET Tekst
int 21h
mov ax, 4C70h
int 21h
END Start
You should be able to use the turbo debugger to run and test the program and fix the logical errors that I can't help you with given the information provided.
I suspect from the code that the intent is to swap each pair of characters until the end of string is found. If that is the case then the main part of the code would probably be this:
Start:
jmp Poczatek
Tekst DB "napis", '$'
Poczatek:
mov bx, offset Tekst
Petla:
mov ah, [bx]
cmp ah, '$'
je Wyswietlenie
inc bx
mov al, [bx]
cmp al, '$'
je Wyswietlenie
mov [bx - 1], al
mov [bx], ah
inc bx
jmp Petla
Upvotes: 2