← Back to Home

Practical 4

To display flag register content on the monitor.

Theory

  1. What is the function of the flag register in 8086 microprocessor?
  2. How can you display the contents of the flag register on the monitor using assembly language?
  3. Which instruction is used to push the flag register onto the stack in 8086 assembly?
  4. How does the rcr instruction help in displaying individual flag bits?
  5. Why is it important to convert flag bit values to ASCII before displaying them?

Code

Create a file named exp4.asm in Notepad and save it in D:\TASM:


.model small

.data
msg  db "XXXXODITSZXAXPXC",13,10,'$'
newline db 13,10,'$'

.code
Start:
    mov ax, @data
    mov ds, ax

    xor al,al

    lea dx, msg
    mov ah, 09h
    int 21h

    pushf
    pop bx

    mov cl, 16   ; Fix: 16 bits, not 15

Again:
    rcr bx, 1
    mov dl, '0'
    jnc Over
    mov dl, '1'

Over:
    mov ah, 02h
    int 21h
    loop Again

    ; New line after printing bits
    lea dx, newline
    mov ah, 09h
    int 21h

    mov ah, 4Ch
    int 21h

end Start
    

Compilation and Execution using TASM

Inside DOSBox, compile and run:

    tasm filename.asm
    tlink filename.obj
    

Using Debug Tool

Run Debug:

td filename.exe