Return to Menu

= EMULATOR AND ASSEMBLER =

Download: DuoAssemblerAndEmulator.jar
Last update: 5/8/10. This file requires Java to run. May not work on Macs.

The DUO TTL assembler is a utility which converts assembly code into machine code which the DUO machine can execute directly. Command lines are typed or pasted into the "Assembly Code" box, then is converted to machine code when the "Assemble" button is pressed. Code is NOT case sensitive. The text to the right of the code box shows all the command names you can use and their arguments.

Commands are separated by newlines, and the terms of a command are separated by spaces. The first term of a command is the command name. If the command name is not one of the 11 DUO commands, then the assembler interprets it as a label. If the command name is preceded by a question mark (?), then the command is conditional. Arguments (the terms after the command name) may be one of the following:

If brackets ([]) are placed around an argument, the data at the RAM address is used in place of the argument. Using a label by default calls the lower nybble of the label's address byte. To access the upper nybble, a plus sign (+) is placed before the label name.

Writes the number 6 to RAM address A: write 6 A

Writes the data at A to B: write [A] B

Goes to the label called "myLabel": goto +myLabel myLabel

Conditionally skips to the first command: ?goto 0 0

Sets the 3rd bit from the left on in the given nybble: bitOn 1001 2 A

= EXAMPLE PROGRAMS =

Move a dot around on screen with arrow keys:

output 1000 0000 0
loop
write [a] c
write [b] d
input 0 e
equal [e] 1000
?add [c] 15 c
equal [e] 0100
?add [d] 15 d
equal [e] 0010
?add [c] 1 c
equal [e] 0001
?add [d] 1 d
equal [a] [c]
?equal [b] [d]
?goto +loop loop
write 0000 g
write 0000 h
greater 4 [c]
?biton [g] [c] g
greater [c] 3
?add [c] 12 f
?biton [h] [f] h
output 0000 0000 [b]
output [g] [h] [d]
write [c] a
write [d] b
goto +loop loop

PONG (use left/right arrow keys):

write 3 a
write 1 c
write 1 d
loop
write [b] i
add [a] [c] a
equal [a] 7
?write 15 c
equal [a] 0
?write 1 c
add [b] [d] b
add [f] 3 e
greater [a] [e]
?goto +bounceSkip bounceSkip
greater [f] [a]
?goto +bounceSkip bounceSkip
equal [b] 6
?write 15 d
bounceSkip
equal [b] 0
?write 1 d
write 0000 g
write 0000 h
greater 4 [a]
?biton [g] [a] g
greater [a] 3
?add [a] 12 e
?biton [h] [e] h
output 0000 0000 [i]
output [g] [h] [b]
input 0 e
equal [e] 1000
?unequal [f] 0
?add [f] 14 f
equal [e] 0010
?unequal [f] 4
?add [f] 2 f
equal [f] 0
?output 1111 0000 7
equal [f] 2
?output 0011 1100 7
equal [f] 4
?output 0000 1111 7
equal [b] 7
?output 0100 1000 1
?output 0011 0000 3
?output 0100 1000 4
goto +loop loop

THIS IS THE DUO memory optimized letter slideshow:

write 0 a
loop
write 0 b
pause
unequal [b] 15
?add [b] 1 b
?goto +pause pause
equal [a] 0
?goto +drawT drawT
equal [a] 8
drawT
?write 0111 h
?write 0010 i
?write 0010 j
?write 0010 k
?write 0010 l
equal [a] 1
?goto +drawH drawH
equal [a] 9
drawH
?write 0101 h
?write 0101 i
?write 0111 j
?write 0101 k
?write 0101 l
equal [a] 5
?goto +drawI drawI
equal [a] 2
drawI
?write 0111 h
?write 0010 i
?write 0010 j
?write 0010 k
?write 0111 l
equal [a] 6
?goto +drawS drawS
equal [a] 3
drawS
?write 0011 h
?write 0100 i
?write 0001 k
?write 0110 l
equal [a] 4
?goto +drawSpace drawSpace
equal [a] 7
?goto +drawSpace drawSpace
equal [a] 11
?goto +drawSpace drawSpace
equal [a] 15
drawSpace
?write 0000 h
?write 0000 i
?write 0000 j
?write 0000 k
?write 0000 l
equal [a] 10
?write 0111 h
?write 0100 i
?write 0110 j
?write 0100 k
?write 0111 l
equal [a] 12
?write 0110 h
?write 0101 i
?write 0101 j
?write 0101 k
?write 0110 l
equal [a] 13
?write 0101 h
?write 0111 l
equal [a] 14
?write 0111 h
output [h] 0 1
output [i] 0 2
output [j] 0 3
output [k] 0 4
output [l] 0 5
add [a] 1 a
goto +loop loop

