1 / 10

Microprocessor

Microprocessor. MA Rahim Khan Computer Engineering and Networks Department. Loop. include 'emu8086.inc‘ ORG 100h MOV CX, 5 label1: PRINTN 'loop!' LOOP label1 RET. Overflow. CX = CX – 1 if (CX <> 0) and (ZF = 1) then jump else no jump, continue

casta
Download Presentation

Microprocessor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessor MA Rahim Khan Computer Engineering and Networks Department

  2. Loop • include 'emu8086.inc‘ • ORG 100h • MOV CX, 5 • label1: • PRINTN 'loop!' • LOOP label1 • RET

  3. Overflow • CX = CX – 1if (CX <> 0) and (ZF = 1) then • jump • else • no jump, continue • Example:; Loop until result fits into AL alone, • ; or 5 times. The result will be over 255 • ; on third loop (100+100+100), • ; so loop will exit.

  4. LOOPE(Loop will continue Until equal) • include 'emu8086.inc' • ORG 100h • MOV AX, 0 • MOV CX, 5 • label1: • PUTC '*' • ADD AX, 100 • JO Label2 • CMP AH, 0 • LOOPE label1 • label2: • PRINT 'Overflow' • RET

  5. LOOPNE(Loop will continue Until Not equal) • MOV SI, 0 • MOV CX, 5 • label1: • PUTC '*' • MOV AL, v1[SI] • INC SI ; next byte (SI=SI+1). • CMP AL, 13 • JE Label2 • LOOPNE label1 • PRINT 'Number Not Found' • JMP Exit • Label2: PRINT 'Number Found' • Exit: • RET • v1 db 9, 8, 7, 6, 5

  6. LOOPZ (Loop will until ZF=0) • include 'emu8086.inc‘ • ORG 100h • MOV AX, 0 • MOV CX, 5 • label1: • PUTC '*' • ADD AX, 100 • CMP AH, 0 • LOOPZ label1 • RET

  7. Program to find square and cube of a number • DATA SEGMENT • X DW 04H • SQUARE DW ? • CUBE DW ? • DATA ENDS • CODE SEGMENT • ASSUME CS:CODE,DS:DATA • START: MOV AX,DATA • MOV DS,AX • MOV AX,X • MOV BX,X • MUL BX • MOV SQUARE,AX • MUL BX • MOV CUBE,AX • MOV AH,4CH • INT 21H • CODE ENDS • END START • Input: x ----------- 4h • Output: Square ---------10h • Cube -----------40h

  8. Program to find factorial of a given number • DATA SEGMENT • X DW 06H • FACT DW ? • DATA ENDS • CODE SEGMENT • ASSUME CS:CODE,DS:DATA • START: MOV AX,DATA • MOV DS,AX • MOV AX,01H • MOV CX,X • UP: MUL CX • LOOP UP • MOV FACT,AX • MOV AH,4CH • INT 21H • CODE ENDS • END START

  9. Program to find Data is odd or even • include 'emu8086.inc' • DATA SEGMENT • X DW 25H • DATA ENDS • MOV DS,AX • MOV AX,X • MOV AX,3 • MOV BL,2 • DIV BL • CMP AH,0H • JNZ LABEL1 • PRINT 'NUMBER IS EVEN' • JMP EXIT: • LABEL1: • PRINT 'NUMBER IS ODD' • EXIT:RET

  10. PROGRAM TO FIND LARGEST NUMBER AMONG THE SERIES • include 'emu8086.inc' • DATA SEGMENT • X DW 0010H,52H,30H,40H,50H • LAR DW ? • DATA ENDS • CODE SEGMENT • ASSUME CS:CODE,DS:DATA • START: MOV AX,DATA • MOV DS,AX • MOV CX,05H • LEA SI,X • MOV AX,[SI] • DEC CX • UP: CMP AX,[SI+2] • JA CONTINUE • MOV AX,[SI+2] • CONTINUE:ADD SI,2 • DEC CX • JNZ UP • MOV LAR,AX • MOV AH,4CH • INT 21H • CODE ENDS • END START

More Related