.486
.model flat,c
.code

Chip_pNextChip equ 40
Chip_pfnOnClock equ 44
Clock_TimerRoot_iTime equ 96

extrn ExecEvent:near

DisplaySCProc macro x
  DisplaySCProc&x proc private

    mov AL,[EBX+4]
    if x and 80h
      mov [EBX+0],CH
    else
      mov [EBX+0],CL
    endif

    mov EAX,[ESI+Clock_TimerRoot_iTime]
    if x and 08h
      mov [EBX+4],CH
    else
      mov [EBX+4],CL
    endif

    inc EAX
    if x and 40h
      mov [EBX+1],CH
    else
      mov [EBX+1],CL
    endif

    mov [ESI+Clock_TimerRoot_iTime],EAX
    if x and 04h
      mov [EBX+5],CH
    else
      mov [EBX+5],CL
    endif

    mov ESI,[ESI+Chip_pNextChip]
    if x and 20h
      mov [EBX+2],CH
    else
      mov [EBX+2],CL
    endif

    if x and 02h
      mov [EBX+6],CH
    else
      mov [EBX+6],CL
    endif
    if x and 10h
      mov [EBX+3],CH
    else
      mov [EBX+3],CL
    endif

    if x and 01h
      mov [EBX+7],CH
    else
      mov [EBX+7],CL
    endif
    je ExecEvent

    jmp dword ptr [ESI+Chip_pfnOnClock]

  DisplaySCProc&x endp
endm

.data
align 4
aiFour label dword
x = 0
rept 256
  dd x*16777216+x*65536+x*256+x
  x = x + 1
endm
.code

x = 0
rept 256
  DisplaySCProc %x
  x = x + 1
endm

DisplayMCProc macro x
  DisplayMCProc&x proc private

    mov AL,[EBX+4]
    if (x and 0C0h) eq 00h
      mov [EBX+0],CL
    elseif (x and 0C0h) eq 40h
      mov [EBX+0],DH
    elseif (x and 0C0h) eq 80h
      mov [EBX+0],DL
    else 
      mov [EBX+0],CH
    endif

    mov EAX,[ESI+Clock_TimerRoot_iTime]
    if (x and 0Ch) eq 00h
      mov [EBX+4],CL
    elseif (x and 0Ch) eq 04h
      mov [EBX+4],DH
    elseif (x and 0Ch) eq 08h
      mov [EBX+4],DL
    else 
      mov [EBX+4],CH
    endif

    inc EAX
    if (x and 0C0h) eq 00h
      mov [EBX+1],CL
    elseif (x and 0C0h) eq 40h
      mov [EBX+1],DH
    elseif (x and 0C0h) eq 80h
      mov [EBX+1],DL
    else 
      mov [EBX+1],CH
    endif

    mov [ESI+Clock_TimerRoot_iTime],EAX
    if (x and 0Ch) eq 00h
      mov [EBX+5],CL
    elseif (x and 0Ch) eq 04h
      mov [EBX+5],DH
    elseif (x and 0Ch) eq 08h
      mov [EBX+5],DL
    else 
      mov [EBX+5],CH
    endif

    mov ESI,[ESI+Chip_pNextChip]
    if (x and 30h) eq 00h
      mov [EBX+2],CL
    elseif (x and 30h) eq 10h
      mov [EBX+2],DH
    elseif (x and 30h) eq 20h
      mov [EBX+2],DL
    else 
      mov [EBX+2],CH
    endif

    if (x and 03h) eq 00h
      mov [EBX+6],CL
    elseif (x and 03h) eq 01h
      mov [EBX+6],DH
    elseif (x and 03h) eq 02h
      mov [EBX+6],DL
    else 
      mov [EBX+6],CH
    endif
    if (x and 30h) eq 00h
      mov [EBX+3],CL
    elseif (x and 30h) eq 10h
      mov [EBX+3],DH
    elseif (x and 30h) eq 20h
      mov [EBX+3],DL
    else 
      mov [EBX+3],CH
    endif

    if (x and 03h) eq 00h
      mov [EBX+7],CL
    elseif (x and 03h) eq 01h
      mov [EBX+7],DH
    elseif (x and 03h) eq 02h
      mov [EBX+7],DL
    else 
      mov [EBX+7],CH
    endif
    je ExecEvent

    jmp dword ptr [ESI+Chip_pfnOnClock]

  DisplayMCProc&x endp
endm

x = 0
rept 256
  DisplayMCProc %x
  x = x + 1
endm

.data

DisplaySCPtr macro x
  dd DisplaySCProc&x
endm

DisplayMCPtr macro x
  dd DisplayMCProc&x
endm

align 4
gapfnDisplaySC label dword
public gapfnDisplaySC
x = 0
rept 256
  DisplaySCPtr %x
  x = x + 1
endm
gapfnDisplayMC label dword
public gapfnDisplayMC
x = 0
rept 256
  DisplayMCPtr %x
  x = x + 1
endm

end
