I need to create a data array of 5 strings each with 4 characters---three '0' characters followed by a lower case letter (a-f)
I need to set up a main function that prints out the set of strings as created in the above section one string per line with no zero bytes at the end of each string.  Then set up a second procedure that will receive the address of the data array on the stack and convert the lower case letter to an upper case letter without modifying any of the '0' characters.  Then print the array again as earlier.

I have some of the code, but for some reason I am getting my end of program string printed on each line and I can't get the strings of the array on seperate lines...I have been working on this for about 6 hrs now and am ready to beat my head against a wall.  I would appreciate any help.  Thanks

Here is what I have...I have written and rewritten this like 60 times, but this is the best I have been able to come up with.

; provide access to the class IO library
%include "c:/tools/lib/asm_io.inc"

; define data needed by the program here ----------------------------
segment    .data
signon      db      'Lab 2 - IOdemo',0
array      dd      '000a'
            dd      '000b'
            dd      '000c'
            dd      '000d'
            dd      '000e'
            dd      '000f'

signoff    db      'End of program',0

; define uninitialized variable containers here
segment    .bss




; program code begins here ------------------------------------------
segment    .text

            global  _asm_main
_asm_main:
            enter      0, 0
            mov        eax, signon
            call        print_string
            call        print_nl
            ; your project code goes below this point

            mov        eax,array
            call        print_string
            call        print_nl

            ; this is the end of the program.
            mov        eax, signoff
            call        print_string
            call        print_nl
            mov        eax, 0
            leave
            ret

            end:
Posted on 2008-07-07 23:19:08 by cannsyl
I currently don't have access to whatever toolkit you are using, nor do I currently have access to NASM on this computer (I'm at a friends house) but give this a shot in the dark and let me know if it works.

; provide access to the class IO library
%include "c:/tools/lib/asm_io.inc"

; define data needed by the program here ----------------------------
segment    .data
signon      db      'Lab 2 - IOdemo',0
array      db      '000a'
            db      '000b'
            db      '000c'
            db      '000d'
            db      '000e'
            db      '000f'

signoff    db      'End of program',0

; define uninitialized variable containers here
segment    .bss


; program code begins here ------------------------------------------
segment    .text

            global  _asm_main
_asm_main:
            enter      0, 0
            mov        eax, signon
            call        print_string
            call        print_nl
            ; your project code goes below this point

            mov        esi,array
            mov        ecx,signoff

.L1:
            cmp        esi, ecx
            je          .eoa

            mov        al,
            call        print_char
            mov        al,
            call        print_char
            mov        al,
            call        print_char
            mov        al,
            call        print_char
            call        print_nl

            add        esi, 4
            jmp        .L1

            ; this is the end of the program.
.eoa:
            mov        eax, signoff
            call        print_string
            call        print_nl
            mov        eax, 0
            leave
            ret

            end:


If it doesn't, name the Nasm toolkit you are working with and when I get home I'll play around with it.
Posted on 2008-07-07 23:53:08 by Synfire
As for the conversion proc (sorry I overlooked that) do this (also search the board, I'm sure there are better methods):

char_upper:
enter 0, 0

cmp al, 'a'
jl .nir
cmp al, 'f'
jg .nir
sub al, 'a'
add al, 'A'

leave
ret

.nir:
xor eax, eax
leave
ret


to use it move the character into AL then call char_upper.
Posted on 2008-07-08 00:09:40 by Synfire
So I do this...
   ; your project code goes below this point

            mov        esi,array
            mov        ecx,signoff

.L1:
            cmp        esi, ecx
            je          .eoa

            mov        al,
            call        print_char
            mov        al,
            call        print_char
            mov        al,
            call        print_char
            mov        al,
            call        print_char
            call        print_nl

            add        esi, 4
            jmp        .L1
            call        char_upper
                         
           
            ; this is the end of the program.
.eoa:
            mov        eax, signoff
            call        print_string
            call        print_nl
            mov        eax, 0
            leave
            ret
    end:



char_upper:
enter 0, 0

cmp al, 'a'
jl .nir
cmp al, 'f'
jg .nir
sub al, 'a'
add al, 'A'

leave
ret

.nir:
xor eax, eax
leave
ret

and the first part works brilliantly, but the second part where it is suppose to change to upper case it's like the code is not even there. 
Posted on 2008-07-08 23:18:43 by cannsyl
Nah, you have put the call to char_upper below the jmp and it should be before each call to print_char like so:
   ; your project code goes below this point

            mov         esi,array ; set ESI to start of array (i=0)
            mov         ecx,signoff ; set ECX to end of array
            xor         eax, eax ; clear EAX register

.L1:
            cmp         esi, ecx ; have we reached the end?
            je          .eoa ; yes, jump to .eoa

            mov         al, ; set AL to array[0]
            call        char_upper ; convert AL to uppercase if 'a'-'f'
            call        print_char ; print AL
            mov         al, ; set AL to array[1]
            call        char_upper ; convert AL to uppercase if 'a'-'f'
            call        print_char ; print AL
            mov         al, ; set AL to array[2]
            call        char_upper ; convert AL to uppercase if 'a'-'f'
            call        print_char ; print AL
            mov         al, ; set AL to array[3]
            call        char_upper ; convert AL to uppercase if 'a'-'f'
            call        print_char ; print AL
            call        print_nl ; print newline

            add         esi, 4 ; move to next element (i++)
            jmp         .L1

            ; this is the end of the program.
.eoa:
            mov         eax, signoff
            call        print_string
            call        print_nl
            mov         eax, 0
            leave
            ret
    end:



char_upper:
enter 0, 0

cmp al, 'a'
jl .nir
cmp al, 'f'
jg .nir
sub al, 'a'
add al, 'A'

leave
ret

.nir:
xor eax, eax
leave
ret


I added some rough commenting to give you an idea of the thought process.
Posted on 2008-07-09 17:38:42 by Synfire
erm..

char_upper:
enter 0, 0

cmp al, 'a'
jl .nir
cmp al, 'f'
jg .nir
sub al, 'a'
add al, 'A'

leave
ret

.nir:
xor eax, eax  <<< isnt this a bug?
leave
ret


and couldnt it be done simpler.. like

char_upper:
enter 0, 0            ; no idea why this is here

cmp al, 'a'
jb .nir
cmp al, 'f'
ja .nir
      sub    al, 'a'-'A'

.nir:
leave
ret
Posted on 2008-07-10 02:05:09 by evlncrn8
The xor eax,eax is equivalent to 'mov eax,0' - he's returning NULL if the input character is not in the legal range.
But you're right about the sub IMM8 followed by add IMM8.
Thats just icky.

Posted on 2008-07-10 06:10:19 by Homer
yeh but...

   call        char_upper ; convert AL to uppercase if 'a'-'f'
            call        print_char ; print AL


char_upper - if char isn't valid it'll return null, and then print_char will print al right?.. and al will be null...

of course, im guessing because i can't see the print_char proc anywhere
Posted on 2008-07-10 08:13:07 by evlncrn8
First off, I noted that there were better implementations. The reason I didn't use 'a'-'A' inline is because I didn't have acces to NASM at the time and wasn't sure if that would assemble correctly, so to avoid that discussion i just used the runtime notation. Second, you are correct, in the last post the 'xor eax, eax' shouldn't be there, I got in a hurry trying to retype the code and I type the "return(0)" equivilant almost automatically like 90% of the time. My bad.
Posted on 2008-07-10 14:18:16 by Synfire
It worked great thanks so much to everyone. 
Posted on 2008-07-11 23:01:09 by cannsyl