please can some one help me with option 2 of my program . i am trying to get the program to accept a string from the user and then print it out in a new screen this is what i've got so far. it works but the only problem is that it prints out a whole load of numbers after it which i don't want.

mainmenu:
mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu1
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu2
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu3
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu4
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu5
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu6
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, quit
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, message
int 33


option1:

mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu1
int 33
mov AH, 63
mov CX, 20
lea DX, text
mov BX, 0
int 33
sub AX, 2
mov lenght, AX



option2:

mov ah, 0
mov al, 7
int 16
mov AH, 9
lea DX, text
int 33




hlt
menu db 'assignment-menu$'
menu1 db '1.enter a string$'
menu2 db '2.print out the string$'
menu3 db '3.print out string in reverse$'
menu4 db '4.menu optin four$'
menu5 db '5.menu optin five$'
menu6 db '6.menu optin six$'
quit db '7.quit$'
message db 'select an option$'
text db '1234567890123456789012345'
crlf db 13, 10, 36
lenght DW '0'

any help would be great
Posted on 2003-03-16 11:33:11 by evilz35
option three of my program should print out the entered string in reverse. i know to do this i must first feed it into a array. i have done this but can any one tell me how i print the contents of a array. and more importantly how i print the contents of the array in reverse.
here is what i have done so far.

mainmenu:
mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu1
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu2
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu3
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu4
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu5
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu6
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, quit
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, message
int 33


option1:

mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu1
int 33
mov AH, 63
mov CX, 20
lea DX, text
mov BX, 0
int 33
sub AX, 2
mov lenght, AX



option2:

mov ah, 0
mov al, 7
int 16
mov AH, 9
lea DX, text
int 33

mov cx, 0
lea si, text
lea di, textcopy

loop:
mov dl,
mov , dl
inc si
inc di
inc cx
cmp cx, lenght
jb loop

;option 3:



hlt
menu db 'assignment-menu$'
menu1 db '1.enter a string$'
menu2 db '2.print out the string$'
menu3 db '3.print out string in reverse$'
menu4 db '4.menu optin four$'
menu5 db '5.menu optin five$'
menu6 db '6.menu optin six$'
quit db '7.quit$'
message db 'select an option$'
text db '1234567890123456789012345'
crlf db 13, 10, 36
lenght DW '0'
textcopy db '1234567890123456789012345'



























:) :) :( :o :o
Posted on 2003-03-16 13:38:15 by evilz35
ebilz35, I couldn't run the emulator you sent me, it gave a 'device not ready' error and terminated immediately.
You could print the string by getting the offset of the last byte (= offset string + size string - 1), then scan backwards and print character by character until you've had all characters.
You could also put the bytes in reversed order in another buffer first and then print it, or use the same buffer by swapping the bytes at index and while x < (length-x-1).

Thomas
Posted on 2003-03-16 14:36:47 by Thomas
how would i do that- in terms of code, i don't know how to access the array and print out the contents
Posted on 2003-03-16 15:36:40 by evilz35
Well I can't give you more hints or I'll write the full code for you. If that's what you want I'll show you but what's the point of doing this then? You really need a basic understanding of assembly language, find some tutorials (like the Art Of Assembly) and read them. These tasks are not hard, just try and look at examples.

Thomas
Posted on 2003-03-16 16:04:07 by Thomas
well i think you missed the dollar sign at the end of your 'text' string variable, for one
Posted on 2003-03-16 19:40:26 by Kobra
i have looked at the art of assembly ad i really don't understand what the page is talking about. please could u just help me with this exercise. i've done most of it i just need to know how the code for accesing the array and then printing it.
Posted on 2003-03-17 05:00:34 by evilz35
An array is nothing more than a serie of memory locations. You already know how to read from a given location, just add a value (the index in the array) to the base address of the array and read from that location. I have explained this already in this thread.

Thomas
Posted on 2003-03-17 05:17:44 by Thomas
this is what i've got so far and it does'nt seem to be working

mainmenu:
mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu1
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu2
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu3
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu4
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu5
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, menu6
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, quit
int 33
mov ah, 9
lea DX, crlf
int 33
mov ah, 9
lea DX, message
int 33


option1:

mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu1
int 33
mov AH, 63
mov CX, 20
lea DX, text
mov BX, 0
int 33
sub AX, 2
mov lenght, AX



option2:

mov ah, 0
mov al, 7
int 16
mov AH, 9
lea DX, text
int 33

mov cx, 0
lea si, text
lea di, textcopy

loop:
mov dl,
mov , dl
inc si
inc di
inc cx
cmp cx, lenght
jb loop

mov ah, 0
mov al, 7
int 16
mov bl, textcopy


option3:
mov ax, lenght
mov dx,
dec lenght



hlt
menu db 'assignment-menu$'
menu1 db '1.enter a string$'
menu2 db '2.print out the string$'
menu3 db '3.print out string in reverse$'
menu4 db '4.menu optin four$'
menu5 db '5.menu optin five$'
menu6 db '6.menu optin six$'
quit db '7.quit$'
message db 'select an option$'
text db '1234567890123456789012345$'
crlf db 13, 10, 36
lenght DW '0'
textcopy db '1234567890123456789012345':confused: ;) :tongue: :o
Posted on 2003-03-17 05:33:31 by evilz35
how would i do that- in terms of code, i don't know how to access the array and print out the contents
Dude, that is one of the most basic fundamental things in programming, if you don't know it then what are doing messing with asm???!!! :rolleyes:

