0

I have a problem with my assembler language program using mmx. This program declares 3 arrays, and then adds two to each other and stores the result in 3. What went wrong?

%define ITERATIO 16

org 100h

start:
    movq mm0, [tab1] 
    paddb mm0, [tab2] 
    movq [tab3], mm0 

    mov cx, ITERATIO

    mov ah, 2 

loop1:
    mov si, tab3
    add si, ITERATIO 

    sub si, cx
    mov dx, [si]

    int 21h 
    loop loop1

    mov ax, 4C00h
        int 21h

tab1 times ITERATIO db 41
tab2 times ITERATIO db 28 
tab3 times ITERATIO db 65
zx485
  • 28,498
  • 28
  • 50
  • 59
puac
  • 11
  • 4
    Note that an MMX register is 8 bytes not 16. – Jester Jan 08 '19 at 23:20
  • The output I'd expect is "`EEEEEEEEAAAAAAAA`", mostly because Jester is right. – Brendan Jan 09 '19 at 02:05
  • 1
    That print loop indexing with `add si, ITERATIO` / `sub si, cx` is super awkward compared to just incrementing a pointer and `cmp si, tab3+ITERATIO` / `jb`. You don't have to use the slow `loop` instruction. It's not fast on most CPUs that support MMX. – Peter Cordes Jan 10 '19 at 10:31
  • I changed the iteratio from 16 to 8, but still, when I run the program, it crashes. This happens with the first line it is: "movq mm0, [tab1]". What i should change?I tried to find a good tutorial about mmx, but I haven't found anything, do you know any? – puac Jan 12 '19 at 19:25
  • How does it crash and how do you run it? You know this is a 16 bit DOS program, right? – Jester Jan 14 '19 at 00:57

0 Answers0