60 likes | 216 Views
Lab 7. Array, Addressing. Register Indirect Mode. BX → DS SI → DS DI → DS BP → SS. Example 1. suppose that SI contains 0100h, and the word at 0100h contains 1234h. MOV AX, SI. MOV AX, [SI]. Example 1. Sum the elements in array DEC and display the result.
E N D
Lab 7 Array, Addressing
Register Indirect Mode • BX → DS • SI → DS • DI → DS • BP → SS
Example 1 • suppose that SI contains 0100h, and the word at 0100h contains 1234h. MOV AX, SI MOV AX, [SI]
Example 1 Sum the elements in array DEC and display the result. DECM DW 10, 20, 30 org 100h XOR AX,AX LEA SI,DECM MOV CX,3 ADDS: ADD AX,[SI] ADD SI,2 LOOP ADDS CALL OUTDEC ret DECM DW 10,20,30 INCLUDE 'C:\emu8086\MySource\PGM9_1.ASM' END
Example 2 Replace each lower case letter with its upper case. Msgdb “this is a message” org 100h MOV CX,17 ; NO of chars in string XOR SI, SI ; clear SI indexes a char TOP: CMP MSG[SI]," " ;BLANK ? JE NEXT ; yes skip over AND MSG[SI],0DFH ; convert to upper case NEXT: INC SI ;Index next byte LOOP TOP mov ah,9 lea dx,msg int 21h ret msg DB "this is a message"
Exercise • Enter a word or a sentence and save it in an array, then print this word or sentence in a newline.