All About Circuits Forum  

Go Back   All About Circuits Forum > Electronics Forums > Homework Help


Homework Help Stuck on a textbook question or coursework? Cramming for a test and need help understanding something? Post your questions and attempts here and let others help.

Reply   Post New Thread
Thread Tools Display Modes
Old 03-28-2009, 12:30 PM
fortune2k fortune2k is offline
Junior Member
Join Date: Mar 2009
Posts: 19
Default Strings with nasm assembly 16bit

Hi i have to make a program to these specs:

So far in stdio.asm you have subroutines which enable you to output and input single characters, and input a word sized number in hex. However, it would be nice to be able to output and input a string of characters.

So write 2 new subroutines which you add to stdio.asm to the following specification:
GetString – inputs a string with echo (into a string in memory i.e. an array of char) from the keyboard until it encounters a cariage return character (note – not a line feed). This is because the <enter> key on the keyboard is encoded as a single carriage return character (not carriage return/linefeed). Thus you cannot look for linefeed as the input termination character.

The carriage return character you have found should not be stored with the rest of the string, it should be discarded. The input string should be placed in an array 256 bytes long. The start address of the destination character array should be passed as a parameter to the subroutine in DI. Very importantly you should ensure that the string of characters you have input is null terminated i.e. as in C put a byte value of 00H into the first byte after the end of the string. The subroutine should not corrupt any register values.

Remember to use the specialist string (array) instructions – although we are unable in this instance to use rep.

Also note that you can use the subroutine Getch that you wrote last week to input individual characters (it should be in stdio.asm).

PutString – outputs to the console window the contents of a character array. The address of the start of the array should be passed to the subroutine in SI. The subroutine assumes that the string is null terminated. You can use the subroutine Putch that you wrote last week to output the individual characters.

c) Write some code in a separate program to test your subroutines. NOTE – PutString like PutHex does NOT output a newline so you will need to do this yourself if you want to put it on separate lines.

i have read all the material which has been given to us in class but i have no idea how to start and approach this any thing you guys can recommended to research?

I am guessing i would have to use some sort of loop with a counter and an array to store the word which has been input from keyboard an array of characters. When printing the out the string to screen you would use a loop again printing out each character in order.

do i have the right idea of how to do this or am i well off here if so can you offer some guidance please.

Reply With Quote
Old 03-28-2009, 06:08 PM
thatoneguy's Avatar
thatoneguy thatoneguy is offline
Senior Member
Join Date: Feb 2009
Location: Midwest USA
Posts: 6,356
Blog Entries: 4

Allocate memory for the string.

Loop through getc waiting for a keypress. When a character key is pressed, check value for valid character, add to memory, increment pointer. When ENTER is pressed, terminate string with NUL.

To write it back to screen, start at first memory area, get character, print, advance pointer one, test for NUL, if not null, print, repeat until NUL is found in string or variable's memory end is reached.
Reply With Quote
Old 03-28-2009, 06:43 PM
fortune2k fortune2k is offline
Junior Member
Join Date: Mar 2009
Posts: 19

okky i have done some research and i understand how to do it now but how do i define the array i have looked everywhere i need like a named array . This is all similar to how C works with strings just an array of characters im after something like this


array [256] ; define arry 256 bytes

read char
display char
MOV array[CX] , AL ; moves the value of AL to the array
Reply With Quote
Old 03-28-2009, 08:29 PM
fortune2k fortune2k is offline
Junior Member
Join Date: Mar 2009
Posts: 19

hey i found this but not sure if its right
'MyArray times 256 db 0 ' ... i want to store characters in the array

and then i want to be able to do somthing like 'MOV myarray[CX],DL' soo i can move the char from DL to a part of the array

Last edited by fortune2k; 03-28-2009 at 08:42 PM.
Reply With Quote
Reply   Post New Thread

, , ,

Related Site Pages
Section Title
Textbook Quirks : Using The spice Circuit Simulation Program

Similar Threads
Thread Thread Starter Forum Replies Last Post
&& (and) fuction in assembly language BANnY Embedded Systems and Microcontrollers 3 12-16-2008 03:46 PM
Assembly Problem maple23 Programmer's Corner 1 04-23-2008 11:56 PM
Assembly Language Question hhedayati Programmer's Corner 7 10-21-2007 01:08 AM
Assembly Program For Transmitting And Receiving A Message Using Ms-dos Debug Diana Programmer's Corner 5 06-22-2007 04:09 AM
assembly language chino22 Programmer's Corner 1 11-02-2006 03:53 AM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 05:19 PM.

User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.