1

As part of a school project (majoring in Computer Science and we learn assembly language for part of our grade, starting with 8086 right now) I have to make... something using what we've "learned" (our teacher gave us a list of commands and told us to teach ourselves, with his help obviously) until the end of the month.

So I made a "game" where you are this smiley guy and you gotta go through this maze, with stars as obstacles that bring you back to the starting point and '>' as the marker for next level.

The levels are just text that I print to the screen, each step comparing the next input with a wall/star/'>' thing and then if it's a star it resets your position, if it's a wall you stay in your place and if it's a '>' thingy then it prints the next level. It all works except the next part of next level.

Here's the Pastebin, with my problem detailed and pointed out.

itamar reif
  • 139
  • 2
  • 9

1 Answers1

0

Here: inc mazesIndex you need to increase mazesIndex by maze size (49 * 10 + 1 = 491 bytes) instead of by 1

Denis Itskovich
  • 4,383
  • 3
  • 32
  • 53
  • So would adding a mazeSize 16 bit variable and then doing `add mazeIndex, mazeSize` solve my issue? Also, how would I calculate the mazeSize? I'd hate having it hard coded... – itamar reif Dec 19 '14 at 17:12
  • @ItamarReif, you don't have to have it hard-coded. Assuming your maze is of constant type, you can put label at the beginning of the second maze and then to calculate the difference between the starting address of maze1 and starting address of maze0. If the length may vary, then you will have to measure the string length in run-time – Denis Itskovich Dec 19 '14 at 18:18
  • What does 'constant type' mean? And if I understand correctly I put, say, a '#' sign at (0;0) in each member of the mazes array and then I calculate the amount of characters between each '#'? How would I do that? – itamar reif Dec 19 '14 at 21:40
  • Sorry, I meant constant size, of course. If the size may vary, you need to calculate it in run-time. Another option is to build a look-up table, which will contain pointers to the mazes themselves. If you prefer to calculate in run-time, then you don't need to add any special character, because you already have one - '$' at the end of each maze. So when you start the maze, you can scan the array until you find '$' and remember its position. Then, when you want to switch to the next maze, set mazeIndex to previously remembered position + 1 (in order to skip '$' character itself) – Denis Itskovich Dec 20 '14 at 03:37
  • `whichMaze:mov si, mazesIndex mov bh, mazes[si] mov byte ptr indexChar, bh cmp bh, '$' je endOfMaze jne nextChar endOfMaze: inc $Count mov dx, mazeCount cmp $Count, dx je fin jne nextChar nextChar: inc mazesIndex loop whichMaze fin: inc mazesIndex mov $Count, 0h ret` something like that? – itamar reif Dec 20 '14 at 19:51
  • [I solved it!](http://pastebin.com/ktXqEuxe) But now the cursor starts displaying at the end of the maze: http://i.imgur.com/0i9ZMls.png – itamar reif Dec 20 '14 at 22:26
  • @Denis Itskovich. Where did you get those numbers? I got (48*10)+45+1. To Itamar Reif. For lines 188-189 : Since *mazeCount* and *$count* are both variables they reside in memory. The processor cannot compare these straight up. For line 194 : You didn't setup CX so you cannot use LOOP here! A simple JMP is ok. – Sep Roland Dec 21 '14 at 14:55
  • @ItamarReif, I didn't calculate well. It should be 48*10+1. – Denis Itskovich Dec 21 '14 at 16:53
  • @user3144770 Oh, thanks! DenisItskovich Thanks for all the help, I solved this thanks to you. – itamar reif Dec 21 '14 at 21:50