Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need help with 2 programs please

I need help with two programs...

1) File Listing program - Write a program that reads a text file into a buffer and displays the first 12 line of text. Write it directly to video memory. Provide the following Keyboard command functions:

Key - Function
PgUp - Scroll up 12 lines
PgDn - Scroll down 12 lines
UpArrow - Scroll up 1 line
DnArrow - Scroll down 1 line
Esc - Exit Program


2) Random File Creation program - Write a program that creates a random file containing student academic information, using data entered from the console. Each record is 27 bytes long, and approximately 20 records. The record format will look like:

Field......................Column
Student number..........1
Last name..................6
Course taken..............19
Number of credits........27
Grade........................28

Any hints, source codes, etc would be much appreciated

P.S. Anyone know if there's any "touch" utility program written in TASM that i can find (the source code)? Its like the program in DOS where you type in where you type in "dir *.exe" but it's "touch *.exe"? Just wondering

Thanks

Comments

  • PrzemekG_PrzemekG_ Posts: 595Member
    : I need help with two programs...
    :
    : 1) File Listing program - Write a program that reads a text file into a buffer and displays the first 12 line of text. Write it directly to video memory. Provide the following Keyboard command functions:
    :
    : Key - Function
    : PgUp - Scroll up 12 lines
    : PgDn - Scroll down 12 lines
    : UpArrow - Scroll up 1 line
    : DnArrow - Scroll down 1 line
    : Esc - Exit Program
    :
    :
    : 2) Random File Creation program - Write a program that creates a random file containing student academic information, using data entered from the console. Each record is 27 bytes long, and approximately 20 records. The record format will look like:
    :
    : Field......................Column
    : Student number..........1
    : Last name..................6
    : Course taken..............19
    : Number of credits........27
    : Grade........................28
    :
    : Any hints, source codes, etc would be much appreciated
    :
    : P.S. Anyone know if there's any "touch" utility program written in TASM that i can find (the source code)? Its like the program in DOS where you type in where you type in "dir *.exe" but it's "touch *.exe"? Just wondering
    :
    : Thanks
    :

    I can't help you too much but for the first program you should first the number of files you must list, the you allocate num_of_file * 12 / 16 (For the division you can use SHR), * 12 because a DOS app can read only short file names 8 for file name,3 for extension and 1 for '.' or a space. Actualy the '12' is one record size, you divide by 16 because DOS function 48h in int 21h allocates 16 bytes pages.
    When you have your buffer, you must fill it (in the way you wan, look at other DOS function, you will find there one that will help you ;-)).

    For direct write to screen, it's easy, the video text screen starts at 0B800h segmnet, to find a memory location of x and y you do
    [code]
    (maxx * y + x ) * 2
    [/code]
    Remember one character on the screen takes 2 bytes, first one for ASCII number and the other for the text atribute (the dos standart text attr is 7, gray on a black background). Starting address of an entry is entry_index * enrty_size, in this case entry_size is 12. So when you want to display an entry on the screen you pass the start seg:offset of that record.

    List:
    Lists are a bit dificult to make in assembler (I think you should make this entire program in a high level language and translate it then to assembler).
    Simple lists (that will fit on the screen) are easy but when you have 200 items you must scroll your list (which is too dificult to explayn).
    I can give you some tips.
    You must have few vars:
    1. rec_count - record count
    2. max_rec_screen - maximum number of items visible on the screen (it's a constant)
    3. sel_item - currently selected item
    4. first_item - first item visible on the top of the list

    Ok, so now how kays will work:
    KeyDown - Check if you are already on the buttom (if yes you can ignore or scroll up to the top), if no you add 1 to sel_item, if sel_item>max_rec_screen and sel_item-12>first_item the you must add 1 to first_item becose the selection wouldn't be visible. (refresh screen)

    KeyUp - Check if you are already on the top (if yes you can ignore or scroll down to the buttom), if no you substract 1 from sel_item, if sel_itemrec_count, it true you don't add 12 to sel_item but you set sel_item = rec_count. For page up you check if sel_item<12, it true then you sets sel_item to 0 not to sel_item-12 (which would be out of array bound)

    KeyEnd and KeyHome are easy and you should figure out how to use them.

    It is possible (even sure) I make some array bound errors, you must decide what will be the lowest bound, 1 or 0.
  • RickHallRickHall Posts: 4Member
    : I need help with two programs...
    :
    : 1) File Listing program - Write a program that reads a text file into a buffer and displays the first 12 line of text. Write it directly to video memory. Provide the following Keyboard command functions:
    :
    : Key - Function
    : PgUp - Scroll up 12 lines
    : PgDn - Scroll down 12 lines
    : UpArrow - Scroll up 1 line
    : DnArrow - Scroll down 1 line
    : Esc - Exit Program
    :
    :
    : 2) Random File Creation program - Write a program that creates a random file containing student academic information, using data entered from the console. Each record is 27 bytes long, and approximately 20 records. The record format will look like:
    :
    : Field......................Column
    : Student number..........1
    : Last name..................6
    : Course taken..............19
    : Number of credits........27
    : Grade........................28
    :
    : Any hints, source codes, etc would be much appreciated
    :
    : P.S. Anyone know if there's any "touch" utility program written in TASM that i can find (the source code)? Its like the program in DOS where you type in where you type in "dir *.exe" but it's "touch *.exe"? Just wondering
    :
    : Thanks
    :

    Check out ASM_0-m.zip and companion file in asm directory
    LOTS of source code for text viewing, and touch utility.

  • non0non0 Posts: 5Member
    : : I need help with two programs...
    : :
    : : 1) File Listing program - Write a program that reads a text file into a buffer and displays the first 12 line of text. Write it directly to video memory. Provide the following Keyboard command functions:
    : :
    : : Key - Function
    : : PgUp - Scroll up 12 lines
    : : PgDn - Scroll down 12 lines
    : : UpArrow - Scroll up 1 line
    : : DnArrow - Scroll down 1 line
    : : Esc - Exit Program
    : :
    : :
    : : 2) Random File Creation program - Write a program that creates a random file containing student academic information, using data entered from the console. Each record is 27 bytes long, and approximately 20 records. The record format will look like:
    : :
    : : Field......................Column
    : : Student number..........1
    : : Last name..................6
    : : Course taken..............19
    : : Number of credits........27
    : : Grade........................28
    : :
    : : Any hints, source codes, etc would be much appreciated
    : :
    : : P.S. Anyone know if there's any "touch" utility program written in TASM that i can find (the source code)? Its like the program in DOS where you type in where you type in "dir *.exe" but it's "touch *.exe"? Just wondering
    : :
    : : Thanks
    : :
    :
    : Check out ASM_0-m.zip and companion file in asm directory
    : LOTS of source code for text viewing, and touch utility.
    :
    :

    where can i find the link of

    [red]check out ASM_0-m.zip and companion file in asm directory
    LOTS of source code for text viewing, and touch utility.[/red]

    [hr][red][size=4]n[b][/b]n0[/size][/red]
    [blue][size=2][b]ASM[/b] programmer stuDz[/size][/blue]
    :-o [red] am in need of [b]HELP[/b]...[/red]:-o
    [hr]

Sign In or Register to comment.