📄 instrview.cpp
字号:
// InstrView.cpp : implementation file
//
#include "stdafx.h"
#include "Pipeline.h"
#include "InstrView.h"
#include "PipelineDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// InstrView
IMPLEMENT_DYNCREATE(InstrView, CScrollView)
InstrView::InstrView(): m_rectPrint(0, 0, 4800, -15120)
{
}
InstrView::~InstrView()
{
}
BEGIN_MESSAGE_MAP(InstrView, CScrollView)
//{{AFX_MSG_MAP(InstrView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// InstrView drawing
void InstrView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
CSize sizeTotal(m_rectPrint.Width(), -m_rectPrint.Height());
CSize sizePage(sizeTotal.cx / 2,
sizeTotal.cy / 2); // page scroll
CSize sizeLine(sizeTotal.cx / 100,
sizeTotal.cy / 100); // line scroll
SetScrollSizes(MM_TWIPS, sizeTotal, sizePage, sizeLine);
}
void InstrView::OnDraw(CDC* pDC)
{//显示当前指令内存的内容
CPipelineDoc* pDoc = GetDocument();
// TODO: add draw code here
int i,nHeight;
unsigned long temp=268435456;
CString outputLine,str;
CFont font;
TEXTMETRIC tm;
font.CreateFont(-240, 120, 0, 0, 400, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
CFont* pOldFont = (CFont*) pDC->SelectObject(&font);
pDC->GetTextMetrics(&tm);
nHeight = tm.tmHeight + tm.tmExternalLeading;
pDC->TextOut(160, -80, " IM Instruction");
for(i=1;i<1000;i++)
{
//输出指令地址
if(i<5)
outputLine.Format("000%x ",4*(i-1));
else if(i>=4&&i<65)
outputLine.Format("00%x ",4*(i-1));
else if(i>=65&&i<1025)
outputLine.Format("0%x ",4*(i-1));
else
outputLine.Format("%x ",4*(i-1));
/* //输出指令二进制值
if(pDoc->IM[i-1]<temp&&pDoc->IM[i-1]!=0)
str.Format("0%x ",pDoc->IM[i-1]);
else
str.Format("%x ",pDoc->IM[i-1]);*/
outputLine+=str;
pDC->TextOut(160, -i * nHeight-80, outputLine);
//输出二进制值表示的指令“文字形式”
outputLine=pDoc->attr[i-1];
pDC->TextOut(1300,-i * nHeight-80, outputLine);
}
pDC->SelectObject(pOldFont);
}
/////////////////////////////////////////////////////////////////////////////
// InstrView diagnostics
#ifdef _DEBUG
void InstrView::AssertValid() const
{
CScrollView::AssertValid();
}
void InstrView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CPipelineDoc* InstrView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPipelineDoc)));
return (CPipelineDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// InstrView message handlers
BOOL InstrView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
// cs.style&=WS_VSCROLL;
return CScrollView::PreCreateWindow(cs);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -