I made a simple number guessing game:
It now supports numbers from 0 to 65534!
;SETUP
reset:
;ax: current guess
MOV bx,0 ;minimum
;cx: carry flag / input port
MOV dx,0xFFFF ;maximum+1
;#
MOV ex,0 ;# of guesses
;sp: unused
loop:
;CALCULATE AVERAGE
MOV ax,bx ;set ax to minimum
ADD ax,dx ;add maximum, set carry flag if the sum is >65535
@noflags MOV cx,0 ;reset cx
ADC cx,0 ;put carry flag in cx
SHRD ax,cx,1 ;divide by 2 and set high bit if there was a carry
;I wish there was a way to shift in the carry flag directly...
;OUTPUT/INPUT
SEND 0,ax ;display guess
ADD ex,1 ;increase # of guesses
WAIT cx ;wait for input
CMP cx,2 ;compare input to 2
JA toohigh ;if higher (port 3)
JB toolow ;if lower (port 1)
;CORRECT
SEND 0,ex ;display # of guesses
HLT
JMP reset
;TOO HIGH
toohigh:
MOV dx,ax ;set maximum to ax
JMP loop
;TOO LOW
toolow:
MOV bx,ax ;set minimum to ax
JMP loop
none
The link to the manual is not working.
LBPHacker:
This guide is intended for R2. Will it work for R1?
Although I am a complete zero in programming, I am interested in the set of instructions for R1. In R2, as I understand, there are 63 of them.