From mboxrd@z Thu Jan 1 00:00:00 1970 From: lehotsky@earthlink.net To: cgen@sourceware.cygnus.com Subject: problems simulating register-only architecture... Date: Thu, 24 May 2001 13:39:00 -0000 Message-id: <200105242031.QAA10298@iron.> X-SW-Source: 2001-q2/msg00073.html The machine I'm developing a simulator for is a "register only" architecture, whose only memory is 512, 32-bit registers. I'm trying to model this as as a group of virtual registers with a 2k memory. There are 4 registers that are "special", in that they are auto-indexed (e.g.) reading register X uses the contents of register Y as an indirect register number. But when I set up my "model" as follows, it doesn't work; is it possible that the define-pmacro EA is evaluated at the wrong time? Or, do I need to write my "get" and "set" accessors as escapes to C code to make this work? It appears that with these hardware elements defined, the generated sem.c expands to code that is doing GETMEMSI() directly, Here's the code from my .cpu file (define-hardware (name h-register) (comment "all addressable registers") (attrs VIRTUAL) (type memory SI (512)) (get (index) (mem SI (EA index))) (set (index newval) (set (mem SI (EA index)) newval)) ) ; The actual memory.... 512 32 bit words == 2048 bytes ; (define-hardware (name h-memory) (comment "all addressable data memory") (type memory QI (2048)) ) .,. ... (define-pmacro (EA index) (sll (cond SI ((eq index ptr0x) (and #x1ff (reg SI h-register ptr0))) ((eq index ptr1x) (and #x1ff (reg SI h-register ptr1))) ((eq index ptr2x) (and #x1ff (reg SI h-register ptr2))) ((eq index spx) (and #x1ff (reg SI h-register sp))) (else index)) 2) ) ...... (dni cmpi "cmp reg/imm" () "cmpi $rd,$imm16" (+ OP5_CMPI (f-dc2 #x0) rd imm16) (sequence ((SI result)) (set result (sub SI (reg SI h-register rd) (zext USI imm16))) (set zbit (zflag result)) (set nbit (nflag result)) (set cbit (sub-cflag (reg SI h-register rd) (zext USI imm16) (const 0)))) () ) =========================== But the resulting expansion in the sem file looks like... SI tmp_result; tmp_result = SUBSI (GETMEMSI (current_cpu, pc, i_rd), ZEXTSISI (f_imm16)); Note that the REGISTER access has been optimized to a GETMEMSI, but when I step my way thru the expansion of the GETMEMSI, the code to evaluate the effective address is gone. Any thoughts on this? Is there a better way to achieve this? -- Al