Microprocessor control instructions test bench

From Zet

Jump to: navigation, search

This example tests these instructions:

  1. clc
  2. cld
  3. cli
  4. cmc
  5. hlt
  6. nop
  7. stc
  8. std
  9. sti

Code

.code16
start:
movw $0x1000, %ax
movw %ax, %ss
movw $0x1000, %sp
 
movw $0xfeff, %cx
push %cx
popf
 
clc                # (1)
cld                # (2)
cli                # (3)
 
nop                # (6)
 
pushf
pop   %ax          # %ax = 0x08d6
 
movw $0x1, %dx
push %dx
popf
 
cmc                # (4)
stc                # (7)
std                # (8)
sti                # (9)
 
pushf
pop   %bx          # %bx = 0x0603
 
movw $0x0, %cx
movw %cx, %ds
movw %ax, (0)
movw %bx, (2)
 
hlt                # (5)
 
.org 65520
jmp start
 
.org 65535
.byte 0xff
 

Results

Memory contents at the end should be:

0x00:  0x08d6  0x0603  0xXXXX  0xXXXX  0xXXXX  0xXXXX  0xXXXX  0xXXXX
Personal tools