mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:28:06 +11:00
avra: add arg range checks
This commit is contained in:
parent
5227777b34
commit
b5d42924ba
3
blk/661
3
blk/661
@ -2,7 +2,8 @@ VARIABLE ORG
|
||||
: SPLITB
|
||||
256 /MOD SWAP
|
||||
;
|
||||
: PC H@ ORG @ ;
|
||||
( We divide by 2 because each PC represents a word. )
|
||||
: PC H@ ORG @ - 1 RSHIFT ;
|
||||
( A, spits an assembled byte, A,, spits an assembled word
|
||||
Both increase PC. To debug, change C, to .X )
|
||||
: A, C, ; : A,, SPLITB A, A, ;
|
||||
|
16
blk/662
16
blk/662
@ -1,11 +1,7 @@
|
||||
( 0000 000d dddd 0000 )
|
||||
: _oor ." arg out of range: " .X SPC ." PC: " PC .X NL ABORT ;
|
||||
: _r8c DUP 7 > IF _oor THEN ;
|
||||
: _r32c DUP 31 > IF _oor THEN ;
|
||||
: _r16+c _r32c DUP 16 < IF _oor THEN ;
|
||||
: _r256c DUP 255 > IF _oor THEN ;
|
||||
: _Rdp ( op rd -- op', place Rd ) 4 LSHIFT OR ;
|
||||
: OPRd CREATE , DOES> @ SWAP _Rdp A,, ;
|
||||
0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM,
|
||||
0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC,
|
||||
0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS,
|
||||
0b1001001000000111 OPRd LAT,
|
||||
0b1001010000000110 OPRd LSR, 0b1001010000000001 OPRd NEG,
|
||||
0b1001000000001111 OPRd POP, 0b1001001000001111 OPRd PUSH,
|
||||
0b1001010000000111 OPRd ROR, 0b1001010000000010 OPRd SWAP,
|
||||
0b1001001000000100 OPRd XCH,
|
||||
|
||||
|
19
blk/663
19
blk/663
@ -1,9 +1,10 @@
|
||||
( 0000 00rd dddd rrrr )
|
||||
: OPRdRr CREATE C, DOES> C@ ( rd rr op )
|
||||
OVER 0x10 AND 3 RSHIFT OR ( rd rr op' )
|
||||
8 LSHIFT OR 0xff0f AND ( rd op' )
|
||||
SWAP _Rdp A,, ;
|
||||
0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND,
|
||||
0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE,
|
||||
0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL,
|
||||
0x28 OPRdRr OR, 0x08 OPRdRr SBC, 0x18 OPRdRr SUB,
|
||||
( 0000 000d dddd 0000 )
|
||||
: OPRd CREATE , DOES> @ SWAP _r32c _Rdp A,, ;
|
||||
0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM,
|
||||
0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC,
|
||||
0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS,
|
||||
0b1001001000000111 OPRd LAT,
|
||||
0b1001010000000110 OPRd LSR, 0b1001010000000001 OPRd NEG,
|
||||
0b1001000000001111 OPRd POP, 0b1001001000001111 OPRd PUSH,
|
||||
0b1001010000000111 OPRd ROR, 0b1001010000000010 OPRd SWAP,
|
||||
0b1001001000000100 OPRd XCH,
|
||||
|
22
blk/664
22
blk/664
@ -1,13 +1,9 @@
|
||||
( 0000 KKKK dddd KKKK )
|
||||
: OPRdK CREATE C, DOES> C@ ( rd K op )
|
||||
OVER 0xf0 AND 4 RSHIFT OR ( rd K op' )
|
||||
ROT 5 LSHIFT ROT 0x0f AND OR ( op' rdK ) A, A, ;
|
||||
0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0x0e OPRdK LDI,
|
||||
0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR,
|
||||
0x50 OPRdK SUBI,
|
||||
|
||||
( 0000 0000 AAAA Abbb )
|
||||
: OPAb CREATE C, DOES> C@ ( A b op )
|
||||
ROT 3 LSHIFT ROT OR A, A, ;
|
||||
0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC,
|
||||
0x9b OPAb SBIS,
|
||||
( 0000 00rd dddd rrrr )
|
||||
: OPRdRr CREATE C, DOES> C@ ( rd rr op )
|
||||
OVER _r32c 0x10 AND 3 RSHIFT OR ( rd rr op' )
|
||||
8 LSHIFT OR 0xff0f AND ( rd op' )
|
||||
SWAP _r32c _Rdp A,, ;
|
||||
0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND,
|
||||
0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE,
|
||||
0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL,
|
||||
0x28 OPRdRr OR, 0x08 OPRdRr SBC, 0x18 OPRdRr SUB,
|
||||
|
22
blk/665
22
blk/665
@ -1,11 +1,13 @@
|
||||
: OPNA CREATE , DOES> @ A,, ;
|
||||
0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH,
|
||||
0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS,
|
||||
0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ,
|
||||
0x9419 OPNA EIJMP, 0x9509 OPNA ICALL, 0x9519 OPNA EICALL,
|
||||
0x9409 OPNA IJMP, 0x0000 OPNA NOP, 0x9508 OPNA RET,
|
||||
0x9518 OPNA RETI, 0x9408 OPNA SEC, 0x9458 OPNA SEH,
|
||||
0x9478 OPNA SEI, 0x9428 OPNA SEN, 0x9448 OPNA SES,
|
||||
0x9468 OPNA SET, 0x9438 OPNA SEV, 0x9418 OPNA SEZ,
|
||||
0x9588 OPNA SLEEP, 0x95a8 OPNA WDR,
|
||||
( 0000 KKKK dddd KKKK )
|
||||
: OPRdK CREATE C, DOES> C@ ( rd K op )
|
||||
OVER _r256c 0xf0 AND 4 RSHIFT OR ( rd K op' )
|
||||
ROT _r16+c 4 LSHIFT ROT 0x0f AND OR ( op' rdK ) A, A, ;
|
||||
0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0x0e OPRdK LDI,
|
||||
0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR,
|
||||
0x50 OPRdK SUBI,
|
||||
|
||||
( 0000 0000 AAAA Abbb )
|
||||
: OPAb CREATE C, DOES> C@ ( A b op )
|
||||
ROT _r32c 3 LSHIFT ROT _r8c OR A, A, ;
|
||||
0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC,
|
||||
0x9b OPAb SBIS,
|
||||
|
19
blk/666
19
blk/666
@ -1,10 +1,11 @@
|
||||
( 0000 0000 0sss 0000 )
|
||||
: OPb CREATE , DOES> @ ( b op )
|
||||
SWAP 4 LSHIFT OR A,, ;
|
||||
0b1001010010001000 OPb BCLR, 0b1001010000001000 OPb BSET,
|
||||
: OPNA CREATE , DOES> @ A,, ;
|
||||
0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH,
|
||||
0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS,
|
||||
0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ,
|
||||
0x9419 OPNA EIJMP, 0x9509 OPNA ICALL, 0x9519 OPNA EICALL,
|
||||
0x9409 OPNA IJMP, 0x0000 OPNA NOP, 0x9508 OPNA RET,
|
||||
0x9518 OPNA RETI, 0x9408 OPNA SEC, 0x9458 OPNA SEH,
|
||||
0x9478 OPNA SEI, 0x9428 OPNA SEN, 0x9448 OPNA SES,
|
||||
0x9468 OPNA SET, 0x9438 OPNA SEV, 0x9418 OPNA SEZ,
|
||||
0x9588 OPNA SLEEP, 0x95a8 OPNA WDR,
|
||||
|
||||
( 0000 000d dddd 0bbb )
|
||||
: OPRdb CREATE , DOES> @ ( rd b op )
|
||||
ROT _Rdp OR A,, ;
|
||||
0b1111100000000000 OPRdb BLD, 0b1111101000000000 OPRdb BST,
|
||||
0b1111110000000000 OPRdb SBRC, 0b1111111000000000 OPRdb SBRS,
|
||||
|
10
blk/667
Normal file
10
blk/667
Normal file
@ -0,0 +1,10 @@
|
||||
( 0000 0000 0sss 0000 )
|
||||
: OPb CREATE , DOES> @ ( b op )
|
||||
SWAP _r8c _Rdp A,, ;
|
||||
0b1001010010001000 OPb BCLR, 0b1001010000001000 OPb BSET,
|
||||
|
||||
( 0000 000d dddd 0bbb )
|
||||
: OPRdb CREATE , DOES> @ ( rd b op )
|
||||
ROT _r32c _Rdp SWAP _r8c OR A,, ;
|
||||
0b1111100000000000 OPRdb BLD, 0b1111101000000000 OPRdb BST,
|
||||
0b1111110000000000 OPRdb SBRC, 0b1111111000000000 OPRdb SBRS,
|
Loading…
Reference in New Issue
Block a user