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

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Piramid of chars - nasm


    Hi all,
    i have a problem with a program which is doing a pyramid of inputted chars.
    for exampled input is 'abc' and output is:
    ...a
    ..bbb
    ccccc

    I'm absolutely new to assembler and everything i have managed to do is:
    Code:
    org 100h
    mov ah,9
    mov dx, hello
    int 21h          ; display on screen
    mov ah, 0ah ;takes an char from keybord
    mov dx, string ; take data
    int 21h
    ; here should be some loop which i cant figure out
    mov ah,9
    mov dx, string+2 ; adress of imputted data
    mov ax, 4c00h; end of program
    int 21h
    hello db "imput an word $"
    string db 20 ;max amount of chars to be takend
    db 0; here we are getting list of chars which were taken
    times 22 db "$" ;space for data
    I don't know how to make this spaces before chars in these strings. I know only that this pyramid's top line should have n-1 (where n is string length) spaces before an char and every next one is (-1). But i don't know assembler's magic loops and i don't even know how to dismember string to chars here.
    of course i was googling for this but even if there were codes that could help me they are for fasm or other ide that i dont understand at all

    thanks in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    928
    Code examples aren't going to help you much at the moment. You will need a firmer understanding of assembler and memory first. If you have a text book, it would be helpful to work through the earlier problems and examples.

    You could also look at the various subproblems in your current assignment. For instance: Can you write out a string from memory? Can you write out a string from memory one character at a time? Can you write out a character N times? can you create a triangle of characters like:
    Code:
    X
    XX
    XXX
    ?

    When you need help with your code, it is useful to know what it is that you don't understand. Is the question how to construct a loop in assembler? Or is the problem with how to construct the condition?

    BTW, to get better search results, try including the keywords "x86" and "intel". There are different flavors of assembler for different chips and x86 assembler is often written in two distinct styles called Intel and AT&T syntax.
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

IMN logo majestic logo threadwatch logo seochat tools logo