English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Code

dosseg
.model small
.stack
.data
.code

main proc
mov ax, @data
mov ds, ax
mov cx, 7

mov dl, 41h

next_char: mov ah, 02h
int 21h
inc dl
loop next_char

Exit: mov ax, 4c00h
int 21h

main endp
end main




Pls explain each line....comment it... Thanx

2006-11-16 01:21:55 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

Here is line by line code with comments:

dosseg - Declare DOS segment
.model small - Declare as Small memory model
.stack - Declare Stack segment
.data - Declare Data segment
.code - Declare Code segment

(All the above are called Assembler Directives for Microsoft Macro Assembler or MASM)

main proc - Main program begins
mov ax, @data - Move Data segment address to AX
mov ds, ax - Set data segment address to DS
mov cx, 7 - Move 7 to CX(Loop counter)

mov dl, 41h - Move 41H(the alphabet "A")

next_char: mov ah, 02h - Move 02H to AH(Indicate you want to write to standard output)
int 21h - Call DOS Interrrupt 21H to write to standard output the character in DL
inc dl - Increment DL(the character in DL is now B/C/D/E/F/G for each interation.
loop next_char - Loop 7 times(as many times as CX)

Exit: mov ax, 4c00h - Move 4CH to AH and 00 to AL which indicates "Terminate program and return the code in AL" which is 00
int 21h - Invoke DOS interrupt to terminate the program.

main endp - End of code segment.
end main - Main program ends.

Finally the output of the program is "ABCDEFG".

Yes this is an Intel processor assembly language.

2006-11-16 01:41:55 · answer #1 · answered by Joe Simon 1 · 1 0

ABCDEFG

too easy!!!!

mov dl, 41h ;move A in dl

;display the cahracter using interupt 21h
next_char: mov ah, 02h
int 21h
inc dl ;increment dl
loop next_char ;repeat it 7 times

2006-11-16 01:29:18 · answer #2 · answered by joker 2 · 0 0

this relies upon heavily on the compiler used, as this good judgment may be diverse finding on the compiler. yet many times conversing, that's the way it works. the %d parameter ability to demonstrate a variety in decimal format This calls the printf approach and tells it to demonstrate 4 decimal numbers, as descibed after the comma. z++ will return Z (0) and then decrement by utilising a million --z will decrement by utilising a million and return Z (0) ++z will increment by utilising a million and return Z (a million) z-- will return Z (a million) and decrement by utilising a million ending fee of Z is 0 displayed is "0 0 a million a million" in spite of the undeniable fact that, C++ spec states that order of argument assessment isn't guarenteed.. so... :)

2016-10-15 15:14:25 · answer #3 · answered by score 4 · 0 0

fedest.com, questions and answers