0

Im trying to make a guessing game in pure NASM assembly. The problem Im facing with is that; I can't figure out how to input characters and then display them on the vga or screen. Can somebody please help me or show me how to do this. There is very little documentation online. I want the player to input a number then if it matches a random number generated by the computer it will output text or if it's incorrect output correct. Below is my code ...

 org   0
 bits  16

 section .text
 global _start

 _start:
 push cs
 pop  ds
 mov  si, msg
 mov  bx, 0x0007
 jmp  BeginLoop

 PrintLoop:
 mov  ah, 0x0E
 int  0x10

 BeginLoop:
 mov  al, [si]
 inc  si
 test al, al
 jnz  PrintLoop


 msg db   'Welcome To My Guessing Game: ', 10, 13, 'Pick A Number Between 1 - 10 ', 10, 13

 TIMES 512 - ($ - $$) db 0
  • 1
    CS isn't always 0x7C0. you should set DS to a known constant to match your ORG; your code won't work on all computers. – Peter Cordes Oct 13 '22 at 04:21
  • 1
    Also consider simplifying to only deal with single-digit numbers (at least in your first version), so it's always a single character. Like '0' to '9', or '1' to '9'. Otherwise you need to compare strings, or do string->int conversion (`total = total*10 + digit`.) as well as deal with converting ASCII codes to the integer digit they represent. (`sub al, '0'`) – Peter Cordes Oct 13 '22 at 04:23

0 Answers0