Simple Simple Question

[b][red]This message was edited by ii0oo0ooii at 2003-3-31 19:24:23[/red][/b][hr]
Well, simple to pros :)

I am well versed in c++/java, but I am messing around with assembly. Just wondering, how to input an integer (16 bit, i am using MASM by the way...) and simply output the number i had inputted. I figured out how to output text (I took sippets from here and created a simple hello world program) but I cannot figure out how to take input and echo it out. thanks a lot.

btw, LOL in C++ what i am doing is this:

#include
void main(){
int c;
cin>>c;
cout<<c;
}//end main


Comments

  • : [b][red]This message was edited by ii0oo0ooii at 2003-3-31 19:24:23[/red][/b][hr]
    : Well, simple to pros :)
    :
    : I am well versed in c++/java, but I am messing around with assembly. Just wondering, how to input an integer (16 bit, i am using MASM by the way...) and simply output the number i had inputted. I figured out how to output text (I took sippets from here and created a simple hello world program) but I cannot figure out how to take input and echo it out. thanks a lot.
    :
    : btw, LOL in C++ what i am doing is this:
    :
    : #include
    : void main(){
    : int c;
    : cin>>c;
    : cout<<c;
    : }//end main
    :
    :
    :
    [blue]You need to:
    1. Input the text with digits (like "53739") using Function 0Ah from INT 21H
    2. Convert this text into a WORD (16-bit) value, so you can perform calculations with it.
    3. Convert it back from WORD value into string
    4. Echo it using Function 9 from INT 21H.

    There are some conversion functions on my site: www.codexxi.com -> Components. See some sample code for TASM.[/blue]
  • ok this is my prob... I dont understand assembly too much, but I want to. this is what i did to make my program output. to be honest, i have NO idea how to input data.

    ; hello world program
    .MODEL small
    .STACK 100h
    .DATA

    message db 'hello world$'
    .CODE

    start:
    mov ax, @data
    mov ds, ax
    mov ah, 9

    mov dx, offset message
    int 21h
    mov ax, 4c00h ; exit sequence

    int 21h

    end start


    instead of message db 'hello world$'
    would i put
    message db 0ah ; ??
    not too sure on really what to do. I understand the process I need to do (as i showed VERY easily with c++) but I just dont know how to do it in assembly. thanks.

    : : [b][red]This message was edited by ii0oo0ooii at 2003-3-31 19:24:23[/red][/b][hr]
    : : Well, simple to pros :)
    : :
    : : I am well versed in c++/java, but I am messing around with assembly. Just wondering, how to input an integer (16 bit, i am using MASM by the way...) and simply output the number i had inputted. I figured out how to output text (I took sippets from here and created a simple hello world program) but I cannot figure out how to take input and echo it out. thanks a lot.
    : :
    : : btw, LOL in C++ what i am doing is this:
    : :
    : : #include
    : : void main(){
    : : int c;
    : : cin>>c;
    : : cout<<c;
    : : }//end main
    : :
    : :
    : :
    : [blue]You need to:
    : 1. Input the text with digits (like "53739") using Function 0Ah from INT 21H
    : 2. Convert this text into a WORD (16-bit) value, so you can perform calculations with it.
    : 3. Convert it back from WORD value into string
    : 4. Echo it using Function 9 from INT 21H.
    :
    : There are some conversion functions on my site: www.codexxi.com -> Components. See some sample code for TASM.[/blue]
    :

  • : ok this is my prob... I dont understand assembly too much, but I want to. this is what i did to make my program output. to be honest, i have NO idea how to input data.
    [code]
    : ; hello world program
    : .MODEL small
    : .STACK 100h
    : .DATA
    :
    : message db 'hello world$'
    [red]
    : iMaxChars db 6
    : iChars db 0
    : strInput db 8 dup (0) [/red]
    :
    : .CODE
    : start:
    : mov ax, @data
    : mov ds, ax
    [red]
    mov dx, offset [iMaxChars]
    mov ah, 0Ah
    int 21h ; Input text will be in 'strInput'[/red]

    : mov ah, 9
    : mov dx, offset message
    : int 21h

    : mov ax, 4c00h ; exit sequence
    : int 21h
    :
    : end start
    [/code]
    :
    : instead of message db 'hello world$'
    : would i put
    : message db 0ah ; ??
    : not too sure on really what to do. I understand the process I need to do (as i showed VERY easily with c++) but I just dont know how to do it in assembly. thanks.
    :
    : : : [b][red]This message was edited by ii0oo0ooii at 2003-3-31 19:24:23[/red][/b][hr]
    : : : Well, simple to pros :)
    : : :
    : : : I am well versed in c++/java, but I am messing around with assembly. Just wondering, how to input an integer (16 bit, i am using MASM by the way...) and simply output the number i had inputted. I figured out how to output text (I took sippets from here and created a simple hello world program) but I cannot figure out how to take input and echo it out. thanks a lot.
    : : :
    : : : btw, LOL in C++ what i am doing is this:
    : : :
    : : : #include
    : : : void main(){
    : : : int c;
    : : : cin>>c;
    : : : cout<<c;
    : : : }//end main
    : : :
    : : :
    : : :
    : : [blue]You need to:
    : : 1. Input the text with digits (like "53739") using Function 0Ah from INT 21H
    : : 2. Convert this text into a WORD (16-bit) value, so you can perform calculations with it.
    : : 3. Convert it back from WORD value into string
    : : 4. Echo it using Function 9 from INT 21H.
    : :
    : : There are some conversion functions on my site: www.codexxi.com -> Components. See some sample code for TASM.[/blue]
    : :
    :
    :

  • ok cool. i got it to input (i guess) but how do you display it? BTW i have read through tutorials, etc. They seem like more beginner then i am (i dont know how :) ) or as if I know how to do what i am looking for anyway. I understand that the value inputted is in srtInput, but how do I display it. I tried using a similar method to how i outputted the message "hello world" but no go. also, how do I output a carrage return? i know in c++ its
    , but i dont know how to do it in java. If i knew how to output ascii chars, I would just output the ascii char for carrage return. thanks a lot ASM GURU you have been a great help.

    : : ok this is my prob... I dont understand assembly too much, but I want to. this is what i did to make my program output. to be honest, i have NO idea how to input data.
    : [code]
    : : ; hello world program
    : : .MODEL small
    : : .STACK 100h
    : : .DATA
    : :
    : : message db 'hello world$'
    : [red]
    : : iMaxChars db 6
    : : iChars db 0
    : : strInput db 8 dup (0) [/red]
    : :
    : : .CODE
    : : start:
    : : mov ax, @data
    : : mov ds, ax
    : [red]
    : mov dx, offset [iMaxChars]
    : mov ah, 0Ah
    : int 21h ; Input text will be in 'strInput'[/red]
    :
    : : mov ah, 9
    : : mov dx, offset message
    : : int 21h
    :
    : : mov ax, 4c00h ; exit sequence
    : : int 21h
    : :
    : : end start
    : [/code]
    : :
    : : instead of message db 'hello world$'
    : : would i put
    : : message db 0ah ; ??
    : : not too sure on really what to do. I understand the process I need to do (as i showed VERY easily with c++) but I just dont know how to do it in assembly. thanks.
    : :
    : : : : [b][red]This message was edited by ii0oo0ooii at 2003-3-31 19:24:23[/red][/b][hr]
    : : : : Well, simple to pros :)
    : : : :
    : : : : I am well versed in c++/java, but I am messing around with assembly. Just wondering, how to input an integer (16 bit, i am using MASM by the way...) and simply output the number i had inputted. I figured out how to output text (I took sippets from here and created a simple hello world program) but I cannot figure out how to take input and echo it out. thanks a lot.
    : : : :
    : : : : btw, LOL in C++ what i am doing is this:
    : : : :
    : : : : #include
    : : : : void main(){
    : : : : int c;
    : : : : cin>>c;
    : : : : cout<<c;
    : : : : }//end main
    : : : :
    : : : :
    : : : :
    : : : [blue]You need to:
    : : : 1. Input the text with digits (like "53739") using Function 0Ah from INT 21H
    : : : 2. Convert this text into a WORD (16-bit) value, so you can perform calculations with it.
    : : : 3. Convert it back from WORD value into string
    : : : 4. Echo it using Function 9 from INT 21H.
    : : :
    : : : There are some conversion functions on my site: www.codexxi.com -> Components. See some sample code for TASM.[/blue]
    : : :
    : :
    : :
    :
    :

  • [blue]To output a string store a '$' at the end and use Function 9 as you did before:[code]
    .DATA
    iMaxChars db 8
    iChars db 0 ; Here will be number of symbols entered
    strInput db 12 dup (0)
    strCRLF db 0Dh,0Ah,'$'

    .CODE

    ; --- Store a '$' at the end
    mov si, offset [strInput]
    mov al, iChars
    cbw
    add si, ax
    mov al, '$'
    mov [si], al

    ; --- Out!
    mov dx, offset [strInput]
    mov ah, 9
    int 21h

    ; --- Next line on console:
    mov dx, offset [strCRLF]
    mov ah, 9
    int 21h
    [/code]
    Hope it helps.
    [/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories