Help me, please...
Why my code incorrect?
When i run debugger, my program start to work from first segment instead code segment?
title CharProcessing
text segment
txt db 200 dup (?)
text ends
stack segment
S db 100 dup (?)
stack ends
INCH macro x
mov ah, 7h
int 21h
mov bl, al
mov x, bl
endm
OUTCH macro c
mov dl, c
mov ah, 2h
int 21h
endm
FINISH macro
mov ax, 4C00h
int 21h
endm
NEWLINE macro
OUTCH 13
endm
code segment
assume cs: code, ds: text, ss: stack
; set start params
OUTCH '>'
cld
mov ax, text
mov ds, ax
mov ax, stack
mov ss, ax
mov di, 0h
mov si, 0h
; read text
Read:
INCH al
cmp al, '.'
je Next
stosb
jmp Read
; print source text
Next:
lodsb
OUTCH al
cmp si, di
jbe Next
; test
mov al, [di]
cmp al, 'A'
jb Prop2
cmp al, 'Z'
jg Prop2
mov si, 0h
Next2:
cmp al, ds: [si]
je Prop2
inc si
cmp si, di
jb Next2
call rule1
jmp Result
Prop2:
call rule2
jmp Result
; rule # 1
rule1 proc
mov si, 0h
L:
lodsb
cmp al, 'a'
jb Cont
cmp al, 'z'
jg Cont
add al, 32
mov ds: [si], al
Cont:
cmp si, di
jbe L
ret
rule1 endp
; rule # 2
rule2 proc
mov si, di
mov cx, si
std
L1:
lodsb
push ax
loop L1
cld
mov cx, di
mov di, 0h
L2:
pop ax
mov ah, al
stosw
loop L2
ret
rule2 endp
; print result code
NEWLINE
Result:
mov cx, di
L:
lodsb
OUTCH al
loop L
FINISH
code ends
end
Artem,
why dont you declare the start label? basically all .asm files terminated by <END StartLabel>
>>asmfan
Do you speak Russia? I viewed you blank and had noted you location.
In theory labels isn't requested.
Artem,
i speak a little bit;)
...but in practice they (labels) are needed. or otherwise you'll get what you have now (execution from the first byte of the first section).
use <END Start>
Really label is needed...
Thanks!
So, I don't understand meaning of "assume"...
Quote from: ArtemESC on April 08, 2006, 05:47:21 PM
So, I don't understand meaning of "assume"...
Here is a 32-bit implementation of ASSUME. Maybe this will help.
SOME_STRUCT STRUCT
Element1 DD ?
Element2 DD ?
Element3 DD ?
SOME_STRUCT ENDS
.data?
MyStruct1 SOME_STRUCT<>
MyStruct2 SOME_STRUCT<>
MyStruct3 SOME_STRUCT<>
.code
ASSUME EAX:PTR MyStruct1
MOV [EAX.Element1], 10101010h
MOV [EAX.Element2], 12345678h
MOV [EAX.Element3], 87654321h
ASSUME EAX:PTR MyStruct2
MOV [EAX.Element1], 10101010h ; ...etc.
ASSUME EAX:NOTHING
There is an explination of the various ASSUME functions in the MASM32 v9.0 installation under \masm32\help\masm32.hlp
Quote from: ArtemESC on April 08, 2006, 05:47:21 PM
Really label is needed...
Thanks!
So, I don't understand meaning of "assume"...
Assume указывает какой сегмент к какому сегментному регистру относится,
в простых программах можно не указывать, но иногда бывают "тяжелые" случаи когда Assume необходим, как например в листингах BIOS которые приводила IBM; в книге Пильшикова "Ассемблер" довольно внятно про нее рассказано