direct video practice and keyboard operations. midterm avg: 182/195 (93%)
TRANSCRIPT
![Page 1: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/1.jpg)
Direct video practice and Keyboard Operations
![Page 2: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/2.jpg)
Midterm
Avg: 182/195 (93%)
Midterm
165
170
175
180
185
190
195
0 5 10 15 20
Series1
![Page 3: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/3.jpg)
Midterm
1.1. For the data bits 01001001, the parity bit is
(a) 0 (b) 1
(c) irrelevant (d) unknown
![Page 4: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/4.jpg)
Midterm
1.2. The data segment contains (a) read-only memory, (b) the machine instructions that are to execute, (c) a program's defined data, constants, and work areas, (d) values that a program needs to save temporarily.
![Page 5: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/5.jpg)
Midterm
1.3. The binary representation for decimal 117 is
a. 01110101 c. 01111011
b. 01110011 d. 01100101
![Page 6: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/6.jpg)
Midterm
1.5 Which of the following is an invalid name?
a. _hello b. #hello
c. $hello d. hello
![Page 7: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/7.jpg)
Midterm
1.6. Which one of the following statements is invalid?
(a) MOV AL,035AH (b) MOV CX,035AH
(c) MOV AX,035AH (d) MOV DI,035AH
![Page 8: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/8.jpg)
Midterm
1.7. INT 21H function 09H for displaying requires defining a display string in the data area, immediately followed by this character:
(a) @ (b) &
(c) $ (d) _
![Page 9: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/9.jpg)
Midterm
1.8 Given DATSG is the name of the data segment. The instruction MOV DS,DATSG is a correct instruction to initialize the address of the data segment in the DS register.
a. True
b. False
![Page 10: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/10.jpg)
Midterm
1.9 Identify the following colors in the attribute byte 00000001:
(a) Blue foreground and black background
(b) Blue foreground and white background
(c) White foreground and blue background
(d) Black foreground and blue background
![Page 11: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/11.jpg)
Midterm
1.10 In what significant way do the following MOV instructions differ in execution MOV DX,AC24HMOV DX,[AC24]H
a. The first MOV moves immediate value AC24H to DX while the second MOV moves AC24H to location specified by DS:DX
b. The first MOV moves immediate value AC24H to DX while the second MOV moves the contents of locations AC24H and AC25H to DX.
c. The first MOV moves immediate value AC24H to location specified by DS:DX while the second MOV moves the content of locations AC24H and AC25H to DX
d. The first MOV moves immediate value AC24H to DX while the second MOV moves the content of locations AC24H to DX.
![Page 12: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/12.jpg)
Midterm
1. The _code____ segment contains the machine instructions that are to execute. The _data____ segment contains a program's defined data, constants, and work areas. The _stack_____ contains any data and addresses that you need to save temporarily.
2. The _IP__ register contains the offset address of the instruction that is to execute next and is associated with the _CS__ register that addresses the code segment.
![Page 13: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/13.jpg)
Midterm
3. The LOOP instruction requires an initial value in the _CX__ register. For each iteration, LOOP deducts 1 from this value; if it is __zero____, control drops through to the following instruction, and if it is __non zero_____, control jumps to the operand address.
4. For INT 21H function 0AH, the area for keyboard input requires definition of a _parameter list__. The first byte contains maximum number of character entered_. The second byte is for the operation to store the _actual number of character entered___. The third byte begins a field that is to contain _entered characters______________________.
![Page 14: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/14.jpg)
Midterm
5. A RET instruction that returns from a near procedure pops the original value from the stack into the IP___ register and increments the _SP__ register by 2.
6. For screen clearing or scrolling, use BIOS INT _10H__ and insert function _06H__ in AH
![Page 15: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/15.jpg)
Midterm
7. The first byte of an instruction is the _operation_; the other bytes are _operands__, which reference an immediate value, register, or memory location.
8. On loading an .EXE program into memory for execution, the loader stores the address of the PSP in the _DS___ and _ES___ registers, the address of the stack in the __SS__ register, and the size of the stack in the ___SP_ register.
![Page 16: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/16.jpg)
Midterm
9. The BIOS Data Area begins in low memory at segment address __40[0] H______
10. The statement DB 0 defines one _byte___ initialized with a _zero___ value.
![Page 17: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/17.jpg)
Midterm
III. 1.a. SS: 2A600H
+ 100H2A700H -> SS: 2A70H
b. CS: 2A600H+ 100H 30H 40H 2A770H -> CS: 2A77H
![Page 18: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/18.jpg)
Midterm
III. 1.
c. ES: 2A60H
d. SP: 0030H
![Page 19: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/19.jpg)
Midterm
III. 2
a.
b. 3412H + 011AH = 352CH
BH BL
34H 12H
BH BL
35H 2CH
![Page 20: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/20.jpg)
Midterm
III. 2
c.2CH 35H
0134 0135
![Page 21: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/21.jpg)
Midterm
3.WORD3: 10*30 = 300
4. CX = 5 AX = 10CX = 4 AX = 20CX = 3 AX = 30CX = 2 AX = 40CX = 1 AX = 50
![Page 22: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/22.jpg)
Direct Video Display
Fastest way to display text or graphic characters is to transfer them directly to video display area
The address of page 0 for mode 3 is B800[0]H. Each character require two bytes (one for representing the character itself and one for its attribute)
Moving a pair of character:attribute into video area of the active page will cause the character appear immediately on screen
![Page 23: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/23.jpg)
Direct Video Display
80 columns (0-79)25 rows (0-24)
Hint: Similar to the use one dimension array to represent this area. Each element put in this area takes 2 bytes. We start this array from 0Example:
ES:[00] = 48H ES:[01] = 1FH
(0,0)
MOV ES:[00], 48H MOV ES:[01], 1FH
![Page 24: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/24.jpg)
Direct Video Display
ES:[78] = 48HES:[79] = 0FH
ES:[160] = 48HES:[161] = 0FHES:[238] = 48HES:[239] = 0FH
(0,39)
MOV ES:[78], 48HMOV ES:[79], 0FH
(1,0) (1,39)
MOV ES:[160], 48HMOV ES:[161], 0FHMOV ES:[238], 48HMOV ES:[239], 0FH
![Page 25: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/25.jpg)
Example of direct video display
MOV AX, 0B800h MOV ES, AX
; print message using ES; as segment:
MOV ES:[00h], 48h ;H MOV ES:[02H], 45h ;E MOV ES:[04H], 4ch ;L MOV ES:[06H], 4ch ;L MOV ES:[08H], 4fh ;O
![Page 26: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/26.jpg)
Example of direct video display
![Page 27: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/27.jpg)
Example of direct video display
MOV AX, 0B800HMOV ES, AX
MOV AX, 0003H ; Set the current video mode to text mode INT 10H ; INT 10H, function 00H (mode=03H is standard text)
MOV AX, 0500H ; Set the active page = 00INT 10H CALL DISPLAY
![Page 28: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/28.jpg)
Example of direct video display
DISPLAY PROC NEAR mov cx,25 ;vertical line mov di,0again1:
mov es:[di],48hmov es:[di+1],4ehadd di,80loop again1
DISPLAY ENDP
![Page 29: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/29.jpg)
Direct Video Display
![Page 30: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/30.jpg)
Direct video display Practice
1. Open your browser and open this page:C:\emu8086\documentation\
8086_instruction_set.htmlAndC:\emu8086\documentation\
8086_and_dos_interrupts.html2. Open your emu8086 software3. Cut and paste (or type) the following code
(as shown in the next page) and save as directvideo.asm
![Page 31: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/31.jpg)
page 60,132TITLE VideoPractice DirectDisplay; ---------------------------------------------STACK SEGMENT PARA STACK 'Stack'
DW 32 DUP(0)STACK ENDS; ----------------------------------------------DATASEG SEGMENT PARA 'Data'; Please insert your data declaration here DATASEG ENDS
CODESEG SEGMENT PARA 'Code'
MAIN PROC FAR MOV AX, 0B800H MOV ES, AX ; Please enter your code here MOV AX,4C00H ;exit procedure INT 21HMAIN ENDP
CODESEG ENDS
END MAIN ;End of program
![Page 32: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/32.jpg)
Direct video display Practice
4. Modify your code so that it performs the following tasks:
Draw horizontal line (40 character E) on the screen using direct video display
5. Compile and run your code. It should look something like:
![Page 33: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/33.jpg)
Coding
MOV AX, 0B800h MOV ES, AX
mov cx,40 ;horizontal line mov di,0again2: mov es:[di],45h mov es:[di+1],5eh add di,2loop again2
![Page 34: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/34.jpg)
Lesson plan
Brief go over keyboard operations Focus on String operation
![Page 35: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/35.jpg)
Keyboard Operations
Keyboard provides three basic types of keys:– Standard characters: A-Z, a-z,0-9,%,$,#.– Extended function key:
Function keys: F1,F2..Shift-F1.. Numeric keypad keys: Home,End, Arrows, Page Up,
Page Down.
– Special keys Alt, Ctrl, and Shift
![Page 36: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/36.jpg)
INT 21H Functions
Direct keyboard input no echo:
if there is no character in the keyboard buffer, the function waits until any key is pressed.
Example:
example:
MOV AH, 7
INT 21H
![Page 37: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/37.jpg)
INT 21HFunction 0BH: Check Keyboard status:
Return FFH in AL if an input character is available in the keyboard buffer and
Return 00H if no character is availableMOV AH, 7
INT 21H MOV AH, 0BH INT 21H CMP AL, 00H JE PRINTLABEL JMP CONT
PRINTLABEL:…………..
CONT:……
![Page 38: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/38.jpg)
INT 21H
Function 0Ch - flush keyboard buffer and read standard input.Example:
MOV AH, 0CH
MOV AL, 07H
INT 21H
![Page 39: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/39.jpg)
Keyboard buffer
BIOS Data Area starts at 40:1EH INT 09H is automatically executed when you
press a key. This interrupt points to an interrupt-handling routines in ROM BIOS.
The BIOS routine reads the scan code and compares it with entries in a scan code table for the associate ASCII character
![Page 40: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/40.jpg)
BIOS INT 09H and the keyboard buffer
When we press a key, the keyboard processor automatically generates its scan code and issue INT 09H
When we release the key with one-half second, it generates a second scan code to tell the interrupt routine that you have released the key.
![Page 41: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/41.jpg)
Address
41AH: current head of the buffer, the next position for INT 16H is to get a character entered from the keyboard
41CH: current tail of the buffer. The next position for INT 09H to store a character entered from the keyboard
41EH: beginning of the keyboard buffer itself.
![Page 42: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/42.jpg)
INT 16H operations for keyboard
INT 16H is the basic BIOS keyboard operation used extensively by software developers
![Page 43: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/43.jpg)
INT 16H operations for keyboard
INT 16h / AH = 00h - get keystroke from keyboard (no echo).return:AH = BIOS scan code.AL = ASCII character.
MOV AH, 00H
INT 16H
![Page 44: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/44.jpg)
Example
MOV AH, 00HINT 16H
CMP AL,'c'JE PRINTPROMPTJMP CONT
PRINTPROMPT:………
CONT:
![Page 45: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/45.jpg)
INT 16H
INT 16h / AH = 01h - check for keystroke in the keyboard buffer.
return:ZF = 1 if keystroke is not available.ZF = 0 if keystroke available.AH = BIOS scan code.AL = ASCII character.(if a keystroke is present, it is not removed from the keyboard buffer).
![Page 46: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/46.jpg)
String operations
![Page 47: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/47.jpg)
Processing String Data
Two ways to code string instructions
1. Address of Operands are implied
E.g: MOVS BYTE1, BYTE2
Need to have:
BYTE1 is stored at ES:DI
BYTE2 is stored at ES:SI
![Page 48: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/48.jpg)
Processing String Data
Two ways to code string instructions
2. Move the addresses of operands in DI and SI and use the instruction without OPERANDS
E.g:
LEA DI, BYTE2; BYTE2 at ES:DI
LEA SI, BYTE1; BYTE1 at DS:SI
MOVSB ; MOVE BYTE2 to BYTE1
![Page 49: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/49.jpg)
String operations
Don’t forget to initialize the DS and ES by:– MOV AX, DATASEG– MOV DS, AX– MOV ES, AX
![Page 50: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/50.jpg)
MOVSB
Copy byte at DS:[SI] to ES:[DI]. Update SI and DI.
if DF = 0 then – SI = SI + 1 – DI = DI + 1
else – SI = SI - 1 – DI = DI - 1
![Page 51: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/51.jpg)
MOVSB
Example:a1 DB 5 DUP('&')
a2 DB 5 DUP(' ')
LEA SI, a1
LEA DI, a2
MOV CX, 5
REP MOVSB
![Page 52: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/52.jpg)
Repeat String Prefix (REP)
Repeat following MOVSB, MOVSW, LODSB, LODSW, STOSB, STOSW instructions CX times.
check_cx:
if CX <> 0 then do following chain instruction
Decrease CX = CX - 1 go back to check_cx else exit
![Page 53: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/53.jpg)
MOVSW
Copy word at DS:[SI] to ES:[DI]. Update SI and DI.
ES:[DI] = DS:[SI]
if DF = 0 then – SI = SI + 2 – DI = DI + 2
else – SI = SI - 2 – DI = DI - 2
![Page 54: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/54.jpg)
Example
a1 DW 5 DUP('&')
a2 DW 5 DUP(' ')
LEA SI, a1
LEA DI, a2
MOV CX, 5
REP MOVSW
![Page 55: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/55.jpg)
LODSB
Load byte at DS:[SI] into AL. Update SI.
AL = DS:[SI]
if DF = 0 then SI = SI + 1
else SI = SI - 1
![Page 56: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/56.jpg)
Example
String reverse
SRC_STR DB 'NEWYORK'DES_STR DB 7 DUP (' ')
LEA SI, SRC_STR
LEA DI, DES_STR+6 MOV CX, 7 L10: LODSB MOV [DI], AL DEC DI LOOP L10
![Page 57: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/57.jpg)
STOB
Store byte in AL into ES:[DI]. Update DI.
Algorithm:
ES:[DI] = AL
if DF = 0 then – DI = DI + 1
else – DI = DI - 1
![Page 58: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/58.jpg)
Example
LEA DI, a1
MOV AL, 12h
MOV CX, 5
REP STOSB
![Page 59: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/59.jpg)
COMPSB
Compare bytes: ES:[DI] from DS:[SI].
DS:[SI] - ES:[DI]
set flags according to result:OF, SF, ZF, AF, PF, CF
if DF = 0 then – SI = SI + 1 – DI = DI + 1
else– SI = SI - 1 – DI = DI - 1
![Page 60: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/60.jpg)
Lab/Practice
1. Open your browser and open this page:
C:\emu8086\documentation\8086_instruction_set.html
And
C:\emu8086\documentation\8086_and_dos_interrupts.html
2. Open your emu8086 software
3. Cut and paste (or type) the following code (as shown in the next page) and save reverse.asm
![Page 61: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/61.jpg)
page 60,132TITLE StringPractice StringReverse; ---------------------------------------------STACK SEGMENT PARA STACK 'Stack'
DW 32 DUP(0)STACK ENDS; ----------------------------------------------DATASEG SEGMENT PARA 'Data'; Please insert your data declaration hereDATASEG ENDS
CODESEG SEGMENT PARA 'Code'MAIN PROC FAR MOV AX, DATASEG MOV DS, AX MOV ES, AX ; Please enter your code here MOV AX,4C00H ;exit procedure INT 21HMAIN ENDPCODESEG ENDSEND MAIN ;End of program
![Page 62: Direct video practice and Keyboard Operations. Midterm Avg: 182/195 (93%)](https://reader035.vdocument.in/reader035/viewer/2022062515/56649d005503460f949d2db7/html5/thumbnails/62.jpg)
Lab/Practice
4. Insert the code to:
- Read a string from keyboard (INT 21H, 0AH). Max typed characters = 50
- Reverse that string using the string operations learned today. (see code for reversing a string)
5. Compile and run the code