hi all ! I'm newbie and hope below questions can be answered. thanks
%TITLE "Send printer form feed command -- by Tom Swan"
IDEAL
MODEL Small
STACK 256
;--------- Equates
ASCIIcr EQU 13 ;Ascii carriage return
ASCIIff EQU 12 ;Ascii form feed control code
CODESEG
Start:
mov ax, @data ;Initialize DS to address
mov ds, ax ; of data segment
mov dl, ASCIIcr ;Assign cr code to dl
mov ah, 05h ;Dos Function: Printer output
int 21h ;Call Dos -- carrige return
mov dl, ASCIIff ;Assign ff code to dl
mov ah, 05h ;Dos Function: Printer output
int 21h ;Call Dos -- form feed
Exit:
mov ax, 04C00h ;Dos Function: Exit Program
int 21h ;Call Dos. Terminate program
END Start ;End of program / entry point
This is a sample listing of the book "Mastering Turbo Assembler" and my questions are :-
1) whats the meaning of @data ?
2) why the ASCII code was assigned to dl and not dh ?
3) when dos function 05h was assigned to ah why the value of dx changed to 000D (this was examined in Turbo Debugger) ?
thanks
YM
1) @data is a pre-defined symbol for the segment address of the data segment. For a .EXE program the system has no way of knowing what the segment address of the data segment is, so it sets DS (and ES) to the segment address of the Program Segment Prefix, a 256-byte data structure that precedes the program in memory. It's up to the program to load the segment address of the data segment into DS.
2) Interrupt 21h Function 05h expects the ASCII value of the character to print in DL. For information on the DOS interrupts see Ralf Brown's Interrupt list.
An HTML version is here:
http://www.ctyme.com/rbrown.htm
And the download version here:
http://www-2.cs.cmu.edu/~ralf/files.html
3) The decimal value 13 is 0D in hexadecimal.
Pls help me to answer below questions. thanks
%TITLE "Mov demo -- by Tom Swan
IDEAL
MODEL small
STACK 256
DATASEG
exCode DB 0
speed DB 99 ;One - byte variable
CODESEG
Start:
mov ax, @data ;Initialize DS to
mov ds, ax ;of data segment
mov ax, 1 ;Move immediate data into reg
mov bx, 2
mov cx, 3
mov dx, 4
mov ah, [speed] ;Load value of speed into al
mov si, offset speed ;Load address of speed into al
Exit:
mov ah, 04Ch ;Dos Function : Exit Program
mov al, [exCode] ;Return exit code value
int 21h ;Call Dos. Terminate program
END Start ;End of program / entry point
1) In this statement, "mov ah, [speed]" why ah should be used and not al ?
2) what is the relationship of si and ax in this statement " mov si, offset speed" ?
YM
1) Either would be legal, and there is nothing in the code to indicate that one should be selected over the other.
2) There is no relationship between AX and SI that I can see, beyond them both being 16-bit registers.
mov ah, [speed] ;Load value of speed into al
mov si, offset speed ;Load address of speed into al
It appears to me that the registers are being set up to read the location at [SI]
into the AL register with a LODSB instruction.
You have to show us the rest of the code - this is only a piece of it.