Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statements not working #26

Open
Jyo561 opened this issue Jun 7, 2022 · 13 comments
Open

Statements not working #26

Jyo561 opened this issue Jun 7, 2022 · 13 comments

Comments

@Jyo561
Copy link

Jyo561 commented Jun 7, 2022

MOV AX,2000H
MOV BX,2002H
ADD AX,BX

i wrote this code and this not working in the compiler

@Vatsalsoni13
Copy link
Collaborator

Hello, @Jyo561 thanks for using the 8086 emulator web.
As for your question, we would recommend referring to the instruction page, we tried to keep the syntax simple and somewhat similar to assemblers like gas/nasm ; along with that we made some decisions which we thought would be helpful for beginners when coding to avoid accidental errors, and some syntax was changed due to conflicts in the parser. As a result, the syntax for this can be different from the syntax of emu8086 in some places, for example, whenever you want to access memory for data, you have to specify if you want to access byte memory or word memory; this prevents accidentally using incorrect size values or registers.

For accessing the memory it starts with 0 and use byte [0] for accessing the first element for example.
You can also check the examples

@Jyo561
Copy link
Author

Jyo561 commented Jun 7, 2022

I am not getting how to apply indirect addressing mode in it?

@Vatsalsoni13
Copy link
Collaborator

Hope this helps

vals:
DB 0x3                 ; declaration of the numbers
DB 0x2

start:
MOV SI, 0      
MOV AH, byte [SI]
INC SI
MOV BH, byte [SI]
ADD AH, BH

@Jyo561
Copy link
Author

Jyo561 commented Jun 7, 2022

and can u suggest how change values in the memory location
just like we do in Emu8086

@Vatsalsoni13
Copy link
Collaborator

MOV byte [address] , value
here value can be number, register,etc
Note : Memory location starts from index 0

@Jyo561
Copy link
Author

Jyo561 commented Jun 7, 2022

thanks but i was asking if we can directly change values in the memory section
like if the code is
MOV AX,byte [0x5004]
so how can we put the values directly in the memory location by going to the set address so as to be accessed by AX

@Vatsalsoni13
Copy link
Collaborator

Vatsalsoni13 commented Jun 7, 2022

So if you run

start:
MOV byte [0], 8

Then you will notice in memory the first element will be 8
And to access it
Use SI
Hope this answers your question if not do let us know

@Jyo561
Copy link
Author

Jyo561 commented Jun 7, 2022

Can we put data to 5000 address using DB?
how to use hexadecimal in emulator?

@Vatsalsoni13
Copy link
Collaborator

Vatsalsoni13 commented Jun 8, 2022

The memory is based on an index starting from 0 and not the actual address you can read the note for the reason.
When you use DB it will by default store the date starting from first index.
But you can represent the index in decimal or hexadecimal
eg:

MOV byte [0xA], 7

This will store number 7 in the 10th index. Same way in place of 7 you can use hexadecimal.

@YJDoc2
Copy link
Owner

YJDoc2 commented Jun 8, 2022

@Jyo561 Apart from what @Vatsalsoni13 has suggested, if you want a way to store data at "compile" time, you can use the set directive.

DB 0x75     ;this will be stored at mem loc 0
set 0x100    ; this will set the DS to 0x100
DB 0x57     ; this will be stored at 0x100 * 0x10 = 0x1000
DB 0x88     ; this will be stored at 0x1001 

You can check this works by compiling and setting the mem location to the * 0x10 value. (Note that the set input for memory takes hex values)

Hope this helps :)

@Jyo561
Copy link
Author

Jyo561 commented Jun 14, 2022

set 0x2000
DW 0x0004
DW 0x0012; declaration of the numbers
DW 0x0014
DW 0x0016
DW 0x0018
set 0x0000 //why this line is not working

start:
MOV SI,0x2000
MOV CX,word [SI]
MOV BX,CX
MOV AX,0x0000
INC SI
INC SI
BACK:ADD AX,word [SI]
JNC SKIP
INC DX
SKIP:INC SI
INC SI
DEC CX
JNZ BACK

INC SI
INC SI
MOV word [SI],DX
INC SI
INC SI
MOV word [SI],AX
DIV BX
INC SI
INC SI
MOV word [SI],DX
INC SI
INC SI
MOV word [SI],AX
DIV BX
HLT

@Vatsalsoni13
Copy link
Collaborator

Vatsalsoni13 commented Jun 15, 2022

The program is fine but I guess you have miscalculated the address, after set 0x2000 the address for DW 0x0004 will be 0x2000 * 0x10 which goes out of the range of memory
Here is what you can do use set in the program
eg

set 0x1
DW 0x0004    ;will be saved in the 1st row(note we are using 0-based indexing)

@Jyo561Python
Copy link

how to write this piece of Code
ARR: DB 0x25,0x38,0x0AA,0x0F,0x12,0x22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants