flat assembler
Message board for the users of flat assembler.

Index > Windows > need help..Emu > FASM

Author
Thread Post new topic Reply to topic
vicky



Joined: 22 Dec 2010
Posts: 9
vicky 22 Dec 2010, 21:15
Hi everyone, i'm newbie here Wink
We learnt in the course microprocessors only Emu and now the inductor wants code in Fasm, and i learnt it only today Sad Tomorrow is the last day of the homework. And i've got the code in Emu. So anyone can help me about that? Pls pls pls Crying or Very sad

This is a program which takes a string from user and writes it on the screen char by char. So it's not so hard. I found how to write it on the screen but don't know how to take string from user.

Here is my Emu code:

Code:


org  100h


print_new_line macro
    mov dl, 13
    mov ah, 2
    int 21h   
    mov dl, 10
    mov ah, 2
    int 21h      
endm


    mov dx, offset msg1
    mov ah, 9
    int 21h
    ; input the string:
    mov dx, offset s1
    mov ah, 0ah
    int 21h
    
    ; get actual string size:
    xor cx, cx
    mov cl, s1[1]
    print_new_line
                  
    mov bx, offset s1[2]
print_char:
    mov dl, [bx]
    mov ah, 2
    int 21h      
    print_new_line   
    inc bx
    loop print_char


    ; wait for any key...
    mov ax, 0 
    int 16h
    
    ret


msg1    db  "ENTER THE STRING: $"
s1      db 100,?, 100 dup(' ') 


end
     
Post 22 Dec 2010, 21:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 23 Dec 2010, 00:25
Did you want this in the DOS section?
Post 23 Dec 2010, 00:25
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 23 Dec 2010, 03:31
Copy-n-Paste from web, but it looks like it'd work. Very Happy
Code:
; Input:
;
; DS:SI = offset to input buffer
; (first byte specifies size)
;
Input:
    mov ah, 01h         ; Select DOS "Input with echo" function
    mov cl, [ di ]      ; Grab size of buffer into CL (max size)
    mov ch, cl          ; Copy into CH (current count)
    inc di              ; Advance to start of actual buffer
NextChar:
    int 21h             ; Input character from "stdin"
    cmp al, 0Dh         ; Is it ENTER?
    je EndOfInput       ; Yes, then terminate early
    cmp al, 08h         ; Is it backspace?
    jne CarryOn         ; No, then skip over backspace processing

    cmp ch, cl          ; Are we at the start of the buffer?
    je NextChar         ; Yes, ignore backspace as we can't go back
                        ; before the beginning of the buffer
    dec di              ; Move back a character in the buffer
    inc ch              ; Increment count back up
    mov ah, 02h         ; Select DOS "display output"
    mov dl, 20h         ; A space to clear old character
    int 21h             ; Print it!
    mov dl, 08h         ; A backspace character moves left
                        ; (non-destructive)
    int 21h             ; Print it!
    mov ah, 01h         ; Restore DOS "input with echo" function
    jmp NextChar        ; Jump to get next character

CarryOn:
    mov [ di ], al      ; Store input into buffer
    inc di              ; Advance to next character in buffer
    dec ch              ; Decrement count of characters
    jnz NextChar        ; While there's still room in buffer,
                        ; do it all again
EndOfInput:
    ret    
Test it out and let us know.
(Merry Christmas, to you and your instructor.)
Post 23 Dec 2010, 03:31
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 23 Dec 2010, 14:45
vicky wrote:
Thanks a lot for your copy'n paste code Smile But it didn't work. It didn't give any error too. Should i insert sth in it?
I'll tell your wishes to instructor with my wishes, don't worry Laughing
It is difficult to assist without seeing your progress. You'll need to CALL the function correctly. Set DS:SI to the address of your input buffer - the first byte of which must be set to the number of input bytes allowed. Something like:
Code:
lds si,[iBuffer]
call Input
.
.
.
iBuffer db 42,42 dup ?    
...and then you'll need to correctly respond to the result return by the function. CL - CH should be the number of input characters to be processed by your output function.
Post 23 Dec 2010, 14:45
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.