Accepts two 4-digit binary numbers and multiplies them. Use left/right arrow keys to move cursor, up/down to set each bit of the numbers, then hold left and right simultaneously to multiply:

output 1000 0000 0
inputLoop
write 0000 e
write 0000 f
inputLoop2
input 0 k
equal [k] 1000
?add [m] 14 m
?goto +displayCursor displayCursor
equal [k] 0010
?goto +displayCursor displayCursor
equal [k] 0100
?goto +bitonInput bitonInput
equal [k] 0001
?goto +bitoffInput bitoffInput
equal [k] 1010
?goto +multiply multiply
goto +inputLoop2 inputLoop2

bitonInput
equal [n] 0
?biton [a] [m] a
equal [n] 1
?biton [b] [m] b
goto +displayInput displayInput

bitoffInput
equal [n] 0
?bitoff [a] [m] a
equal [n] 1
?bitoff [b] [m] b

displayInput
output [a] [b] 1

displayCursor
add [m] 1 m
greater [m] 3
?add [n] 1 n
?equal [n] 2
?write 0 n
equal [m] 4
?write 0 m
equal [m] 15
?write 3 m
add e [n] k
biton 0000 [m] [k]
output [e] [f] 0
goto +inputLoop inputLoop

multiply
write 3 c

resetPlaceValue
write 3 d

addDigit
bitget [a] [c] i
bitget [b] [d] j
add [i] [j] k
unequal [k] 2
?goto +addSkip addSkip

add [c] [d] g
add [g] 1 g
greater 4 [g]
?write e h
?write [e] i
greater [g] 3
?add [g] 12 g
?write f h
?write [f] i
biton 0000 [g] j

add [i] [j] k
write [k] [h]
greater [i] [k]
?add [e] 1 e
?goto +addSkip addSkip
greater [j] [k]
?add [e] 1 e

addSkip
add [d] 15 d
unequal [d] 15
?goto +addDigit addDigit

output [e] [f] 6
add [c] 15 c
unequal [c] 15
?goto +resetPlaceValue resetPlaceValue

goto +inputLoop inputLoop

Duck food collect game (use up and down arrow keys):

start
write 14 c
write 12 g
goto +drawDuck drawDuck
loop
input 0 k
write [a] b
equal [k] 0100
?write 0 b
equal [k] 0001
?write 4 b
unequal [k] 0000
?add [f] 1 f
equal [b] [a]
?goto +drawDuckSkip drawDuckSkip
drawDuck
write 0 p
eraseRow
add [a] [p] n
output 0000 0000 [n]
add [p] 1 p
unequal [p] 4
?goto +eraseRow eraseRow
write [b] a
add [a] 1 n
add [a] 2 o
add [a] 3 p
output 0010 0000 [a]
output 0011 0000 [n]
output 1110 0000 [o]
output 0110 0000 [p]
drawDuckSkip
add [c] 15 c
equal [c] 15
?goto +eraseFood eraseFood
equal [c] 14
?goto +shuffleFood shuffleFood
greater [c] 3
?goto +loop loop
biton 0000 [c] p
drawFood
add [d] 1 n
equal [d] [a]
?output 0011 [p] [n]
unequal [d] [a]
?output 0000 [p] [n]
goto +loop loop
eraseFood
equal [d] [a]
?add [e] 1 e
add [g] 15 g
equal [g] 0
?goto +endGame endGame
unequal [d] [a]
?add [d] 2 n
?output 1111 1111 [n]
write 0000 p
goto +drawFood drawFood
shuffleFood
bitget [f] 3 p
equal [p] 0
?add [f] 1 f
?goto +loop loop
add [d] 4 d
greater [d] 4
?write 0 d
goto +loop loop
endGame
output [e] 0000 0
output 12 0000 1
output 0000 0000 2
output 0000 0100 3
output 0000 0010 4
output 0011 1111 5
output 0000 0010 6
output 0000 0100 7
write 0 e
endLoop
input 0 k
equal [k] 0010
?goto +start start
goto +endLoop endLoop

Return to Menu

Return to the Ostracod Pond