Thread: Assembly

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Rep Power

    Exclamation Assembly

    I need to make a programm in assembly (itīs better to use Emu8086) that
    recieves the STRING from the keyboard and than compress it in this way: input string--> aaabbcddd output string--> 3a2b1c3d.
    I know that it is very simple, but Iīm just a beginner and canīt make it. I have just one day till tomorrow afternoon. Hope Youīll help me. Thnks

    I have an exemple of a code here, but it doesnīt work

    .model small
    inputstr db 80 dup (' '),'$' ;uncompressed input string & read from keyboard
    outputstr db 80 dup (' '),'$' ;compressed output string & displayed
    start: mov ax,@data ;Prepare access to Data Segment
    mov ds,ax
    mov ah,0Ah ;DOS function "Read from file or device"
    mov bx,0 ;Standard input device (keyboard)
    mov cx,80 ;Maximum length of read input string
    mov dx,offset inputstr ;Memory address of read input string
    int 21h ;Call DOS function dispatcher
    sub ax,2 ;Decrement by 2 the actual input string length(EOL)
    mov si, offset inputstr
    mov di, offset outputstr
    L1: mov bx,si ;Check if we arrived the end of input string (While-type loop)
    sub bx,offset inputstr
    cmp bx,ax ;Compare with the length of read input string
    je L4 ;If so jump to finish
    mov cl,1 ;initialize the character counter
    L2: mov dl,[si] ;Read the character
    cmp dl,[si+1] ;Compare with the next character
    jne L3 ;If not equal jump to constructing output string
    inc cl ;If equal increment counter
    inc si ;And address of next character
    jmp L2 ;Repeat counting the current character
    L3: mov [di],dl ;Construct the compressed output string. Save character
    inc di
    add cl,'0' ;Simple single digit conversion to ASCII
    mov [di],cl ;Save the counter
    inc di ;Prepare for next character
    inc si ;
    jmp L1 ;Repeat for next character (End of While-type loop)
    L4: mov ah,09h ;DOS function "Write string to standard output"
    mov dx,offset outputstr ;Display decompressed output string
    int 21h ;Call DOS function dispatcher
    mov ah,4ch ;DOS function "Exit"
    int 21h ;Call DOS function dispatcher
    end start
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Alpharetta, GA
    Rep Power
    Which assembler are you using? There are literally dozens of assemblers for the x86 processors, each of which take a different syntax. From the code, I gather you are using Turbo Assembler, which is fairly widely used in coursework.

    The Language Resources thread has an extensive list of we sites for assembly, including some specifically about Turbo (and other common assemblers). A quick review of these may give you some information you could use.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short • Understanding the C/C++ Preprocessor
    Taming Python • A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Rep Power
    I Use o Emu8086. I have the book about it, but I just canīt find out whatīs wrong with this code. The program does not print the final result!!
    Thank you for answer.

IMN logo majestic logo threadwatch logo seochat tools logo