Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Assebly troubles

Name: Anonymous 2010-11-07 8:39


...
mov si, field

mov ax, 0
mov [variable], ax
mov cx, 10

cyclus:
    mov ax, [SI]
    cmp ax, [variable]
    jbe skip
        mov [variable], ax
    skip:
    inc si
    loop cyslus
    mov ax, [v4]

...

in data section:

field dw 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
variable resw 1

...
I get stack. Do you know where is the problem??? I want to get biggest number from fiel and store it in variable

Name: Anonymous 2010-11-07 8:43

Too intel, didn't read.

Do you know where is the problem???

Use debugger. If you used normal OS, I'd recommend you gdb or OllyDbg. But if it's dos, then have fun with TD(aka Turbo Debugger).

Name: Anonymous 2010-11-07 8:47

alsous
>cyclus
Whyus sous Latinus?

Name: Anonymous 2010-11-07 8:47

I used it. The problem is when I call mov ax, [SI]. It should point to the number from filed - eg DS:[SI], but I get wrong number. How can I acces it then?!

Name: Anonymous 2010-11-07 8:52

Exaplainus yourselfus, please.

What do you mean, wrong number?
What does it get instead? CS:[SI]? SI? Or SI contains wrong address?

mov si, field

can mean two things

mov si, offset field
mov si, [offset field]

Name: Anonymous 2010-11-07 8:56

I translate it with NASM. It should be address of field - so offset. Or am I wrong?

Name: Anonymous 2010-11-07 8:59

inc si
dw

Name: Anonymous 2010-11-07 11:57

thanks for reply. So i would call add si, 2. But the problem is, that i cannot get value stored in data section by SI. When I run this program in debugger, i get segfault because ds:[si] doesnt point to field.

Name: Anonymous 2010-11-07 14:04

Noone geeky enought?
I run this simple program and I get bad values in al.


SECTION CODE:

..start:
mov si, field
mov cx, 2
cyc:
    mov al, [si] ;HERE IS MY PROBLEM MAKER
    inc si
loop cyc

; Call DOS to exit
mov ah, 0x4c
int 0x21

SECTION DATA:
field db 1, 2

Please help!!

Name: Anonymous 2010-11-07 17:17

y u no lodsb

Name: Anonymous 2010-11-07 18:31

>>9
Maybe you need to initialize ds? See the code in http://nasm.us/doc/nasmdoc7.html#section-7.4
Note that segmentation is a pain that you don't have to deal with if you write assembly for any modern system.

Name: Anonymous 2010-11-08 3:38

>Noone geeky enought?

>; Call DOS to exit
>DOS

here is your program. Do you know it's 21st century already?

Name: Anonymous 2010-11-08 3:40

>program

s/gra/ble

but your program and your problem are synonyms here.

Name: Anonymous 2010-11-08 4:17

Colonel: Stop, stop it, this is silly!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List