ST4 Syntax

Information

The following tables show the definition of the Studio IV pseudo code.

During startup the Studio IV will check if hex address 800 or 1000 contains AA. If so the interpreter will do a JP to hex address 802 or 1002 where it will expect the cartridge pseudo code.

This info is also available online on the Emma 02 site.

Definitions

aaa 12 bit address
kk 8 bit constant
n 4 bit constant
x Register number Vx (x = 0 to F)
y Register number Vy (y = 0 to F)
I Register I (16 bit)
[I] Memory value of address in register I
[Vy] Memory value of address in register Vy within in page 27 (RAM)
. Not used, value doesn't matter
1..9, A..F Hexadecimal digits

Syntax

6754 ADD [V0V1], [V2V3]
V0V1, V2V3
Add decimal values [V0V1] and [V2V3] store result on [V0V1]. Number of digits stored in V9. LSD is on V0V1 and V2V3, following digit is on one address lower. Each address (byte) only contains one decimal digit
62kk ADD I, kk Add kk to Low byte of I; no carry to high byte is done
678E ADD I, V9 I = I + V9
7xkk ADD Vx, kk Vx = Vx + kk
4x4y ADD Vx, Vy Vx = Vx + Vy, VB is carry / not borrow
4xAy ADDN Vx, Vy ADD Nibbles, Vx-n0 = Vx-n0 + Vy-n0 and Vx-n1 = Vx-n1 + Vy-n1 (Vx-n0 is the lower 4 bits of Vx, Vx-n1 the higher 4 bits)
4x2y AND Vx, Vy Vx = Vx + Vy
66kk CALL 06kk Call subroutine on 6kk, return with 6B..
67kk CALL 07kk Call subroutine on 7kk, return with 6B..
68kk CALL 08kk Call subroutine on 8kk, return with 6B..
60kk CALL 10kk Call subroutine on 10kk, return with 6B..
61kk CALL 11kk Call subroutine on 11kk, return with 6B..
69kk CALL I, kk Call subroutine on I, V9=kk, return with 6B..
662E CHAR [V2V3], V0, V1
[V2V3]
Print character stored on [V2V3] on screen position horizontal V0, vertical V1
662C CHAR [I], V0, V1
[I]
Print character stored on [I] on screen position horizontal V0, vertical V1
6688 CLR Colour 2 blocks on the screen with CLR Vx, Vy, address following subroutine call contains:
Byte 1/2: Screen position first CLR command (Vx and Vx+1)
Byte 3/4: Screen position second CLR command (Vx and Vx+1)
Byte 5: Colour first CLR command (Vy)
Byte 6: Colour second CLR command (Vy)
If byte 6 highest nibble is not 0 then 2 more blocks in following 6 bytes will be coloured.
5x6c CLR Vx, c Store colour c in colour RAM.
Size: 8*4 (w*h)
Repeat horizontal: Vx high nibble
Repeat vertical: Vx+1 high nibble
Screen position: Vx, Vx+1 low nibble
Positions: 16x16
5x5y CLR Vx, Vy Store colour Vy (lowest 4 bit) in colour RAM.
Size: 8*4 (w*h)
Repeat horizontal: Vx high nibble
Repeat vertical: Vx+1 high nibble
Screen position: Vx, Vx+1 low nibble
Positions: 16x16
6612 CLS Print 8*4 pattern from 0575-0578 (zeros) on screen with DRWR I, Vx, address following subroutine call contains:
Byte 1: Vx value
Byte 2: Vx+1 value
6690 CP [I]
I
Copy to [I] from memory after subroutine call, number of bytes stored in V9
5xDy CP [I], Vx, Vy
I, Vx, Vy
Copy value [I] until [I+y] to Vx until Vy
5xCy CP Vx, Vy, [I]
Vx, Vy, I
Copy value Vx until Vy to [I] until [I+y]
4xEn DRW I, Vx, n Draw pattern from [I] on screen position Vx, V(x+1)
Size: 8*n
Positions: 128x64
5x2. DRW I, Vx Draw patterns from [I] on screen.
Size: 8*4 (w*h)
Repeat horizontal: Vx high nibble
Repeat vertical: Vx+1 high nibble
Screen position: Vx, Vx+1 low nibble
Positions: 16x16
5x7. DRWR I, Vx Draw pattern from [I] on screen and repeat the same pattern.
Size: 8*4 (w*h)
Repeat horizontal: Vx high nibble
Repeat vertical: Vx+1 high nibble
Screen position: Vx, Vx+1 low nibble
Positions: 16x16
Axkk JE I, Vx, kk
Vx, kk
Jump to I if Vx = kk
5x3y JE I, Vx, Vy
Vx, Vy
IF Vx = Vy THEN jump to I
5xAy JG I, Vx, Vy
Vx, Vy
IF Vx greater than Vy THEN jump to I
5.8y JK I, Vy
Vy
IF KEY Vy is pressed THEN jump to I. VA contains keypad (0 key pad player 1, 1 keypad player 2)
Bxkk JNE I, Vx, kk
Vx, kk
Jump to I if Vx != kk
5.9y JNK I, Vy
Vy
IF KEY Vy not pressed THEN jump to I. VA contains keypad (0 key pad player 1, 1 keypad player 2)
9xkk JNZ Vx, kk Jump if variable Vx is not zero to current page with offset kk
65kk JP kk Jump to kk in same page
4.B. JP I Jump to address I
5xBy JS I, Vx, Vy
Vx, Vy
IF Vx smaller than Vy THEN jump to I
5x4y JU I, Vx, Vy
Vx, Vy
IF Vx!=Vy THEN jump to I
8xkk JZ Vx, kk Jump if variable Vx is zero to current page with offset kk
671C KEY SWITCH Key switch subroutine. Following bytes are used as input:
Byte 1: First key
Byte 2: Last key
Byte 3/4: return address if no key pressed
Following bytes contain jump table for the pressed keys, first two bytes key 0, next 2 key 1 etc.
4.Fy KEY Vy Check if key is pressed, if so return key in Vy and VB=1 (VB=0, no key pressed). VA contains keypad (0 key pad player 1, 1 keypad player 2).
67AA KEY WAIT Wait for key from either keypad and return key in V9, VA indicates keypad
4x7y KEYP Vy Wait for key and return key in Vy.
VA contains keypad (0 key pad player 1, 1 keypad player 2).VC = x shift left 3
4x8y KEYR Vy Wait for key press/release and return key in Vy. VA contains keypad (0 key pad player 1, 1 keypad player 2). VC = x shift left 3
64kk LD [27kk], I LD I high byte to [27kk] and low byte to [27kk+1]
Dxkk LD [27kk], Vx Load address [27kk] with Vx
4x0y LD B, [Vy], Vx
B, Vy, Vx
Convert Vx to 3 digit decimal at [Vy+2700], [Vy+2701], [Vy+2702]
679E LD I, [I] I = [I]
679C LD I, [I+V9] I = [I+V9]
0aaa LD I, 0aaa Load I with address 0000 to 0FFF
1aaa LD I, 1aaa Load I with address 1000 to 1FFF
2aaa LD I, 2aaa Load I with address 2000 to 2FFF
3aaa LD I, 3aaa Load I with address 3000 to 3FFF
63kk LD I, [27kk] LD I with high byte from [27kk] and low byte from [27kk+1]
63Ey LD I, Vy, Vy+1
I, Vy
LD I with high byte from Vy and low byte from Vy+1
Exkk LD Vx, [27kk] Load Vx with value on address [27kk]
Fxkk LD Vx, kk Vx = kk
5xFy LD Vx, [Vy] Vx = [VyV(y+1)]
DxEy
ExEy
LD Vx, Vy Vx = Vy
5xEy LD [Vy], Vx [VyV(y+1)] = Vx
64Ey LD Vy, Vy+1, I
Vy, I
LD Vy with high byte from I and Vy+1 with low byte from I
4x1y OR Vx, Vy Vx = Vx OR Vy
6Fkk OUT4 kk OUT 4 with value kk, address 27F4 = kk
6E.y OUT4 Vy OUT 4 with value Vx, address 27F4 = Vx
660A POP POP (get) V0 to V9 from 2702-270B
660A POP V0-V9 POP (get) V0 to V9 from 2702-270B
6C.. POP I Load I from stack
6648 PRINT Print characters on screen, address following subroutine call contains:
Byte 1: horizontal position on screen (0 to 128)
Byte 2: vertical position on screen (0 to 64)
Byte 3 and onwards: character number as on 05nn see 0500-052F table.
Last byte hex FF
6682 PRINT D, 1 Print decimal value of V9 (1 digit) on screen, address following subroutine call contains:
Byte 1: horizontal position on screen (0 to 128)
Byte 2: vertical position on screen (0 to 64)
667C PRINT D, 2 Print decimal value of V9 (2 digit) on screen
6660 PRINT D, 3 Print decimal value of V9 (3 digit) on screen
6656 PRINT [I]
I
Print characters on screen, [I] contains:
Byte 1: horizontal position on screen (0 to 128)
Byte 2: vertical position on screen (0 to 64)
Byte 3 and onwards: character number as on 05nn see 0500-052F table.
Last byte hex FF
6600 PUSH PUSH (save) V0 to V9 on 2702-270B
6600 PUSH V0-V9 PUSH (save) V0 to V9 on 2702-270B
6A.. PUSH I Store value I on stack
6700 RESET RAM Reset 2700-279F to 0
6B.. RETURN Return from subroutine (any CALL)
67BC RND [270B],V8,V9
V8, V9
Store random number between V8 and V9 on [270B]
67B6 RND [270B], V9
V9
Store random number between 0 and V9 on [270B]
Cxkk RND Vx, kk Vx = random byte masked by kk
6612 SCR CLS Print 8*4 pattern from 0575-0578 (zeros) on screen with DRWR I, Vx, address following subroutine call contains:
Byte 1: Vx value
Byte 2: Vx+1 value
6626 SCR FILL Print 8*4 pattern from 05FC-05FF (#ff) on screen with DRWR I, Vx, address following subroutine call contains:
Byte 1: Vx value
Byte 2: Vx+1 value
670B SCR XOR XOR Screen memory with hex FF
4x6n SHL Vx, n Vx = Vx SHL n times, VB will contains bits shifted 'out of Vx'
4x9n SHR Vx, n Vx = Vx SHR n times, VB will contains bits shifted 'out of Vx'
4xCy SHR Vx, Vy Vx = (Vx SHR 3) AND hex F, Vy =(Vy SHR 2) AND hex F
4.D. STOP Wait in endless loop
675A SUB [V0V1], [V2V3]
V0V1, V2V3
Subtract decimal values [V2V3] from [V0V1] store result on [V0V1]. Number of digits stored in V9. LSD is on V0V1 and V2V3, following digit is on one address lower. Each address (byte) only contains one decimal digit
4x5y SUB Vx, Vy Vx = Vx - Vy, VB is carry / not borrow
5x1y SWAP Vx, Vy, [I]
Vx, Vy, I
Switch value [I] and onwards with Vx until Vy
5.0. SYS I Call 1802 routine at address I, end routine with SEP R4
6D.. WAIT [I], kk
I, kk
WAIT with a value kk, using [I] towards a table on 049h and 048l where hl is the byte on [I]
4x3y XOR Vx, Vy Vx = Vx XOR Vy