Thomas has been good to you answering your question, but remember this forum is not the place to ask "please can you do my homework/assignment" type questions, nor is it the place to request complete source for any particular problem. Programming is all about solving problems, if you get spoon fed the answers you will never learn how to do it yourself.

Accessing the elements in an array is done pretty much the same in any language, so do a little search to find the answer (and examples). I just did a quick search on google using the keywords simple array indexing example and got around 64,000 search hits covering every computer language known to man.

Note that i am not trying to flame or harrass you, i am just stirring you up and trying to motivate you to do a little research before posting threads like this. I am your friend, honestly. :o
Posted on 2003-03-17 06:13:46 by sluggy
Hi evilz35,

Do you use any TSR or emulator? If not, I thing interrupt numbers wrong.

- int 33h is mouse interrupt, but here like "print string"



.data
string db 'For Example$',0

.code

mov ah,9
mov dx,string
int 21h
...



- int 16 get keyboard scan code, you can use like below:



mov ah,0
int 16h
; al= ASCII char or zero id special func.key.


- What for you use this function? i don't understand,




mov AH, 63 ; ? this fnc use only dos v2.25
mov CX, 20
lea DX, text
mov BX, 0
int 33



If you can more comment , i can help you,

Regards,
Posted on 2003-03-17 07:20:05 by CYDONIA
-- merged your two separate threads into one

CYDONIA: 33 dec = 21 hex :). The interrupt numbers are correct.
evilz35: Just posting your code again isn't going to help. Sluggy has said it all, these are very basic things. Just read some tutorials and you will understand. Don't give up immediately.
If we give you the code you learn nothing from it. You need to understand the basics, "we can't teach you maths if you don't know how to count".

Btw isn't possible on a 8086, is.

Thomas
Posted on 2003-03-17 07:32:12 by Thomas
Hi Thomas,


CYDONIA: 33 dec = 21 hex . The interrupt numbers are correct.


You are right ! :stupid: I don't care,

Regards,
Posted on 2003-03-17 07:40:53 by CYDONIA
i've managed to get a bit further can n e 1 tell me wherei'm going wrong.


--- stripped code for readability (not relevant) --- Thomas

option1:

mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu1
int 33
mov AH, 63
mov CX, 20
lea DX, text
mov BX, 0
int 33
sub AX, 2
mov lenght, AX



option2:

mov ah, 0
mov al, 7
int 16
mov AH, 9
lea DX, text
int 33

mov cx, 0
lea si, text
lea di, textcopy

loop:
mov dl, [si]
mov [di], dl
inc si
inc di
inc cx
cmp cx, lenght
jb loop




option3:
mov si, 0
lea bp, textcopy
loop:
mov al, [bp]
add al, 1
mov dl, al
inc bp
inc si
cmp si, lenght
jbe loop

hlt
menu db 'assignment-menu$'
menu1 db '1.enter a string$'
menu2 db '2.print out the string$'
menu3 db '3.print out string in reverse$'
menu4 db '4.menu optin four$'
menu5 db '5.menu optin five$'
menu6 db '6.menu optin six$'
quit db '7.quit$'
message db 'select an option$'
text db '1234567890123456789012345$'
crlf db 13, 10, 36
lenght DW '0'
textcopy db '1234567890123456789012345'
Posted on 2003-03-17 09:59:20 by evilz35
option3:

mov si, 0
lea bp, textcopy
loop:
mov al, [bp]
add al, 1
mov dl, al
inc bp
inc si
cmp si, lenght
jbe loop


===

int si = 0;

int j = 0;
while (si<=length)
{
char al = textCopy[j++];
al++;
char dl = al;
}


You're not doing anything with the string...

Thomas
Posted on 2003-03-17 10:34:33 by Thomas
Remove this code:
mov cx, 0

lea si, text
lea di, textcopy

loop:
mov dl, [si]
mov [di], dl
inc si
inc di
inc cx
cmp cx, lenght
jb loop


Replace it with "jmp mainmenu". Also add the same instruction at the end of option 1 and option 3, otherwise option 3 quits the program and option 1 will fall through to option 2.

Then try to translate this into assembler for option3:


