Page 170 - PowerPoint Presentation
P. 170
CAVITE STATE UNIVERSITY
T3 CAMPUS
Department of Information Technology COSC 65 – Programming Languages
DIV Instructions
; Sample code for MUL Instruction
DIV reg/mem8 ; 8 bit reg to 8 bit mem .model small
DIV reg/mem16 ; 16 bit reg to 16 bit mem .data
DIV reg/mem32 ; 32 bit reg to 32 big mem .code
main proc
Dividend Divisor Quotient Remainder mov ax, 0080h ; ax as dividend
AX reg/mem8 AL AH mov bl, 2 ; bl as divisor
DX:AX reg/mem16 AX DX div bl
endp
Note: You can use the single end main
step process on emu8086 to
check what’s happening on
our code.
Third Group: INC, DEC, NOT, NEG
These types of operands are supported:
REG
memory
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.
memory: [BX], [BX+SI+7], variable, etc.…
INC, DEC instructions affect these flags only: ZF, SF, OF, PF, AF
NOT instruction does not affect any flags.
NEG instructions affects these flags only: CF, ZF, SF, OF, PF, AF.
NOT – Reverse each bit of operand.
NEG – Make operand negative (two’s complement). It reverses each bit of operand and
then adds 1 to it. For example, 5 will become -5, and -2 will become 2.
; Sample Code to print a number ; Sample code for INC and DEC
.model small .model small
.data .data
.code .code
main proc near main proc
mov dl, 50 ; set value of 2 to dl (refer to ASCII Table) mov dl, 50
mov ah, 2h ; code for printing character inc dl ; inc can be change to dec
int 21h ; prints value of dl which is ‘2’
endp mov ah, 2h
end main int 21h
endp
end main
For more detailed explanation, you can watch this video.
https://www.youtube.com/watch?v=zEuvNYe7WG0&t=344s
QUIZ NO. 4 | Hardcoding: Write an Assembly Program on a piece of paper that the computer
will ask the user to input two single digit number then apply sum instruction to it then display
the result.
Page | 29