Home > other >  Questions about the stack segment "assembly language"
Questions about the stack segment "assembly language"

Time:10-05

Some assembler answer is not defined inside the STACK SEGMENT
Answer inside were defined and some program
To search (the answer disappointing - & gt; Some say it's called int n need to define a stack segment, the problem is that some questions call int n but does not define a stack segment, so it didn't force)

Like this:
Programming to keyboard input of successive lowercase letters displayed in capital letters, separated by '-' space, lowercase letters when entering the program stop processing
Reference answer:
The STACK SEGMENT STACK; To define a stack segment
The DB 100 dup (?) ; Open up 100 storage unit
STACK ENDS; End of the stack segment

CODE SEGMENT. Definition of code
ASSUME CS: CODE, SS: STACK
START: MOV AH, 01 h; 1 call, a character from the keyboard input into AL
INT h; Input and echo
MOV BL, AL; Save the input from the keyboard characters
CMP AL, 'a'; Compared with "a" of the ASCII
JB L3. Under "a" ASCII, turn to the L3 (exit),
CMP AL, "z"; Compared with "z" ASCII
JA L3. Higher than that of "a" ASCII, turn to the L3 (exit),
SUB AL, 20 h; Will AL characters in the ASCII minus 20 h into capital letters,
MOV BL, AL; Save the results
MOV DL, '-'; According to characters' - 'send DL
MOV AH, 02 h; 2 call, displayed on the display characters' - ',
INT h; Show '-'
MOV DL, BL; Results (capital letters) to send DL,
MOV AH, 02 h; 2 call, displayed on the display the contents of the DL (capital letters),
INT h; According to the capital letters
MOV DL, 20 h; Space DL, ()
MOV AH, 02 h; 2 call, displayed on the display the contents of the DL (capital letters),
INT h; Display space (the two results separated by Spaces)
JMP START; Not "carriage return", turn the START (continue)
L3: MOV AH, 4 ch; "Carriage return", set to return to DOS function code,
INT h; Returns the DOS
CODE ENDS; End of the code
END the START; Programming and Cambodia


So what circumstances need to define the STACK SEGMENT

CodePudding user response:

I'm sorry, because try so hard, the indentation of the answers is not set well, sorry ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

CodePudding user response:

General small programs, no memory management requirements, do not need to set up the stack, because dos16 environment has a set, the default stack is in a program at the end of the 64 k section where you use the debug load without stack section of the program, see ss: sp points to know, small procedures, and no memory operation (release, reapply, etc.), this part of the memory will not be affected, so can be used to stack, if they set up a stack section, will be bigger, some example code yourself a bunch of push command, stack only to 16 bytes, is definitely bother; How much practical use, can run, how many stopped to look at before the end of the program stack is used,
  • Related