diff options
| author | Uri Shaked | 2020-04-09 22:54:32 +0300 |
|---|---|---|
| committer | Uri Shaked | 2020-04-09 22:54:32 +0300 |
| commit | d705922dfe12863e1ab4b9f9979916b224f09028 (patch) | |
| tree | 6b751a631974f5958a3a805ea6df7c15d52eae00 /src/cpu/cpu.ts | |
| parent | style(demo): formatting, lint issue (diff) | |
| download | avr8js-d705922dfe12863e1ab4b9f9979916b224f09028.tar.gz avr8js-d705922dfe12863e1ab4b9f9979916b224f09028.tar.bz2 avr8js-d705922dfe12863e1ab4b9f9979916b224f09028.zip | |
feat(instruction): 22-bit PC support #31
adapt CALL, ICALL, RCALL, RET, and RETI for MCUs with 22-bit PC
Diffstat (limited to 'src/cpu/cpu.ts')
| -rw-r--r-- | src/cpu/cpu.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/cpu/cpu.ts b/src/cpu/cpu.ts index 93f79d0..0c60c9e 100644 --- a/src/cpu/cpu.ts +++ b/src/cpu/cpu.ts @@ -5,7 +5,7 @@ * Copyright (C) 2019, Uri Shaked */ -import { u16, u8 } from '../types'; +import { u32, u16, u8 } from '../types'; const registerSpace = 0x100; @@ -15,7 +15,20 @@ export interface ICPU { readonly dataView: DataView; readonly progMem: Uint16Array; readonly progBytes: Uint8Array; - pc: u16; + + /** + * Whether the program counter (PC) can address 22 bits (the default is 16) + */ + readonly pc22Bits: boolean; + + /** + * Program counter + */ + pc: u32; + + /** + * Clock cycle counter + */ cycles: number; readData(addr: u16): u8; @@ -33,6 +46,7 @@ export class CPU implements ICPU { readonly dataView = new DataView(this.data.buffer); readonly progBytes = new Uint8Array(this.progMem.buffer); readonly writeHooks: CPUMemoryHooks = []; + readonly pc22Bits = this.progBytes.length > 0x20000; pc = 0; cycles = 0; |
