GunnerInc 7 xor eax, eax Team Colleague

Nobody is taught to use comments anymore? It is so important to comment your code in Assembly, ESPECIALLY in ancient 16bit code where functions don't have names but numbers!!

Your getting weird characters because after you get the input character, you are modifying it by adding 20h to dl.

To print each letter on a new line, you need to add a call to your nlcr in your y loop, but you must also save the register dx

This should get you started:

 main proc
        mov     ax,@data
        mov     ds, ax

        mov     ah, 9
        lea     dx, string
        int     21h

        call    nlcr

        mov     ah, 9
        lea     dx, string2
        int     21h

        mov     ah, 1       ; get user input
        int     21h
        mov     dl, al

        call    nlcr        ; print CRLF 

        mov     cx, 25      ; print 25 chars in loop
        inc     dl          ; adjust to print input char on 1st iteration
    PrintChar:
        mov     ah, 2       ; print char
        dec     dl
        int     21h

        call    nlcr        ; print CRLF

        loop    PrintChar   ; repeat loop until cx == 0

        mov     ah, 4ch     ; goodbye
        int     21h
    main endp

    nlcr proc
        push    dx          ; save dx since dl contains char to print

        mov     ah, 2
        mov     dl, 13
        int     21h

        mov     dl, 10
        int     21h

        pop     dx          
        ret
    nlcr endp
GunnerInc 7 xor eax, eax Team Colleague

That is all great, so since you didn't meantion what Assembler, I will give you code that you could assemble with say YASM.

DOSBox? That means 16 bit code. Why oh why on earth do you want to use that? That is DEAD, let it rest in peace!! Learn 32bit code!!!!

Do you have any idea how it should be implemented or you just didn't pay attention in class?

You say you are "trying" to write a program, this means you have started coding and are stuck? Show us the code you have so far.

GunnerInc 7 xor eax, eax Team Colleague

Yes there IS a really BIG difference writing 64bit Assembly code verses 32bit code. Especially when it comes to Windows Programming (I am sure Linux is the same). You have a different calling convention, "shadow space", more memory addresses, more registers, stack should be/has to be aligned.

Learn 32bit first to get a firm understanding of how memory, cpu, program flow works. Then lean 64bit, skip 16bit it is dead.

GunnerInc 7 xor eax, eax Team Colleague

Well, if you like MASM take a look at JWASM. It is fully MASM compatable (Meaning if you have an app written in MASM, JWASM will Assemble it without many complaints) Plus, it is 64bit compatible AND cross-platform

GunnerInc 7 xor eax, eax Team Colleague

Think of your matrix like this:
it does not look like this in memrory

1 2 3
 4 5 6
 7 8 9

it looks like: 1 2 3 4 5 6 7 8 9 (spaces added for clarity)

So, load the array, print the first number then add 3 to the address print number, add 3 to the address and print number, print next 2 numbers, subtract 3 and print number, subtract 3 again and print number, sub 1 print number, sub 1 and print final number...

GunnerInc 7 xor eax, eax Team Colleague

Uh, = is not equals it should be 2 equal signs == as in (ecx == 0) || (ecx == 2) etc...

The funny thing with macros (yes .if/.while are macros) is the error number will happen after the macro call...

datdude07 commented: great help! +1
GunnerInc 7 xor eax, eax Team Colleague

Your Fibo algo works fine.

It prints wrong because you are passing the wrong thing to the write file function

mov edx,OFFSET pointarray

this is wrong, this is a pointer to a pointer. Remove offset and it will work. Better yet, cut down on uneeded globals and just do

mov edx,offset array

fix that and it will write the proper file. You cannot open it in notepad and get the correct results, you can open in a hex editor or what the homework says.

GunnerInc 7 xor eax, eax Team Colleague

If you wrote a program in Assembly, then when you pass your code through the assembler you get a "one to one" translation (what you wrote in Assembly is what will be in the exe file), now if on the other hand, you thought you wrote in Assembly and passed your code through a compiler, then yes you will have more code in the debugger/disassembler.

Also, if you link to static libs in your program than yes, you will seem to have more code then you explicitly wrote since that code is added during the assembly process. The assembler you used could also add padding to your sections, procs, etc for alignment purposes, replace some mnemonics for optimization, you might be seeing relocations not sure without seeing your disassembly... but in general, what you write in assembly is what you will see in the debugger... (Not sure about 16 bit asm)

GunnerInc 7 xor eax, eax Team Colleague

Probably line 31? You are trying to move a DWORD into a BYTE... in MASM it would be:

mov    al, BYTE PTR [ebx]

in this way the assembler knows we only want to move a byte from ebx to al.

Wait, HLA is backwards right? you are moving from al to ebx right? either way, BYTE PTR should be correct.

GunnerInc 7 xor eax, eax Team Colleague

hmm, you don't pay attention in class and now you want us to write your code? nope won't do it.... you learn nothing.... show some effort for cryin out loud! write some code... and when you get stuck, we will help...

sDJh commented: hehe, can't say that better! +6
GunnerInc 7 xor eax, eax Team Colleague

Sorry, done with thread now....