R16K1S60

  • 12Me21
    1st Jun 2017 Member 2 Permalink

    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

    Edited 4 times by 12Me21. Last: 3rd Jun 2017
  • IS2511
    4th Jun 2017 Member 0 Permalink

    Best computer in TPT.

    Edited once by IS2511. Last: 4th Jun 2017
  • 12Me21
    5th Jun 2017 Member 0 Permalink

    IS2511:

    Best computer in TPT.

     "not for long"

  • 12Me21
    10th Jun 2017 Member 0 Permalink

    I discovered a bug in the assembler.

    If you use @org, the success message doesn't show the correct number of cells.

    For example

    HLT
    HLT
    HLT
    @org 0
    NOP
    says "4 instructions, 1 cells"

  • CALVIN1390
    12th Oct 2018 Member 0 Permalink
  • VladislavMotkov
    24th April Member 0 Permalink

    The link to the manual is not working.

  • VladislavMotkov
    24th April Member 0 Permalink

    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.

    Edited 2 times by VladislavMotkov. Last: 24th April
  • LBPHacker
    24th April Developer 1 Permalink
    Oh I'm an absolute frog, sorry about that, I completely missed the context. I was wondering why the link in the OP was not redirected to the github link when I had already done that; now I know why, this is a different thread lol. Uh yeah hold on, I don't have the manual for the R1 on github yet and my site's markdown renderer is dead (that's why the links are broken in the first place). I'll fix this in a bit.

    Edit: there, fixed: https://github.com/LBPHacker/R16/blob/master/manual.md
    Edited once by LBPHacker. Last: 24th April