int j = length-1;
for (int i=0;i<length;i++)
{
char c = text[i];
textcopy[j] = c;
j--;
}
print(textcopy);


Thomas
Posted on 2003-03-17 10:39:11 by Thomas
thanks for that



i've been racking my brain for ages trying to figure out where i am going wrong. i am on option 3 but can't see where i'm going wrong. . i have spent 3 hours tidying up the code and trying to figure out option 3 .can you please give me some more hints

;Suresh Dutt
;Tutor Group E
;Student ID Number 02183042

start_of_program:
mov AH, 0
mov AL, 7
int 16
mov AH, 9
mov AL,
lea DX, menu
int 33
mov AH, 1
int 33
mov choice, AL

try_1:
cmp choice, '1'
jne try_2
mov ah, 0
mov al, 7
int 16
mov ah, 9
lea DX, menu1
int 33
mov AH, 63
mov CX, 20
lea DX, text
mov BX, 0
int 33
sub AX, 2
mov ax, lenght
jmp start_of_program

try_2:
cmp choice, '2'
jne try_3
cmp choice, '2'
jne try_3
mov AH, 0
mov AL, 7
int 16
mov ah, 040
mov bx, 1
mov cx, lenght
mov AH, 9
lea DX, text
int 33
jmp start_of_program

try_3:
cmp choice, '3'
;jne try_4
cmp choice, '3'
;jne option4
mov si, 0
lea bp, text
jmp loop

loop:

mov al,
mov dl, al
mov al, dl
int 33
add al, 1
mov , al
inc bp
inc si
cmp si, lenght
jbe loop
jmp start_of_program
hlt
menu1 db '1.enter a string$'
menu2 db '2.print out the string$'
menu3 db '3.print out string in reverse$'
menu4 db '4.menu optin four$'
menu5 db '5.menu optin five$'
menu6 db '6.menu optin six$'
lenght DW '0'
menu db 'ASSIGNMENT MENU'
db 13, 10
db 13, 10
db '1 Enter a new string'
db 13, 10
db '2 Print out the string'
db 13, 10
db '3 Print out the string in reverse'
db 13, 10
db '4 Menu Option Four'
db 13, 10
db '5 Menu Option Five'
db 13, 10
db '6 Menu Option Six'
db 13, 10
db '9 Menu Option Quit'
db 13, 10
db 13, 10
db 'Please Choose an Option:$'
choice db 0
menu1 db '1.enter a string$'
lenght DW '0'
text db '1234567890123456789012345$'
Posted on 2003-03-17 13:27:55 by evilz35
I have given you all the hints I can, I can't give you more, only the solution. :rolleyes: So that's what I'll do, here it is (untested as I can't run your simulator):


;Suresh Dutt
;Tutor Group E
;Student ID Number 02183042

start_of_program:
mov ah, 0
mov al, 7
int 16

mov ah, 9
mov al,
lea dx, menu
int 33

mov ah, 1
int 33

cmp al, '1'
je opt1
cmp al, '2'
je opt2
cmp al, '3'
je opt3
hlt


opt1:
mov ah, 0
mov al, 7
int 16
mov ah, 9
lea dx, menu1
int 33

mov ah, 03F
mov cx, 25
lea dx, text
mov bx, 0
int 33
sub ax, 2
mov length, ax
jmp start_of_program

opt2:
mov ah, 0
mov al, 7
int 16
mov ah, 040
mov bx, 1
mov cx, length
lea dx, text
int 33
jmp start_of_program

opt3:
lea si, text
lea di, textRev
mov cx, length
add di, cx
dec di ; di = textRef + length - 1
test cx, cx
jz _emptyString
xor dx, dx ; dx = 0
_m1:
lodsb ; al = [si], si++
mov [di], al ; [di] = al
dec di ; di--;
loop _m1 ; loop length times
_emptyString:

mov ah, 040
mov bx, 1
mov cx, length
lea dx, textRev
int 33
jmp start_of_program

menu db 'ASSIGNMENT MENU'
db 13, 10
db 13, 10
db '1 Enter a new string'
db 13, 10
db '2 Print out the string'
db 13, 10
db '3 Print out the string in reverse'
db 13, 10
db '4 Menu Option Four'
db 13, 10
db '5 Menu Option Five'
db 13, 10
db '6 Menu Option Six'
db 13, 10
db '9 Menu Option Quit'
db 13, 10
db 13, 10
db 'Please Choose an Option:$'

menu1 db 'Enter a string: $'

length dw 0
text db 25 dup (0)
textRev db 25 dup (0)


Now read it, study it, understand it and try the other options yourself.

Thomas
Posted on 2003-03-17 14:22:02 by Thomas
did'nt work but thanks n e way:stupid: :cool: :grin: :grin: :) :(
Posted on 2003-03-17 14:35:15 by evilz35