***************************************************** Swapping program that always deals 9s to the player: ***************************************************** /////////////////////////////////////////////////// Control /////////////////////////////////////////////////// LOOP: RRAND SEND RIGHT JMP LOOP /////////////////////////////////////////////////// CH1 /////////////////////////////////////////////////// LOOP: READ KEEP JMP LOOP /////////////////////////////////////////////////// CH2 /////////////////////////////////////////////////// LOOP: READ SUB CVALB 9 R0 JE R0 0 GOOD SEND LEFT JMP LOOP GOOD: KEEP JMP LOOP ***************************************************** Swapping program that passes validation: ***************************************************** /////////////////////////////////////////////////// Control /////////////////////////////////////////////////// LOOP: # Send all cards to # the right unit for # initial processing RRAND SEND RIGHT JMP LOOP /////////////////////////////////////////////////// CH1 /////////////////////////////////////////////////// # Keep track of our # score in R4. Aim # for 17 or 22+ LOOP: READ # Add it to our # score ADD R4 CVALB R4 # Aces are # dangerous, so # always pass them SUB CVAL 1 R0 JE R0 0 RECYCLE # If score is less # than 18, deal the # card SUB R4 18 R0 JLT R0 0 PRESERVE # If score is # greater than 21, # deal SUB R4 22 R0 JGE R0 0 PRESERVE # Otherwise, send # the card back to # be reprocessed RECYCLE: # We didn't keep # this card, so # remove it from # our total SUB R4 CVALB R4 SEND RIGHT JMP LOOP PRESERVE: KEEP JMP LOOP /////////////////////////////////////////////////// CH2 /////////////////////////////////////////////////// LOOP: READ # If our score is # 18 or higher, # pass everything SUB R4 18 R0 JGE R0 0 PASS # Look for a 9 or # higher. This # ensures we always # get 18, 19, or 20 SUB CVALB 9 R0 JGE R0 0 PRESERVE # Otherwise pass # all cards to the # left PASS: SEND LEFT JMP LOOP PRESERVE: # Track our score ADD R4 CVALB R4 KEEP JMP LOOP **************************************** Example program that splits even and odd cards between players **************************************** //////////////////////////////////////// Control: //////////////////////////////////////// LOOP: READ SEND LEFT READ SEND RIGHT JMP LOOP //////////////////////////////////////// CH1: //////////////////////////////////////// LOOP: READ # Store the card value ADD CVAL 0 R0 # Determine if the card is even or odd MOD: JLT R0 2 GOTMOD SUB R0 2 R0 JMP MOD GOTMOD: # Keep the card if it's even JE R0 0 PRESERVE SEND RIGHT JMP LOOP PRESERVE: KEEP JMP LOOP //////////////////////////////////////// CH2: //////////////////////////////////////// LOOP: READ # Store the card value ADD CVAL 0 R0 # Determine if the card is even or odd MOD: JLT R0 2 GOTMOD SUB R0 2 R0 JMP MOD GOTMOD: # Keep the card if it's odd JE R0 1 PRESERVE SEND LEFT JMP LOOP PRESERVE: KEEP JMP LOOP