ARM7 ViSUAL仿真器和Keil uVision4

时间:2019-05-28 07:40:47

标签: embedded keil arm7

关于ARM7 ViSUAL EMulator和Keil uVision4,有两个问题。

  • 在ARM7 ViSUAL仿真器上运行此命令并解释其作用。
  • 考虑如何声明变量Value1,Value2,Value3和Result。解释为什么无法使用Keil uVision4进行编译。

我已经运行了代码,但是我仍然不明白它的作用。

extension Date
{
    func hour() -> Int
    {
    //Get Hour
    let calendar = Calendar.current
    let components = calendar.component(.hour, from: self)
    let hour = components

    //Return Hour
    return hour
    }


    func minute() -> Int
    {
    //Get Minute
    let calendar = Calendar.current
    let components = calendar.component(.minute, from: self)
    let minute = components

    //Return Minute
    return minute
        }
}

Result on the ARM7 Emulator

1 个答案:

答案 0 :(得分:1)

内存分配(DCD)在与代码声明相同的区域中完成。这意味着可能会像设置了AREA PROGRAM, CODE, READONLY一样使用它,并且这样keil不会对其进行汇编。这也意味着,如果将其组装,则数据位置将为READONLY。在正确声明变量之前,应先添加AREA <a section name>, DATA, READWRITE

 Main
  LDR R1, =Value1 -- load Value1 inside R1
  LDR R2, =Value2 -- load Value2 inside R2
  LDR R1,[R1]  -- load indirect the address pointed to by the value of R1 to R1 -- (I have reservations about the functionality of this code)
  LDR R2,[R2]  -- load indirect the address pointed to by the value of R2 to R2 -- (I have reservations about the functionality of this code)
Return
  ANDS R3, R1,R2 -- R3 = R1 AND R2
  BNE SEND -- branch if not equal to SEND label
  BEQ NEXT -- branch to NEXT if equal
  END 
SEND
  LDR R4, =Result -- load Result to R4
  LDR R4,[R4]  -- load indirect the address pointed to by the value of R4 to R4 -- (I have reservations about the functionality of this code)
  STR R3, [R4] -- store indirect to address pointed to by the value of R4 with the value of R3
  END
NEXT
   MOV R1, R2  -- copy R2 to R1
   LDR R2, =Value3  -- load Value3 to R2
   LDR R2, [R2] -- load indirect the address pointed to by the value of R2 to R2 -- (I have reservations about the functionality of this code)
   B       Return -- unconditional branch to Return label
   END
 Value1 DCD &0202  -- word allocation with hex value of 
 Value2 DCD &0101  -- word allocation with hex value of 
 Value3 DCD &0001  -- word allocation with hex value of 
 Result DCD &FFFFFFF0 -- word allocation with hex value of 

此代码试图保存r2r1相等或由于Value<1-3>中保存的值的静态性质而发生无限循环的事实