Sei sulla pagina 1di 4

an accumulator is a register in which intermediate arithmetic and logic results are stored.

Without a register like an accumulator, it would be necessary to write the result of each calculation (addition, multiplication, shift, etc.) to main memory, perhaps only to be read right back again for use in the next operation. Access to main memory is slower than access to a register like the accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register. *******************

int 21h means, call the interrupt handler 0x21 which is the DOS Function dispatcher. the "mov ah,01h" is seeting AH with 0x01, which is the Keyboard Input with Echo handler in the interrupt

INT 21,1 - Keyboard Input with Echo


AH = 01 on return: AL = character from standard input device - waits for keyboard input from STDIN and echoes to STDOUT - returns 0 for extended keystroke, then function must be called again to return scan code - if ~Ctrl-Break~ is detected, ~INT 23~ is executed

***********************

Laptop shows These materials are somewhat close to what was shown in class via the laptop. These are insufficient as they are. Your in class notes must be added to these pages to understand what is going on. These also include any corrections made in class that I could remember. Since these are used in class to show that some things don't work, make sure you have gone through your class notes as you read these so which things here are negative examples or errors. Also, there may simply be errors here. If you think you've found one, email me.

The format of these materials may not be what should be used in your code as I have little control over how some things align here.

Interrupts for I/O (DOS level) These are subroutines in low RAM, loaded at boot DOS or BIOS routines INTs automatically push onto the stack information that will be needed to return from the interrupt. It automatically save FLAGs, CS, IP, and clears the interrupt and trap flags. IRET is used in the subroutine (an interrupt subroutine) for return - the. reverse of the above occurs. INT 21h DOS services AH must hold the function (service) number. (That means you must put it there before the INT 21h happens.)
INT 21h, function 1 single character input from keyboard with wait and automatic echo input: AH: 1 output: AL: character typed (ASCII value) if plain character or if AL is zero, we got an extended key and must issue INT 21h, func. 1 again to get the scan code (more on this later) (the character is automatically echoed to the screen by the system so we don't write it back) INT 21h, function 2 single character output to monitor input: AH: 2 DL: character to display (ASCII value) output: none INT 21h, function 9 print 'valid' string ('$' terminated) (not ASCIIZ string 0 terminated) input: AH: 9 DX: address (offset) of valid string in memory output: none CR LF QMRK .data PRMPT uchr .code . . . EQU 0Dh EQU 0Ah EQU '?' ; carriage return ; line feed, need both for DOS new line

DB 'ENTER: $' DB ? ; write mov AH, mov DL, int 21h ; get a mov AH, int 21h the question mark on the screen 2 QMRK character input from keyboard 1

mov uchar, AL ; move screen to next line mov AH, 2 mov DL, CR int 21h mov DL, LF int 21h ; let's write the character we got back twice mov DL, uchar int 21h int 21h mov DL, CR int 21h mov DL, LF int 21h

What's output?
mov mov int mov lea int DL, AH, 21h AH, DX, 21h 65 2 9 PRMPT

What about printing digits?


mov mov int mov int mov int mov int AH, AL, 21h AL, 21h AL, 21h AL, 21h 2 30h 31h 32h 33h ; same as '0' ; same as '1' ; same as '2' ; same as '3'

Hmm, is there a better way? (Does anyone see a pattern?) Consider bit patterns for the number 0 and the digit '0' Consider bit patterns for the number 1 and the digit '1' Consider bit patterns for the number 2 and the digit '2' Consider bit patterns for the number 3 and the digit '3' Hmm, how about case conversion. Consider bit patterns for the number 'A' and the number 'a' Consider bit patterns for the number 'B' and the number 'b' (yes, they're numbers) (positions in the ASCII table) Hmm case conversion is bit-fiddling! >>>>>NOTE that this became a part of an assignment to figure out

We didn't actually do this table or the functions below in class. It's easily understood (from the pattern showed in class about what "input:" and "output:" and "FLAGs:" mean and it's in the book.
DOS INT 21, 01h function: Wait for kbd hit? Yes Echo? Yes Ctrl Break Yes handled? 06H No No No 07H Yes No No 08H Yes No Yes

INT 21h, function 06h input without wait for keyboard input: AH: 06h DL: 0FFh output: AL: character to display (ASCII value) FLAGs: ZF is used to determine if a character was in the keyboard buffer. 0 char. found, 1 no char. found INT 21h, function 0Bh get keyboard buffer status input: AH: 0Bh output: AL: FFh if there is character waiting, 00 otherwise This means we can check for a keyboard hit before reading it from the buffer.

Potrebbero piacerti anche