cosc 456 lesson 8 cool codes add al,sial al + si add al,[si]al al + [si] inc bxbx bx + 1 inc...
TRANSCRIPT
![Page 1: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/1.jpg)
COSC 456Lesson 8
![Page 2: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/2.jpg)
Cool Codes
• ADD AL,SI AL AL + SI• ADD AL,[SI] AL AL + [SI]
• INC BX BX BX + 1
• INC [BX] Ambiguity error
• INC BYTE PTR [BX] [BX] [BX] + 1
• INC WORD PTR [BX][BX + 1 : BX ] [BX + 1 : BX ] + 1
![Page 3: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/3.jpg)
MUL & DIV
• MUL CL CL x AL AX
• MUL BX BX x AX DX : AX
• DIV CL AX/CL calculated. Quotient in AL and remainder in AH
• DIV CX DX:AX/CX calculated. Quotient in AX and remainder in DX
![Page 4: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/4.jpg)
Shift
SHRShift Logical Right
0 MSB LSB CF
SALShift Arithmetic Left
0 MSB LSB CF
• Shift CL times!• SHR BX,CL• SAL BX,1• SAL AL,CL
![Page 5: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/5.jpg)
XCHG & XLAT
• XCHG AX, BX• XCHG BL, [SI + 2]
• XLAT
Translate. Inherent instruction does not require operand specification. This instruction uses AL and BX in the following way:
AL [BX + AL ]
This instruction finds applications in data translation tables, look-up tables, and code conversions.
![Page 6: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/6.jpg)
Adder Program
MOV CX, 7MOV SI , 0050
MOV AL,0AGAIN: ADD AL, [SI]
INC SIDEC CX
JNE AGAININT 3
This program adds 7 numbers stored at the memory locations 0050 through 0056.
![Page 7: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/7.jpg)
Adder Program with LOOP
MOV CX, 7MOV SI , 0050
MOV AL,0AGAIN: ADD AL, [SI]
INC SILOOP AGAIN
INT 3
This program adds 7 numbers stored at the memory locations 0050 through 0056. LOOP automatically uses
CX as a counter!
![Page 8: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/8.jpg)
String Along!
CLD MOV SI, 0200 MOV DI, 0500
MOV CX, 30 REP MOVSB
Program copies 30 (48 decimal) bytes of data beginning at0020 to the destination beginning at 0050
![Page 9: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/9.jpg)
SCAN
CLDMOV CX,0100HMOV DI, 0200H
BACK: MOV AL,0AAHREPNE SCASBJZ JUSTDOITINT3
JUSTDOIT: MOV AL, 0BBHDEC DISTOSBJMP BACK
Program scans memory and replaces AA with BB
![Page 10: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/10.jpg)
CALL & RET
HERE :CALL DELAYMOV AL, E3
MOV SI, 0050CMP AL, [SI]
JB HEREINT 3. . .
DELAY:MOV CX,0FFFFHLOOP AGAIN
RET
Monitors boiler temperature … remember?
![Page 11: COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD](https://reader035.vdocument.in/reader035/viewer/2022072014/56649e8e5503460f94b91839/html5/thumbnails/11.jpg)
Stack … Push and Pop
PUSH Saves word (not byte) on stack. First SP is decremented by 2 and then the operand is saved on the stack.
POP Increments SP by 2 and then pulls (pops) the word. Example follows:
PUSH CXPUSH BXPOP CXPOP BX
The above program is equivalent to XCHG BX,CX